summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Guerry <bzg@altern.org>2011-08-17 11:20:42 +0200
committerBastien Guerry <bzg@altern.org>2011-08-17 11:20:42 +0200
commitc25165c25dc9fdb5b57b3c66b2e0ec0efdbeb7ad (patch)
treefecc7290a74084b2a9998e7a79f1ceb9671040cd
parent163cc3898636f6bc957c66df02210ec83d8efeee (diff)
downloadorg-mode-c25165c25dc9fdb5b57b3c66b2e0ec0efdbeb7ad.tar.gz
org-refile: New option `org-refile-active-region-within-subtree'.
* org.el (org-refile-active-region-within-subtree): New option to allow refiling a region that is part of a subtree without containing a subtree itself. This default to `nil'. (org-refile): Use the new option. Put point at the beginning of the region/subtree to be refiled, so that users understand what will be refiled. Also improve the prompt to tell whether the user is refiling a region or a headline. Thanks to Jeff Horn for raising the issue of refiling a list item, and to Nicolas Goaziou, Nick Dokos and Suvayu Ali for discussing them patiently. The discussion led to these changes.
-rw-r--r--lisp/org.el21
1 files changed, 18 insertions, 3 deletions
diff --git a/lisp/org.el b/lisp/org.el
index d9572c2..737bcc1 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -1970,6 +1970,16 @@ heading."
(const :tag "Always" t)
(const :tag "Prompt for confirmation" confirm)))
+(defcustom org-refile-active-region-within-subtree nil
+ "Non-nil means also refile active region within a subtree.
+
+By default `org-refile' doesn't allow refiling regions if they
+don't contain a set of subtrees, but it might be convenient to
+do so sometimes: in that case, the first line of the region is
+converted to a headline before refiling."
+ :group 'org-refile
+ :type 'boolean)
+
(defgroup org-todo nil
"Options concerning TODO items in Org-mode."
:tag "Org TODO"
@@ -10435,8 +10445,10 @@ prefix argument (`C-u C-u C-u C-c C-w')."
(goto-char region-start)
(or (bolp) (goto-char (point-at-bol)))
(setq region-start (point))
- (unless (org-kill-is-subtree-p
- (buffer-substring region-start region-end))
+ (unless (or (org-kill-is-subtree-p
+ (buffer-substring region-start region-end))
+ (prog1 org-refile-active-region-within-subtree
+ (org-toggle-heading)))
(error "The region is not a (sequence of) subtree(s)")))
(if (equal goto '(16))
(org-refile-goto-last-stored)
@@ -10452,8 +10464,11 @@ prefix argument (`C-u C-u C-u C-c C-w')."
(setq goto nil)))
(setq it (or rfloc
(save-excursion
+ (org-back-to-heading t)
(org-refile-get-location
- (if goto "Goto" "Refile to") default-buffer
+ (cond (goto "Goto")
+ (regionp "Refile region to")
+ (t "Refile subtree to")) default-buffer
org-refile-allow-creating-parent-nodes)))))
(setq file (nth 1 it)
re (nth 2 it)