Browse Source

org-refile.el: Fix commit 63fd0c09ca

* lisp/org-refile.el (org-refile-get-location): Set
`org-refile-history' correctly.
Bastien 7 months ago
parent
commit
da97799a1d
1 changed files with 12 additions and 8 deletions
  1. 12 8
      lisp/org-refile.el

+ 12 - 8
lisp/org-refile.el

@@ -773,20 +773,23 @@ this function appends the default value from
 	       org-refile-target-table))
 	 (completion-ignore-case t)
 	 cdef
-	 (last-refile-loc (car org-refile-history))
-	 (last-refile-loc-path (concat last-refile-loc
-				       (if org-refile-use-outline-path "/")))
 	 (prompt (concat prompt
-			 (or (and last-refile-loc
-				  (concat " (default " last-refile-loc ")"))
+			 (or (and (car org-refile-history)
+				  (concat " (default " (car org-refile-history) ")"))
 			     (and (assoc cbnex tbl) (setq cdef cbnex)
 				  (concat " (default " cbnex ")"))) ": "))
 	 pa answ parent-target child parent old-hist)
     (setq old-hist org-refile-history)
     (setq answ (funcall cfunc prompt tbl nil (not new-nodes)
-			nil 'org-refile-history (or cdef last-refile-loc-path)))
+			nil 'org-refile-history
+			(or cdef (concat (car org-refile-history)
+					 (when (and org-refile-use-outline-path)
+					   "/")))))
     (if (setq pa (org-refile--get-location answ tbl))
-	(progn
+	(let* ((last-refile-loc (car org-refile-history))
+	       (last-refile-loc-path
+		(concat last-refile-loc
+			(when (and org-refile-use-outline-path) "/"))))
 	  (org-refile-check-position pa)
 	  (when (or (not org-refile-history)
 		    (not (eq old-hist org-refile-history))
@@ -795,7 +798,8 @@ this function appends the default value from
 		  (cons (car pa) (if (assoc last-refile-loc tbl)
 				     org-refile-history
 				   (cdr org-refile-history))))
-	    (when (equal last-refile-loc (nth 1 org-refile-history))
+	    (when (or (equal last-refile-loc-path (nth 1 org-refile-history))
+		      (equal last-refile-loc (nth 1 org-refile-history)))
 	      (pop org-refile-history)))
 	  pa)
       (if (string-match "\\`\\(.*\\)/\\([^/]+\\)\\'" answ)