From f19af99d2a74b7a3ceb2d66626955b7704cb9788 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Sun, 23 Sep 2012 10:04:29 +0200 Subject: [PATCH] org.el: Use the current file name as the default target when there is no refile history * org.el (org-refile-get-location): Use the current file name as the default target when there is no refile history. --- lisp/org.el | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index fe63b62f1..e139846c5 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -11114,11 +11114,7 @@ this is used for the GOTO interface." (org-refile-get-targets default-buffer excluded-entries))) (unless org-refile-target-table (error "No refile targets")) - (let* ((prompt (concat prompt - (and (car org-refile-history) - (concat " (default " (car org-refile-history) ")")) - ": ")) - (cbuf (current-buffer)) + (let* ((cbuf (current-buffer)) (partial-completion-mode nil) (cfn (buffer-file-name (buffer-base-buffer cbuf))) (cfunc (if (and org-refile-use-outline-path @@ -11126,6 +11122,7 @@ this is used for the GOTO interface." 'org-olpath-completing-read 'org-icompleting-read)) (extra (if org-refile-use-outline-path "/" "")) + (cbnex (concat (buffer-name) extra)) (filename (and cfn (expand-file-name cfn))) (tbl (mapcar (lambda (x) @@ -11138,10 +11135,16 @@ this is used for the GOTO interface." (cons (concat (car x) extra) (cdr x)))) org-refile-target-table)) (completion-ignore-case t) + cdef + (prompt (concat prompt + (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 (car org-refile-history))) + nil 'org-refile-history (or cdef (car org-refile-history)))) (setq pa (or (assoc answ tbl) (assoc (concat answ "/") tbl))) (org-refile-check-position pa) (if pa