Browse Source

org.el (org-refile): Only keep bracket links descriptions in the displayed heading

* org.el (org-refile): Rename first argument to arg, as its
use goes beyond is now more general.  Only keep bracket links
descriptions in the displayed heading.  Enhance docstring.
Bastien Guerry 11 years ago
parent
commit
932b41e973
1 changed files with 27 additions and 28 deletions
  1. 27 28
      lisp/org.el

+ 27 - 28
lisp/org.el

@@ -11580,22 +11580,21 @@ the *old* location.")
   (let ((org-refile-keep t))
   (let ((org-refile-keep t))
     (funcall 'org-refile nil nil nil "Copy")))
     (funcall 'org-refile nil nil nil "Copy")))
 
 
-(defun org-refile (&optional goto default-buffer rfloc msg)
+(defun org-refile (&optional arg default-buffer rfloc msg)
   "Move the entry or entries at point to another heading.
   "Move the entry or entries at point to another heading.
 The list of target headings is compiled using the information in
 The list of target headings is compiled using the information in
 `org-refile-targets', which see.
 `org-refile-targets', which see.
 
 
-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.
+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 fulfill 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.
+If there is an active region, all entries in that region will be
+refiled.  However, the region must fulfill the requirement that
+the first heading sets the top-level of the moved text.
 
 
-With prefix arg GOTO, the command will only visit the target location
-and not actually move anything.
+With prefix arg ARG, the command will only visit the target
+location and not actually move anything.
 
 
 With a double prefix arg \\[universal-argument] \\[universal-argument], go to the location where the last
 With a double prefix arg \\[universal-argument] \\[universal-argument], go to the location where the last
 refiling operation has put the subtree.
 refiling operation has put the subtree.
@@ -11614,23 +11613,22 @@ another verb.  E.g. `org-copy' sets this parameter to \"Copy\".
 
 
 See also `org-refile-use-outline-path' and `org-completion-use-ido'.
 See also `org-refile-use-outline-path' and `org-completion-use-ido'.
 
 
-If you are using target caching (see `org-refile-use-cache'),
-you have to clear the target cache in order to find new targets.
+If you are using target caching (see `org-refile-use-cache'), you
+have to clear the target cache in order to find new targets.
 This can be done with a 0 prefix (`C-0 C-c C-w') or a triple
 This can be done with a 0 prefix (`C-0 C-c C-w') or a triple
 prefix argument (`C-u C-u C-u C-c C-w')."
 prefix argument (`C-u C-u C-u C-c C-w')."
-
   (interactive "P")
   (interactive "P")
-  (if (member goto '(0 (64)))
+  (if (member arg '(0 (64)))
       (org-refile-cache-clear)
       (org-refile-cache-clear)
     (let* ((actionmsg (cond (msg msg)
     (let* ((actionmsg (cond (msg msg)
-			    ((equal goto 3) "Refile (and keep)")
+			    ((equal arg 3) "Refile (and keep)")
 			    (t "Refile")))
 			    (t "Refile")))
 	   (cbuf (current-buffer))
 	   (cbuf (current-buffer))
 	   (regionp (org-region-active-p))
 	   (regionp (org-region-active-p))
 	   (region-start (and regionp (region-beginning)))
 	   (region-start (and regionp (region-beginning)))
 	   (region-end (and regionp (region-end)))
 	   (region-end (and regionp (region-end)))
 	   (filename (buffer-file-name (buffer-base-buffer cbuf)))
 	   (filename (buffer-file-name (buffer-base-buffer cbuf)))
-	   (org-refile-keep (if (equal goto 3) t org-refile-keep))
+	   (org-refile-keep (if (equal arg 3) t org-refile-keep))
 	   pos it nbuf file re level reversed)
 	   pos it nbuf file re level reversed)
       (setq last-command nil)
       (setq last-command nil)
       (when regionp
       (when regionp
@@ -11644,10 +11642,10 @@ prefix argument (`C-u C-u C-u C-c C-w')."
 			(org-toggle-heading)
 			(org-toggle-heading)
 			(setq region-end (+ (- (point-at-eol) s) region-end)))))
 			(setq region-end (+ (- (point-at-eol) s) region-end)))))
 	  (user-error "The region is not a (sequence of) subtree(s)")))
 	  (user-error "The region is not a (sequence of) subtree(s)")))
-      (if (equal goto '(16))
+      (if (equal arg '(16))
 	  (org-refile-goto-last-stored)
 	  (org-refile-goto-last-stored)
 	(when (or
 	(when (or
-	       (and (equal goto 2)
+	       (and (equal arg 2)
 		    org-clock-hd-marker (marker-buffer org-clock-hd-marker)
 		    org-clock-hd-marker (marker-buffer org-clock-hd-marker)
 		    (prog1
 		    (prog1
 			(setq it (list (or org-clock-heading "running clock")
 			(setq it (list (or org-clock-heading "running clock")
@@ -11655,28 +11653,30 @@ prefix argument (`C-u C-u C-u C-c C-w')."
 					(marker-buffer org-clock-hd-marker))
 					(marker-buffer org-clock-hd-marker))
 				       ""
 				       ""
 				       (marker-position org-clock-hd-marker)))
 				       (marker-position org-clock-hd-marker)))
-		      (setq goto nil)))
+		      (setq arg nil)))
 	       (setq it (or rfloc
 	       (setq it (or rfloc
 			    (let (heading-text)
 			    (let (heading-text)
 			      (save-excursion
 			      (save-excursion
-				(unless (and goto (listp goto))
+				(unless (and arg (listp arg))
 				  (org-back-to-heading t)
 				  (org-back-to-heading t)
 				  (setq heading-text
 				  (setq heading-text
-					(nth 4 (org-heading-components))))
-
+					(replace-regexp-in-string
+					 org-bracket-link-regexp
+					 "\\3"
+					 (nth 4 (org-heading-components)))))
 				(org-refile-get-location
 				(org-refile-get-location
-				 (cond ((and goto (listp goto)) "Goto")
+				 (cond ((and arg (listp arg)) "Goto")
 				       (regionp (concat actionmsg " region to"))
 				       (regionp (concat actionmsg " region to"))
 				       (t (concat actionmsg " subtree \""
 				       (t (concat actionmsg " subtree \""
 						  heading-text "\" to")))
 						  heading-text "\" to")))
 				 default-buffer
 				 default-buffer
-				 (and (not (equal '(4) goto))
+				 (and (not (equal '(4) arg))
 				      org-refile-allow-creating-parent-nodes)
 				      org-refile-allow-creating-parent-nodes)
-				 goto))))))
+				 arg))))))
 	  (setq file (nth 1 it)
 	  (setq file (nth 1 it)
 		re (nth 2 it)
 		re (nth 2 it)
 		pos (nth 3 it))
 		pos (nth 3 it))
-	  (if (and (not goto)
+	  (if (and (not arg)
 		   pos
 		   pos
 		   (equal (buffer-file-name) file)
 		   (equal (buffer-file-name) file)
 		   (if regionp
 		   (if regionp
@@ -11686,10 +11686,9 @@ prefix argument (`C-u C-u C-u C-c C-w')."
 			  (< pos (save-excursion
 			  (< pos (save-excursion
 				   (org-end-of-subtree t t))))))
 				   (org-end-of-subtree t t))))))
 	      (error "Cannot refile to position inside the tree or region"))
 	      (error "Cannot refile to position inside the tree or region"))
-
 	  (setq nbuf (or (find-buffer-visiting file)
 	  (setq nbuf (or (find-buffer-visiting file)
 			 (find-file-noselect file)))
 			 (find-file-noselect file)))
-	  (if (and goto (not (equal goto 3)))
+	  (if (and arg (not (equal arg 3)))
 	      (progn
 	      (progn
 		(org-pop-to-buffer-same-window nbuf)
 		(org-pop-to-buffer-same-window nbuf)
 		(goto-char pos)
 		(goto-char pos)