emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH 1/2] org-refile: escape slashes only in headline of refile target
@ 2017-05-03 17:50 Sebastian Reuße
  2017-05-03 17:50 ` [PATCH 2/2] org-refile: optionally prefix refile targets with buffer name Sebastian Reuße
  0 siblings, 1 reply; 20+ messages in thread
From: Sebastian Reuße @ 2017-05-03 17:50 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Sebastian Reuße

* org.el (org-refile-get-targets): only escape slashes in headline
part of refile target; leave any file-system path component (when
enabled) unescaped.

The reason to escape slashes in refile targets is to make it clear
when a slash was part of a headline vs. part of the outline path.  It
makes sense to treat slashes in the file system part the same way as
outline paths, since this won’t result in any confusion and serves to
make target selection less noisy.
---
 lisp/org.el | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 0d83b4cbd..ad92f3b2e 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -11575,18 +11575,17 @@ (defun org-refile-get-targets (&optional default-buffer)
 					(regexp-quote heading)))
 			    (target
 			     (if (not org-refile-use-outline-path) heading
-			       (mapconcat
-				#'org-protect-slash
-				(append
+			       (string-join
+				(cons
 				 (pcase org-refile-use-outline-path
-				   (`file (list (file-name-nondirectory
-						 (buffer-file-name
-						  (buffer-base-buffer)))))
-				   (`full-file-path
-				    (list (buffer-file-name
-					   (buffer-base-buffer))))
-				   (_ nil))
-				 (org-get-outline-path t t))
+				   (`file (file-name-nondirectory
+					   (buffer-file-name
+					    (buffer-base-buffer))))
+				   (`full-file-path (buffer-file-name
+						     (buffer-base-buffer)))
+				   (_ ""))
+				 (mapcar #'org-protect-slash
+					 (org-get-outline-path t t)))
 				"/"))))
 			(push (list target f re (org-refile-marker (point)))
 			      tgs)))
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 2/2] org-refile: optionally prefix refile targets with buffer name
  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 ` Sebastian Reuße
  2017-05-03 20:30   ` [PATCH 1/2] org-refile: escape slashes only in headline of refile target Sebastian Reuße
  0 siblings, 1 reply; 20+ messages in thread
From: Sebastian Reuße @ 2017-05-03 17:50 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Sebastian Reuße

* 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

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 1/2] org-refile: escape slashes only in headline of refile target
  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   ` Sebastian Reuße
  2017-05-03 20:30     ` [PATCH 2/2] org-refile: optionally prefix refile targets with buffer name Sebastian Reuße
  2017-05-05 23:22     ` [PATCH 1/2] org-refile: escape slashes only in headline of refile target Kyle Meyer
  0 siblings, 2 replies; 20+ messages in thread
From: Sebastian Reuße @ 2017-05-03 20:30 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Sebastian Reuße

* org.el (org-refile-get-targets): only escape slashes in headline
part of refile target; leave any file-system path component (when
enabled) unescaped.

The reason to escape slashes in refile targets is to make it clear
when a slash was part of a headline vs. part of the outline path.  It
makes sense to treat slashes in the file system part the same way as
outline paths, since this won’t result in any confusion and serves to
make target selection less noisy.
---
 lisp/org.el | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 0d83b4cbd..ad92f3b2e 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -11575,18 +11575,17 @@ (defun org-refile-get-targets (&optional default-buffer)
 					(regexp-quote heading)))
 			    (target
 			     (if (not org-refile-use-outline-path) heading
-			       (mapconcat
-				#'org-protect-slash
-				(append
+			       (string-join
+				(cons
 				 (pcase org-refile-use-outline-path
-				   (`file (list (file-name-nondirectory
-						 (buffer-file-name
-						  (buffer-base-buffer)))))
-				   (`full-file-path
-				    (list (buffer-file-name
-					   (buffer-base-buffer))))
-				   (_ nil))
-				 (org-get-outline-path t t))
+				   (`file (file-name-nondirectory
+					   (buffer-file-name
+					    (buffer-base-buffer))))
+				   (`full-file-path (buffer-file-name
+						     (buffer-base-buffer)))
+				   (_ ""))
+				 (mapcar #'org-protect-slash
+					 (org-get-outline-path t t)))
 				"/"))))
 			(push (list target f re (org-refile-marker (point)))
 			      tgs)))
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 2/2] org-refile: optionally prefix refile targets with buffer name
  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
  2017-05-03 20:33       ` 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
  1 sibling, 2 replies; 20+ messages in thread
From: Sebastian Reuße @ 2017-05-03 20:30 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Sebastian Reuße

* 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

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [PATCH 2/2] org-refile: optionally prefix refile targets with buffer name
  2017-05-03 20:30     ` [PATCH 2/2] org-refile: optionally prefix refile targets with buffer name Sebastian Reuße
