emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Sebastian Reuße" <seb@wirrsal.net>
To: emacs-orgmode@gnu.org
Cc: "Sebastian Reuße" <seb@wirrsal.net>
Subject: [PATCH 2/2] org-refile: optionally prefix refile targets with buffer name
Date: Wed,  3 May 2017 22:30:46 +0200	[thread overview]
Message-ID: <20170503203046.31610-2-seb@wirrsal.net> (raw)
In-Reply-To: <20170503203046.31610-1-seb@wirrsal.net>

* 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 ad92f3b2e..342143d5a 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)
@@ -11578,6 +11583,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	other threads:[~2017-05-03 20:31 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-03 17:50 [PATCH 1/2] org-refile: escape slashes only in headline of refile target Sebastian Reuße
2017-05-03 17:50 ` [PATCH 2/2] org-refile: optionally prefix refile targets with buffer name Sebastian Reuße
2017-05-03 20:30   ` [PATCH 1/2] org-refile: escape slashes only in headline of refile target Sebastian Reuße
2017-05-03 20:30     ` Sebastian Reuße [this message]
2017-05-03 20:33       ` [PATCH 2/2] org-refile: optionally prefix refile targets with buffer name Sebastian Reuße
2017-05-05 23:23       ` Kyle Meyer
2017-05-05 23:22     ` [PATCH 1/2] org-refile: escape slashes only in headline of refile target Kyle Meyer
2017-05-06  5:51       ` [PATCH 1/2] org-refile: Escape " Sebastian Reuße
2017-05-06  5:51         ` [PATCH 2/2] org-refile: Optionally prefix refile targets with buffer name Sebastian Reuße
2017-05-06  6:34           ` [PATCH 1/2] org-refile: Escape slashes only in headline of refile target Sebastian Reuße
2017-05-06  6:34             ` [PATCH 2/2] org-refile: Optionally prefix refile targets with buffer name Sebastian Reuße
2017-05-06  6:38               ` [PATCH 1/2] org-refile: Escape slashes only in headline of refile target Sebastian Reuße
2017-05-06  6:38                 ` [PATCH 2/2] org-refile: Optionally prefix refile targets with buffer name Sebastian Reuße
2017-05-06  6:41       ` [PATCH 1/2] org-refile: escape slashes only in headline of refile target Sebastian Reuße
2017-05-06 16:07         ` Kyle Meyer
2017-05-06 19:04           ` [PATCH] ORG-NEWS: Update new features Sebastian Reuße
2017-05-06 20:19             ` Kyle Meyer
2017-05-07 10:04               ` Nicolas Goaziou
2017-05-06  6:44       ` [PATCH 1/2] org-refile: escape slashes only in headline of refile target Sebastian Reuße
2017-05-06 16:08         ` Kyle Meyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170503203046.31610-2-seb@wirrsal.net \
    --to=seb@wirrsal.net \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).