emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] [PATCH 2/2] org-refile: optionally prefix refile targets with buffer


From: Sebastian Reuße
Subject: [O] [PATCH 2/2] org-refile: optionally prefix refile targets with buffer name
Date: Wed, 3 May 2017 19:50:03 +0200

* org.el (org-refile-get-targets): Add case to optionally prefix
refile targets with the buffer name.
(org-refile-use-outline-path): Document new option.

Having an option to use the buffer name as a prefix is convenient,
since this will work hand in hand with uniquify to only show those
parts of the filesystem path needed to disambiguate buffers of
identically named files, as opposed to prefixing refile targets with
the full filesystem path.
---
 lisp/org.el | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lisp/org.el b/lisp/org.el
index ad92f3b2e..06066230f 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -2553,7 +2553,9 @@ (defcustom org-refile-use-outline-path nil
 into the path.  In this case, you can also stop the completion after
 the file name, to get entries inserted as top level in the file.
 
-When `full-file-path', include the full file path."
+When `full-file-path', include the full file path.
+
+When `id', use the buffer name."
   :group 'org-refile
   :type '(choice
          (const :tag "Not" nil)
@@ -11557,6 +11559,8 @@ (defun org-refile-get-targets (&optional default-buffer)
               (setq f (and f (expand-file-name f)))
               (when (eq org-refile-use-outline-path 'file)
                 (push (list (file-name-nondirectory f) f nil nil) tgs))
+              (when (eq org-refile-use-outline-path 'id)
+                (push (list (buffer-name (buffer-base-buffer)) f nil nil) tgs))
               (org-with-wide-buffer
                (goto-char (point-min))
                (setq org-outline-path-cache nil)
@@ -11578,6 +11582,8 @@ (defun org-refile-get-targets (&optional default-buffer)
                               (string-join
                                (cons
                                 (pcase org-refile-use-outline-path
+                                  (`id (buffer-name
+                                        (buffer-base-buffer)))
                                   (`file (file-name-nondirectory
                                           (buffer-file-name
                                            (buffer-base-buffer))))
-- 
2.12.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]