@ 2017-05-03 20:33       ` Sebastian Reuße
  2017-05-05 23:23       ` Kyle Meyer
  1 sibling, 0 replies; 20+ messages in thread
From: Sebastian Reuße @ 2017-05-03 20:33 UTC (permalink / raw)
  To: emacs-orgmode

Apologies for the resubmission; forgot to stage a hunk in one of the
commits.

Kind regards,
Sebastian Reuße

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 1/2] org-refile: escape slashes only in headline of refile target
  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     ` [PATCH 2/2] org-refile: optionally prefix refile targets with buffer name Sebastian Reuße
@ 2017-05-05 23:22     ` Kyle Meyer
  2017-05-06  5:51       ` [PATCH 1/2] org-refile: Escape " Sebastian Reuße
                         ` (2 more replies)
  1 sibling, 3 replies; 20+ messages in thread
From: Kyle Meyer @ 2017-05-05 23:22 UTC (permalink / raw)
  To: Sebastian Reuße; +Cc: emacs-orgmode

Sebastian Reuße <seb@wirrsal.net> writes:

> * org.el (org-refile-get-targets): only escape slashes in headline

For style consistency, the first word following the colon should be
capitalized.  The same applies to the commit subject.

> part of refile target; leave any file-system path component (when
> enabled) unescaped.
>
> The reason to escape slashes in refile targets is to make it clear
> when a slash was part of a headline vs. part of the outline path.  It
> makes sense to treat slashes in the file system part the same way as
> outline paths, since this won’t result in any confusion and serves to
> make target selection less noisy.

That sounds reasonable to me.

> ---
>  lisp/org.el | 21 ++++++++++-----------
>  1 file changed, 10 insertions(+), 11 deletions(-)

Based on the Org contributor page [*], it doesn't look like you've
signed papers with the FSF, so the commit message should label this as a
"TINYCHANGE".  (I think this and the next patch would be small enough to
mark as tiny changes.)

[*] http://orgmode.org/worg/org-contribute.html

> diff --git a/lisp/org.el b/lisp/org.el
> index 0d83b4cbd..ad92f3b2e 100644
> --- a/lisp/org.el
> +++ b/lisp/org.el
> @@ -11575,18 +11575,17 @@ (defun org-refile-get-targets (&optional default-buffer)
>  					(regexp-quote heading)))
>  			    (target
>  			     (if (not org-refile-use-outline-path) heading
> -			       (mapconcat
> -				#'org-protect-slash
> -				(append
> +			       (string-join

Org's master branch currently supports Emacs >= 24.3, but string-join
was added in the 24.5 release.

> +				(cons
>  				 (pcase org-refile-use-outline-path
> -				   (`file (list (file-name-nondirectory
> -						 (buffer-file-name
> -						  (buffer-base-buffer)))))
> -				   (`full-file-path
> -				    (list (buffer-file-name
> -					   (buffer-base-buffer))))
> -				   (_ nil))
> -				 (org-get-outline-path t t))
> +				   (`file (file-name-nondirectory
> +					   (buffer-file-name
> +					    (buffer-base-buffer))))
> +				   (`full-file-path (buffer-file-name
> +						     (buffer-base-buffer)))
> +				   (_ ""))

I'm fine with the append -> cons conversion, but avoiding it would make
for a cleaner diff that's more focused on the main purpose of this
patch.

Also, it does slightly change the result because the fall-through case
would now include "/" at the start of the path, but I don't think that's
a big deal given that this case shouldn't be reached if the user sets
org-refile-use-outline-path to a valid value.  Which makes me wonder
whether we should just raise a user-error for this fall-through case.

> +				 (mapcar #'org-protect-slash
> +					 (org-get-outline-path t t)))
>  				"/"))))

-- 
Kyle

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 2/2] org-refile: optionally prefix refile targets with buffer name
  2017-05-03 20:30     ` [PATCH 2/2] org-refile: optionally prefix refile targets with buffer name Sebastian Reuße
  2017-05-03 20:33       ` Sebastian Reuße
