فهرست منبع

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.
Bastien Guerry 14 سال پیش
والد
کامیت
c25165c25d
1فایلهای تغییر یافته به همراه18 افزوده شده و 3 حذف شده
  1. 18 3
      lisp/org.el

+ 18 - 3
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)