mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2025-01-05 11:45:52 +00:00
Implement refiling for regions.
The refile command allows to move a subtree to under some other heading, in the current file or even in a different file. Sometimes one has a number of sibling subtrees that should all be refiled to the same location. This patch implements a simplification for this process. You can mark the region of subtrees (using transient-mark-mode in required for this) and then move them all with a single command.
This commit is contained in:
parent
43c946b12d
commit
9a46feebfc
@ -2,6 +2,7 @@
|
||||
|
||||
* org.texi (Clocking work time): Document the :formula property of
|
||||
clock tables.
|
||||
(Structure editing, Refiling notes): Document refiling regions.
|
||||
|
||||
2008-11-09 Carsten Dominik <carsten.dominik@gmail.com>
|
||||
|
||||
|
22
doc/org.texi
22
doc/org.texi
@ -952,7 +952,7 @@ paste subtrees folded and in a clever way, using the same command as @kbd{C-c
|
||||
C-x C-y}.
|
||||
@kindex C-c C-w
|
||||
@item C-c C-w
|
||||
Refile entry to a different location. @xref{Refiling notes}.
|
||||
Refile entry or region to a different location. @xref{Refiling notes}.
|
||||
@kindex C-c ^
|
||||
@item C-c ^
|
||||
Sort same-level entries. When there is an active region, all entries in the
|
||||
@ -5185,16 +5185,16 @@ special command:
|
||||
@table @kbd
|
||||
@kindex C-c C-w
|
||||
@item C-c C-w
|
||||
Refile the entry at point. This command offers possible locations for
|
||||
refiling the entry and lets you select one with completion. The item is
|
||||
filed below the target heading as a subitem. Depending on
|
||||
@code{org-reverse-note-order}, it will be either the first of last
|
||||
subitem.@* By default, all level 1 headlines in the current buffer are
|
||||
considered to be targets, but you can have more complex definitions
|
||||
across a number of files. See the variable @code{org-refile-targets}
|
||||
for details. If you would like to select a location via a file-pathlike
|
||||
completion along the outline path, see the variable
|
||||
@code{org-refile-use-outline-path}.
|
||||
Refile the entry or region at point. This command offers possible locations
|
||||
for refiling the entry and lets you select one with completion. The item (or
|
||||
all items in the region) is filed below the target heading as a subitem.
|
||||
Depending on @code{org-reverse-note-order}, it will be either the first of
|
||||
last subitem.@*
|
||||
By default, all level 1 headlines in the current buffer are considered to be
|
||||
targets, but you can have more complex definitions across a number of files.
|
||||
See the variable @code{org-refile-targets} for details. If you would like to
|
||||
select a location via a file-pathlike completion along the outline path, see
|
||||
the variable @code{org-refile-use-outline-path}.
|
||||
@kindex C-u C-c C-w
|
||||
@item C-u C-c C-w
|
||||
Use the refile interface to jump to a heading.
|
||||
|
@ -1,5 +1,7 @@
|
||||
2008-11-10 Carsten Dominik <carsten.dominik@gmail.com>
|
||||
|
||||
* org.el (org-refile): Allow refiling of entire regions.
|
||||
|
||||
* org-clock.el (org-clock-time%): New function.
|
||||
|
||||
* org.el (org-entry-get, org-entry-delete): Use safer regexps to
|
||||
|
27
lisp/org.el
27
lisp/org.el
@ -1294,7 +1294,7 @@ This is list of cons cells. Each cell contains:
|
||||
- a cons cell (:maxlevel . N). Any headline with level <= N is a target.
|
||||
|
||||
When this variable is nil, all top-level headlines in the current buffer
|
||||
are used, equivalent to the vlaue `((nil . (:level . 1))'."
|
||||
are used, equivalent to the value `((nil . (:level . 1))'."
|
||||
:group 'org-remember
|
||||
:type '(repeat
|
||||
(cons
|
||||
@ -7333,14 +7333,27 @@ At the target location, the entry is filed as a subitem of the target heading.
|
||||
Depending on `org-reverse-note-order', the new subitem will either be the
|
||||
first or the last subitem.
|
||||
|
||||
If there is an active region, all entries in that region will be moved.
|
||||
However, the region must fulfil the requirement that the first heading
|
||||
is the first one sets the top-level of the moved text - at most siblings
|
||||
below it are allowed.
|
||||
|
||||
With prefix arg GOTO, the command will only visit the target location,
|
||||
not actually move anything.
|
||||
With a double prefix `C-u C-u', go to the location where the last refiling
|
||||
operation has put the subtree."
|
||||
(interactive "P")
|
||||
(let* ((cbuf (current-buffer))
|
||||
(regionp (org-region-active-p))
|
||||
(region-start (and regionp (region-beginning)))
|
||||
(region-end (and regionp (region-end)))
|
||||
(region-length (and regionp (- region-end region-start)))
|
||||
(filename (buffer-file-name (buffer-base-buffer cbuf)))
|
||||
pos it nbuf file re level reversed)
|
||||
(when regionp (goto-char region-start)
|
||||
(unless (org-kill-is-subtree-p
|
||||
(buffer-substring region-start region-end))
|
||||
(error "The region is not a (sequence of) subtree(s)")))
|
||||
(if (equal goto '(16))
|
||||
(org-refile-goto-last-stored)
|
||||
(when (setq it (org-refile-get-location
|
||||
@ -7355,7 +7368,11 @@ operation has put the subtree."
|
||||
(switch-to-buffer nbuf)
|
||||
(goto-char pos)
|
||||
(org-show-context 'org-goto))
|
||||
(org-copy-subtree 1 nil t)
|
||||
(if regionp
|
||||
(progn
|
||||
(kill-new (buffer-substring region-start region-end))
|
||||
(org-save-markers-in-region region-start region-end))
|
||||
(org-copy-subtree 1 nil t))
|
||||
(save-excursion
|
||||
(set-buffer (setq nbuf (or (find-buffer-visiting file)
|
||||
(find-file-noselect file))))
|
||||
@ -7375,9 +7392,11 @@ operation has put the subtree."
|
||||
(if (not (bolp)) (newline))
|
||||
(bookmark-set "org-refile-last-stored")
|
||||
(org-paste-subtree level))))
|
||||
(org-cut-subtree)
|
||||
(if regionp
|
||||
(delete-region (point) (+ (point) region-length))
|
||||
(org-cut-subtree))
|
||||
(setq org-markers-to-move nil)
|
||||
(message "Entry refiled to \"%s\"" (car it)))))))
|
||||
(message "Refiled to \"%s\"" (car it)))))))
|
||||
|
||||
(defun org-refile-goto-last-stored ()
|
||||
"Go to the location where the last refile was stored."
|
||||
|
Loading…
Reference in New Issue
Block a user