mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-08-27 04:02:53 +00:00
Implement automatic level adjustment for yanked subtrees.
This commit is contained in:
parent
407a84af1b
commit
8cc9b150c8
|
@ -1,3 +1,4 @@
|
||||||
|
|
||||||
2008-10-27 Carsten Dominik <dominik@science.uva.nl>
|
2008-10-27 Carsten Dominik <dominik@science.uva.nl>
|
||||||
|
|
||||||
* org.el ("saveplace"): If saveplace puts point into an invisible
|
* org.el ("saveplace"): If saveplace puts point into an invisible
|
||||||
|
@ -8,7 +9,9 @@
|
||||||
(org-yank): Incorporate adjusting trees.
|
(org-yank): Incorporate adjusting trees.
|
||||||
(org-paste-subtree): New argument FOR-YANK which will cause
|
(org-paste-subtree): New argument FOR-YANK which will cause
|
||||||
insertion at point without backing up over white lines, and leave
|
insertion at point without backing up over white lines, and leave
|
||||||
point at the end of the inserted text.
|
point at the end of the inserted text. Also if the cursor is
|
||||||
|
at the beginning of a headline, use the same level or the inserted
|
||||||
|
tree.
|
||||||
|
|
||||||
* org-publish.el (org-publish-get-base-files-1): Deal correctly
|
* org-publish.el (org-publish-get-base-files-1): Deal correctly
|
||||||
with broken symlinks
|
with broken symlinks
|
||||||
|
|
23
lisp/org.el
23
lisp/org.el
|
@ -5057,7 +5057,12 @@ useful if the caller implements cut-and-paste as copy-then-paste-then-cut."
|
||||||
(defun org-paste-subtree (&optional level tree for-yank)
|
(defun org-paste-subtree (&optional level tree for-yank)
|
||||||
"Paste the clipboard as a subtree, with modification of headline level.
|
"Paste the clipboard as a subtree, with modification of headline level.
|
||||||
The entire subtree is promoted or demoted in order to match a new headline
|
The entire subtree is promoted or demoted in order to match a new headline
|
||||||
level. By default, the new level is derived from the *visible* headings
|
level.
|
||||||
|
|
||||||
|
If the cursor is at the beginning of a headline, the same level as
|
||||||
|
that headline is used to paste the tree
|
||||||
|
|
||||||
|
If not, the new level is derived from the *visible* headings
|
||||||
before and after the insertion point, and taken to be the inferior headline
|
before and after the insertion point, and taken to be the inferior headline
|
||||||
level of the two. So if the previous visible heading is level 3 and the
|
level of the two. So if the previous visible heading is level 3 and the
|
||||||
next is level 4 (or vice versa), level 4 will be used for insertion.
|
next is level 4 (or vice versa), level 4 will be used for insertion.
|
||||||
|
@ -5068,8 +5073,6 @@ You can also force a different level, either by using a numeric prefix
|
||||||
argument, or by inserting the heading marker by hand. For example, if the
|
argument, or by inserting the heading marker by hand. For example, if the
|
||||||
cursor is after \"*****\", then the tree will be shifted to level 5.
|
cursor is after \"*****\", then the tree will be shifted to level 5.
|
||||||
|
|
||||||
If you want to insert the tree as is, just use \\[yank].
|
|
||||||
|
|
||||||
If optional TREE is given, use this text instead of the kill ring.
|
If optional TREE is given, use this text instead of the kill ring.
|
||||||
|
|
||||||
When FOR-YANK is set, this is called by `org-yank'. In this case, do not
|
When FOR-YANK is set, this is called by `org-yank'. In this case, do not
|
||||||
|
@ -5090,9 +5093,14 @@ the inserted text when done."
|
||||||
(- (match-end 0) (match-beginning 0) 1)
|
(- (match-end 0) (match-beginning 0) 1)
|
||||||
-1))
|
-1))
|
||||||
(force-level (cond (level (prefix-numeric-value level))
|
(force-level (cond (level (prefix-numeric-value level))
|
||||||
((string-match
|
((and (looking-at "[ \t]*$")
|
||||||
^re_ (buffer-substring (point-at-bol) (point)))
|
(string-match
|
||||||
|
^re_ (buffer-substring
|
||||||
|
(point-at-bol) (point))))
|
||||||
(- (match-end 1) (match-beginning 1)))
|
(- (match-end 1) (match-beginning 1)))
|
||||||
|
((and (bolp)
|
||||||
|
(looking-at org-outline-regexp))
|
||||||
|
(- (match-end 0) (point) 1))
|
||||||
(t nil)))
|
(t nil)))
|
||||||
(previous-level (save-excursion
|
(previous-level (save-excursion
|
||||||
(condition-case nil
|
(condition-case nil
|
||||||
|
@ -5147,9 +5155,10 @@ the inserted text when done."
|
||||||
(setq shift (+ delta shift)))
|
(setq shift (+ delta shift)))
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(setq newend (point-max))))
|
(setq newend (point-max))))
|
||||||
(when (interactive-p)
|
(when (or (interactive-p) for-yank)
|
||||||
(message "Clipboard pasted as level %d subtree" new-level))
|
(message "Clipboard pasted as level %d subtree" new-level))
|
||||||
(if (and kill-ring
|
(if (and (not for-yank) ; in this case, org-yank will decide about folding
|
||||||
|
kill-ring
|
||||||
(eq org-subtree-clip (current-kill 0))
|
(eq org-subtree-clip (current-kill 0))
|
||||||
org-subtree-clip-folded)
|
org-subtree-clip-folded)
|
||||||
;; The tree was folded before it was killed/copied
|
;; The tree was folded before it was killed/copied
|
||||||
|
|
Loading…
Reference in a new issue