@ 2017-05-05 23:23       ` Kyle Meyer
  1 sibling, 0 replies; 20+ messages in thread
From: Kyle Meyer @ 2017-05-05 23:23 UTC (permalink / raw)
  To: Sebastian Reuße; +Cc: emacs-orgmode

Sebastian Reuße <seb@wirrsal.net> writes:

> * 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.

Yeah, that does seem useful.

> ---
>  lisp/org.el | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)

I think this should be accompanied by an ORG-NEWS entry.

> 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."

The link between `id' and buffer name isn't obvious to me.  I'm guessing
that it's because it would be a unique ID for the file, whereas `file'
would not.  Perhaps `buffer' would be better?


-- 
Kyle

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 1/2] org-refile: Escape slashes only in headline of refile target
  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       ` 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:41       ` [PATCH 1/2] org-refile: escape slashes only in headline of refile target Sebastian Reuße
  2017-05-06  6:44       ` [PATCH 1/2] org-refile: escape slashes only in headline of refile target Sebastian Reuße
  2 siblings, 1 reply; 20+ messages in thread
From: Sebastian Reuße @ 2017-05-06  5:51 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Sebastian Reuße

* org.el (org-refile-get-targets): Only escape slashes in headline
part of refile target; leave any file-system path component (when
enabled) unescaped.

The reason to escape slashes in refile targets is to make it clear
when a slash was part of a headline vs. part of the outline path.  It
makes sense to treat slashes in the file system part the same way as
outline paths, since this won’t result in any confusion and serves to
make target selection less noisy.
---
 lisp/org.el | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 0d83b4cbd..ad92f3b2e 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -11575,18 +11575,17 @@ (defun org-refile-get-targets (&optional default-buffer)
 					(regexp-quote heading)))
 			    (target
 			     (if (not org-refile-use-outline-path) heading
-			       (mapconcat
-				#'org-protect-slash
-				(append
+			       (string-join
+				(cons
 				 (pcase org-refile-use-outline-path
-				   (`file (list (file-name-nondirectory
-						 (buffer-file-name
-						  (buffer-base-buffer)))))
-				   (`full-file-path
-				    (list (buffer-file-name
-					   (buffer-base-buffer))))
-				   (_ nil))
-				 (org-get-outline-path t t))
+				   (`file (file-name-nondirectory
+					   (buffer-file-name
+					    (buffer-base-buffer))))
+				   (`full-file-path (buffer-file-name
+						     (buffer-base-buffer)))
+				   (_ ""))
+				 (mapcar #'org-protect-slash
+					 (org-get-outline-path t t)))
 				"/"))))
 			(push (list target f re (org-refile-marker (point)))
 			      tgs)))
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 2/2] org-refile: Optionally prefix refile targets with buffer name
  2017-05-06  5:51       ` [PATCH 1/2] org-refile: Escape " Sebastian Reuße
@ 2017-05-06  5:51         ` Sebastian Reuße
  2017-05-06  6:34           ` [PATCH 1/2] org-refile: Escape slashes only in headline of refile target Sebastian Reuße
  0 siblings, 1 reply; 20+ messages in thread
From: Sebastian Reuße @ 2017-05-06  5:51 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Sebastian Reuße

* 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

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 1/2] org-refile: Escape slashes only in headline of refile target
  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           ` Sebastian Reuße
  2017-05-06  6:34             ` [PATCH 2/2] org-refile: Optionally prefix refile targets with buffer name Sebastian Reuße
  0 siblings, 1 reply; 20+ messages in thread
From: Sebastian Reuße @ 2017-05-06  6:34 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Sebastian Reuße

* org.el (org-refile-get-targets): Only escape slashes in headline
part of refile target; leave any file-system path component (when
enabled) unescaped.

The reason to escape slashes in refile targets is to make it clear
when a slash was part of a headline vs. part of the outline path.  It
makes sense to treat slashes in the file system part the same way as
outline paths, since this won’t result in any confusion and serves to
make target selection less noisy.
---
 lisp/org.el | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 0d83b4cbd..5d8166c99 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -11576,7 +11576,7 @@ (defun org-refile-get-targets (&optional default-buffer)
 			    (target
 			     (if (not org-refile-use-outline-path) heading
 			       (mapconcat
-				#'org-protect-slash
+				#'identity
 				(append
 				 (pcase org-refile-use-outline-path
 				   (`file (list (file-name-nondirectory
@@ -11586,7 +11586,8 @@ (defun org-refile-get-targets (&optional default-buffer)
 				    (list (buffer-file-name
 					   (buffer-base-buffer))))
 				   (_ nil))
-				 (org-get-outline-path t t))
+				 (mapcar #'org-protect-slash
+					 (org-get-outline-path t t)))
 				"/"))))
 			(push (list target f re (org-refile-marker (point)))
 			      tgs)))
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 2/2] org-refile: Optionally prefix refile targets with buffer name
  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             ` Sebastian Reuße
  2017-05-06  6:38               ` [PATCH 1/2] org-refile: Escape slashes only in headline of refile target Sebastian Reuße
  0 siblings, 1 reply; 20+ messages in thread
