From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?q?Sebastian=20Reu=C3=9Fe?= Subject: [PATCH 2/2] org-refile: Optionally prefix refile targets with buffer name Date: Sat, 6 May 2017 08:34:32 +0200 Message-ID: <20170506063432.17977-2-seb@wirrsal.net> References: <20170506055115.11705-2-seb@wirrsal.net> <20170506063432.17977-1-seb@wirrsal.net> Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:37504) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6tIi-0004LI-Jy for emacs-orgmode@gnu.org; Sat, 06 May 2017 02:34:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d6tIg-0000AH-Mk for emacs-orgmode@gnu.org; Sat, 06 May 2017 02:34:44 -0400 Received: from wirrsal.net ([188.68.36.149]:40742 helo=mail.wirrsal.net) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d6tIg-0000A7-Fk for emacs-orgmode@gnu.org; Sat, 06 May 2017 02:34:42 -0400 In-Reply-To: <20170506063432.17977-1-seb@wirrsal.net> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org Cc: =?UTF-8?q?Sebastian=20Reu=C3=9Fe?= * org.el (org-refile-get-targets): Add case to optionally prefix refile targets with the buffer name. (org-refile-use-outline-path): Add new option setting and document. 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 | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index 5d8166c99..e6b154716 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -2553,13 +2553,16 @@ (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) (const :tag "Yes" t) (const :tag "Start with file name" file) - (const :tag "Start with full file path" full-file-path))) + (const :tag "Start with full file path" full-file-path) + (const :tag "Start with buffer name" id))) (defcustom org-outline-path-complete-in-steps t "Non-nil means complete the outline path in hierarchical steps. @@ -11557,6 +11560,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) @@ -11585,6 +11590,8 @@ (defun org-refile-get-targets (&optional default-buffer) (`full-file-path (list (buffer-file-name (buffer-base-buffer)))) + (`id (list (buffer-name + (buffer-base-buffer)))) (_ nil)) (mapcar #'org-protect-slash (org-get-outline-path t t))) -- 2.12.2