From: Sebastian Reuße @ 2017-05-06  6:34 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Sebastian Reuße

* 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

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 1/2] org-refile: Escape slashes only in headline of refile target
  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               ` Sebastian Reuße
  2017-05-06  6:38                 ` [PATCH 2/2] org-refile: Optionally prefix refile targets with buffer name Sebastian Reuße
  0 siblings, 1 reply; 20+ messages in thread
From: Sebastian Reuße @ 2017-05-06  6:38 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Sebastian Reuße

* org.el (org-refile-get-targets): Only escape slashes in headline
part of refile target; leave any file-system path component (when
enabled) unescaped.

The reason to escape slashes in refile targets is to make it clear
when a slash was part of a headline vs. part of the outline path.  It
makes sense to treat slashes in the file system part the same way as
outline paths, since this won’t result in any confusion and serves to
make target selection less noisy.
---
 lisp/org.el | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 0d83b4cbd..5d8166c99 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -11576,7 +11576,7 @@ (defun org-refile-get-targets (&optional default-buffer)
 			    (target
 			     (if (not org-refile-use-outline-path) heading
 			       (mapconcat
-				#'org-protect-slash
+				#'identity
 				(append
 				 (pcase org-refile-use-outline-path
 				   (`file (list (file-name-nondirectory
@@ -11586,7 +11586,8 @@ (defun org-refile-get-targets (&optional default-buffer)
 				    (list (buffer-file-name
 					   (buffer-base-buffer))))
 				   (_ nil))
-				 (org-get-outline-path t t))
+				 (mapcar #'org-protect-slash
+					 (org-get-outline-path t t)))
 				"/"))))
 			(push (list target f re (org-refile-marker (point)))
 			      tgs)))
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 2/2] org-refile: Optionally prefix refile targets with buffer name
  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                 ` Sebastian Reuße
  0 siblings, 0 replies; 20+ messages in thread
From: Sebastian Reuße @ 2017-05-06  6:38 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Sebastian Reuße

* 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 | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 5d8166c99..0e41edb44 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 `buffer-name', 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" buffer-name)))
 
 (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 'buffer-name)
+		 (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,9 @@ (defun org-refile-get-targets (&optional default-buffer)
 				   (`full-file-path
 				    (list (buffer-file-name
 					   (buffer-base-buffer))))
+				   (`buffer-name
+				    (list (buffer-name
+					   (buffer-base-buffer))))
 				   (_ nil))
 				 (mapcar #'org-protect-slash
 					 (org-get-outline-path t t)))
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [PATCH 1/2] org-refile: escape slashes only in headline of refile target
  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  6:41       ` Sebastian Reuße
  2017-05-06 16:07         ` Kyle Meyer
  2017-05-06  6:44       ` [PATCH 1/2] org-refile: escape slashes only in headline of refile target Sebastian Reuße
  2 siblings, 1 reply; 20+ messages in thread
From: Sebastian Reuße @ 2017-05-06  6:41 UTC (permalink / raw)
  To: Kyle Meyer; +Cc: emacs-orgmode


Kyle Meyer <kyle@kyleam.com> writes:

> Org's master branch currently supports Emacs >= 24.3, but string-join
> was added in the 24.5 release.

> I'm fine with the append -> cons conversion, but avoiding it would
> make for a cleaner diff that's more focused on the main purpose of
> this patch.

Thank you, Kyle. I’ve incorporated your suggestions (after pulling the
git send-mail trigger early a few times).

Kind regards,
Sebastian

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 1/2] org-refile: escape slashes only in headline of refile target
  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  6:41       ` [PATCH 1/2] org-refile: escape slashes only in headline of refile target Sebastian Reuße
@ 2017-05-06  6:44       ` Sebastian Reuße
  2017-05-06 16:08         ` Kyle Meyer
  2 siblings, 1 reply; 20+ messages in thread
From: Sebastian Reuße @ 2017-05-06  6:44 UTC (permalink / raw)
  To: Kyle Meyer; +Cc: emacs-orgmode


Kyle Meyer <kyle@kyleam.com> writes:

> Based on the Org contributor page [*], it doesn't look like you've
> signed papers with the FSF, so the commit message should label this as
> a "TINYCHANGE". (I think this and the next patch would be small enough
> to mark as tiny changes.)

I have a copyright assignment with FSF; the reason I’m not on the org
contributors page is that I haven’t submitted a patch before.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 1/2] org-refile: escape slashes only in headline of refile target
  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
  0 siblings, 1 reply; 20+ messages in thread
From: Kyle Meyer @ 2017-05-06 16:07 UTC (permalink / raw)
  To: Sebastian Reuße; +Cc: emacs-orgmode

Sebastian Reuße <seb@wirrsal.net> writes:

> Thank you, Kyle. I’ve incorporated your suggestions (after pulling the
> git send-mail trigger early a few times).

Thanks.  Applied to the master branch.  Could you send a patch that
mentions the org-refile-use-outline-path change in ORG-NEWS?

-- 
Kyle

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 1/2] org-refile: escape slashes only in headline of refile target
  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
  0 siblings, 0 replies; 20+ messages in thread
From: Kyle Meyer @ 2017-05-06 16:08 UTC (permalink / raw)
  To: Sebastian Reuße; +Cc: emacs-orgmode

Sebastian Reuße <seb@wirrsal.net> writes:

> I have a copyright assignment with FSF; the reason I’m not on the org
> contributors page is that I haven’t submitted a patch before.

Great, I'll add you to that page.

-- 
Kyle

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH] ORG-NEWS: Update new features
  2017-05-06 16:07         ` Kyle Meyer
@ 2017-05-06 19:04           ` Sebastian Reuße
  2017-05-06 20:19             ` Kyle Meyer
  0 siblings, 1 reply; 20+ messages in thread
From: Sebastian Reuße @ 2017-05-06 19:04 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Sebastian Reuße

---
 etc/ORG-NEWS | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index b16b73ae1..2c00f767a 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -219,6 +219,11 @@ This allow to use a different title than entry title.
 Using ~C-c C-a u~ prompts for a URL pointing to a file to be attached
 to the document.
 
+*** New option for ~org-refile-use-outline-path~
+~org-refile-use-outline-path~ now supports the setting ~buffer-name~,
+which causes refile targets to be prefixed with the buffer’s
+name. This is particularly useful when used in conjunction with
+~uniquify.el~.
 ** Removed functions
 
 *** Org Timeline
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [PATCH] ORG-NEWS: Update new features
  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
  0 siblings, 1 reply; 20+ messages in thread
From: Kyle Meyer @ 2017-05-06 20:19 UTC (permalink / raw)
  To: Sebastian Reuße; +Cc: emacs-orgmode

Sebastian Reuße <seb@wirrsal.net> writes:

> ---
>  etc/ORG-NEWS | 5 +++++
>  1 file changed, 5 insertions(+)

Thanks.  Applied.

-- 
Kyle

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] ORG-NEWS: Update new features
  2017-05-06 20:19             ` Kyle Meyer
@ 2017-05-07 10:04               ` Nicolas Goaziou
  0 siblings, 0 replies; 20+ messages in thread
From: Nicolas Goaziou @ 2017-05-07 10:04 UTC (permalink / raw)
  To: Kyle Meyer; +Cc: emacs-orgmode, Sebastian Reuße

Hello,

Kyle Meyer <kyle@kyleam.com> writes:

> Sebastian Reuße <seb@wirrsal.net> writes:
>
>> ---
>>  etc/ORG-NEWS | 5 +++++
>>  1 file changed, 5 insertions(+)
>
> Thanks.  Applied.

BTW, would you mind adding some tests about it in "test-org.el"? Or, at
least, provide some simple test cases we can turn into proper tests?

Thank you.

Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2017-05-07 10:04 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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     ` [PATCH 2/2] org-refile: optionally prefix refile targets with buffer name Sebastian Reuße
2017-05-03 20:33       ` 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

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).