emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Use and show default refiling location.
@ 2011-03-02 13:46 Tassilo Horn
  2011-03-05 11:47 ` [Accepted] [O] " Bastien Guerry
  2011-03-05 11:48 ` [PATCH] " Bastien
  0 siblings, 2 replies; 5+ messages in thread
From: Tassilo Horn @ 2011-03-02 13:46 UTC (permalink / raw)
  To: emacs-orgmode

	* org.el (org-refile-get-location): Set and show default
	value.
	(org-goto, org-refile): Adapt calls.

	* org-id.el (org-id-get-with-outline-path-completion): Adapt
	call.

	* org-agenda.el (org-agenda-refile, org-agenda-bulk-action):
	Adapt calls.

	* org-remember.el (org-remember-handler): Adapt call.
---
This patch that implements the usage (and indication) of a default
refiling location for `org-refile'.  The default is the first value of
`org-refile-history'.  Although that value was already easily accessible
from the history with M-n, an explicit default is convenient when
refiling several (non-consecutive, so you cannot refile using a region)
entries.  That happened to me just now after importing a dozen of
contacts from Gnus into my contacts.org (using org-contacts.el),
followed by refiling them in several category headlines.

 lisp/org-agenda.el   |    4 ++--
 lisp/org-id.el       |    2 +-
 lisp/org-remember.el |    2 +-
 lisp/org.el          |   17 ++++++++++++-----
 4 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index ea822da..9a818ce 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -6718,7 +6718,7 @@ If this information is not given, the function uses the tree at point."
 	   (pos (marker-position marker))
 	   (rfloc (or rfloc
 		      (org-refile-get-location
-		       (if goto "Goto: " "Refile to: ") buffer
+		       (if goto "Goto" "Refile to") buffer
 		       org-refile-allow-creating-parent-nodes))))
       (with-current-buffer buffer
 	(save-excursion
@@ -7984,7 +7984,7 @@ The prefix arg is passed through to the command if possible."
 
      ((member action '(?r ?w))
       (setq rfloc (org-refile-get-location
-		   "Refile to: "
+		   "Refile to"
 		   (marker-buffer (car org-agenda-bulk-marked-entries))
 		   org-refile-allow-creating-parent-nodes))
       (if (nth 3 rfloc)
diff --git a/lisp/org-id.el b/lisp/org-id.el
index a8004af..a70dd15 100644
--- a/lisp/org-id.el
+++ b/lisp/org-id.el
@@ -231,7 +231,7 @@ It returns the ID of the entry.  If necessary, the ID is created."
 	 (org-refile-use-outline-path
 	  (if (caar org-refile-targets) 'file t))
 	 (org-refile-target-verify-function nil)
-	 (spos (org-refile-get-location "Entry: "))
+	 (spos (org-refile-get-location "Entry"))
 	 (pom (and spos (move-marker (make-marker) (nth 3 spos)
 				     (get-file-buffer (nth 1 spos))))))
     (prog1 (org-id-get pom 'create)
diff --git a/lisp/org-remember.el b/lisp/org-remember.el
index c6e21ae..3be7b86 100644
--- a/lisp/org-remember.el
+++ b/lisp/org-remember.el
@@ -1004,7 +1004,7 @@ See also the variable `org-reverse-note-order'."
 	     ((eq org-remember-interactive-interface 'outline-path-completion)
 	      (let ((org-refile-targets '((nil . (:maxlevel . 10))))
 		    (org-refile-use-outline-path t))
-		(setq spos (org-refile-get-location "Heading: ")
+		(setq spos (org-refile-get-location "Heading")
 		      exitcmd 'return
 		      spos (nth 3 spos))))
 	     (t (error "This should not happen")))
diff --git a/lisp/org.el b/lisp/org.el
index a26a3ca..51240c3 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -6544,7 +6544,7 @@ the headline hierarchy above."
 	 (selected-point
 	  (if (eq interface 'outline)
 	      (car (org-get-location (current-buffer) org-goto-help))
-	    (let ((pa (org-refile-get-location "Goto: ")))
+	    (let ((pa (org-refile-get-location "Goto")))
 	      (org-refile-check-position pa)
 	      (nth 3 pa)))))
     (if selected-point
@@ -10290,7 +10290,7 @@ This can be done with a 0 prefix: `C-0 C-c C-w'"
 	       (setq it (or rfloc
 			    (save-excursion
 			      (org-refile-get-location
-			       (if goto "Goto: " "Refile to: ") default-buffer
+			       (if goto "Goto" "Refile to") default-buffer
 			       org-refile-allow-creating-parent-nodes)))))
 	  (setq file (nth 1 it)
 		re (nth 2 it)
@@ -10371,13 +10371,20 @@ This can be done with a 0 prefix: `C-0 C-c C-w'"
   (message "This is the location of the last refile"))
 
 (defun org-refile-get-location (&optional prompt default-buffer new-nodes)
-  "Prompt the user for a refile location, using PROMPT."
+  "Prompt the user for a refile location, using PROMPT.
+PROMPT should not be prefixed with a colon and a space, because
+this function prepends the default value from
+`org-refile-history' automatically, if that is not empty."
   (let ((org-refile-targets org-refile-targets)
 	(org-refile-use-outline-path org-refile-use-outline-path))
     (setq org-refile-target-table (org-get-refile-targets default-buffer)))
   (unless org-refile-target-table
     (error "No refile targets"))
-  (let* ((cbuf (current-buffer))
+  (let* ((prompt (concat prompt
+			 (and (car org-refile-history)
+			      (concat " (default " (car org-refile-history) ")"))
+			 ": "))
+	 (cbuf (current-buffer))
 	 (partial-completion-mode nil)
 	 (cfn (buffer-file-name (buffer-base-buffer cbuf)))
 	 (cfunc (if (and org-refile-use-outline-path
@@ -10400,7 +10407,7 @@ This can be done with a 0 prefix: `C-0 C-c C-w'"
 	 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))
+			nil 'org-refile-history (car org-refile-history)))
     (setq pa (or (assoc answ tbl) (assoc (concat answ "/") tbl)))
     (org-refile-check-position pa)
     (if pa
-- 
1.7.4.1

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

* [Accepted] [O] Use and show default refiling location.
  2011-03-02 13:46 [PATCH] Use and show default refiling location Tassilo Horn
@ 2011-03-05 11:47 ` Bastien Guerry
  2011-03-05 11:48 ` [PATCH] " Bastien
  1 sibling, 0 replies; 5+ messages in thread
From: Bastien Guerry @ 2011-03-05 11:47 UTC (permalink / raw)
  To: emacs-orgmode

Patch 642 (http://patchwork.newartisans.com/patch/642/) is now "Accepted".

Maintainer comment: none

This relates to the following submission:

http://mid.gmane.org/%3C87wrkh4oua.fsf%40member.fsf.org%3E

Here is the original message containing the patch:

> Content-Type: text/plain; charset="utf-8"
> MIME-Version: 1.0
> Content-Transfer-Encoding: 7bit
> Subject: [O] Use and show default refiling location.
> Date: Wed, 02 Mar 2011 18:46:37 -0000
> From: Tassilo Horn <tassilo@member.fsf.org>
> X-Patchwork-Id: 642
> Message-Id: <87wrkh4oua.fsf@member.fsf.org>
> To: emacs-orgmode@gnu.org
> 
> * org.el (org-refile-get-location): Set and show default
> 	value.
> 	(org-goto, org-refile): Adapt calls.
> 
> 	* org-id.el (org-id-get-with-outline-path-completion): Adapt
> 	call.
> 
> 	* org-agenda.el (org-agenda-refile, org-agenda-bulk-action):
> 	Adapt calls.
> 
> 	* org-remember.el (org-remember-handler): Adapt call.
> 
> ---
> This patch that implements the usage (and indication) of a default
> refiling location for `org-refile'.  The default is the first value of
> `org-refile-history'.  Although that value was already easily accessible
> from the history with M-n, an explicit default is convenient when
> refiling several (non-consecutive, so you cannot refile using a region)
> entries.  That happened to me just now after importing a dozen of
> contacts from Gnus into my contacts.org (using org-contacts.el),
> followed by refiling them in several category headlines.
> 
>  lisp/org-agenda.el   |    4 ++--
>  lisp/org-id.el       |    2 +-
>  lisp/org-remember.el |    2 +-
>  lisp/org.el          |   17 ++++++++++++-----
>  4 files changed, 16 insertions(+), 9 deletions(-)
> 
> diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
> index ea822da..9a818ce 100644
> --- a/lisp/org-agenda.el
> +++ b/lisp/org-agenda.el
> @@ -6718,7 +6718,7 @@ If this information is not given, the function uses the tree at point."
>  	   (pos (marker-position marker))
>  	   (rfloc (or rfloc
>  		      (org-refile-get-location
> -		       (if goto "Goto: " "Refile to: ") buffer
> +		       (if goto "Goto" "Refile to") buffer
>  		       org-refile-allow-creating-parent-nodes))))
>        (with-current-buffer buffer
>  	(save-excursion
> @@ -7984,7 +7984,7 @@ The prefix arg is passed through to the command if possible."
>  
>       ((member action '(?r ?w))
>        (setq rfloc (org-refile-get-location
> -		   "Refile to: "
> +		   "Refile to"
>  		   (marker-buffer (car org-agenda-bulk-marked-entries))
>  		   org-refile-allow-creating-parent-nodes))
>        (if (nth 3 rfloc)
> diff --git a/lisp/org-id.el b/lisp/org-id.el
> index a8004af..a70dd15 100644
> --- a/lisp/org-id.el
> +++ b/lisp/org-id.el
> @@ -231,7 +231,7 @@ It returns the ID of the entry.  If necessary, the ID is created."
>  	 (org-refile-use-outline-path
>  	  (if (caar org-refile-targets) 'file t))
>  	 (org-refile-target-verify-function nil)
> -	 (spos (org-refile-get-location "Entry: "))
> +	 (spos (org-refile-get-location "Entry"))
>  	 (pom (and spos (move-marker (make-marker) (nth 3 spos)
>  				     (get-file-buffer (nth 1 spos))))))
>      (prog1 (org-id-get pom 'create)
> diff --git a/lisp/org-remember.el b/lisp/org-remember.el
> index c6e21ae..3be7b86 100644
> --- a/lisp/org-remember.el
> +++ b/lisp/org-remember.el
> @@ -1004,7 +1004,7 @@ See also the variable `org-reverse-note-order'."
>  	     ((eq org-remember-interactive-interface 'outline-path-completion)
>  	      (let ((org-refile-targets '((nil . (:maxlevel . 10))))
>  		    (org-refile-use-outline-path t))
> -		(setq spos (org-refile-get-location "Heading: ")
> +		(setq spos (org-refile-get-location "Heading")
>  		      exitcmd 'return
>  		      spos (nth 3 spos))))
>  	     (t (error "This should not happen")))
> diff --git a/lisp/org.el b/lisp/org.el
> index a26a3ca..51240c3 100644
> --- a/lisp/org.el
> +++ b/lisp/org.el
> @@ -6544,7 +6544,7 @@ the headline hierarchy above."
>  	 (selected-point
>  	  (if (eq interface 'outline)
>  	      (car (org-get-location (current-buffer) org-goto-help))
> -	    (let ((pa (org-refile-get-location "Goto: ")))
> +	    (let ((pa (org-refile-get-location "Goto")))
>  	      (org-refile-check-position pa)
>  	      (nth 3 pa)))))
>      (if selected-point
> @@ -10290,7 +10290,7 @@ This can be done with a 0 prefix: `C-0 C-c C-w'"
>  	       (setq it (or rfloc
>  			    (save-excursion
>  			      (org-refile-get-location
> -			       (if goto "Goto: " "Refile to: ") default-buffer
> +			       (if goto "Goto" "Refile to") default-buffer
>  			       org-refile-allow-creating-parent-nodes)))))
>  	  (setq file (nth 1 it)
>  		re (nth 2 it)
> @@ -10371,13 +10371,20 @@ This can be done with a 0 prefix: `C-0 C-c C-w'"
>    (message "This is the location of the last refile"))
>  
>  (defun org-refile-get-location (&optional prompt default-buffer new-nodes)
> -  "Prompt the user for a refile location, using PROMPT."
> +  "Prompt the user for a refile location, using PROMPT.
> +PROMPT should not be prefixed with a colon and a space, because
> +this function prepends the default value from
> +`org-refile-history' automatically, if that is not empty."
>    (let ((org-refile-targets org-refile-targets)
>  	(org-refile-use-outline-path org-refile-use-outline-path))
>      (setq org-refile-target-table (org-get-refile-targets default-buffer)))
>    (unless org-refile-target-table
>      (error "No refile targets"))
> -  (let* ((cbuf (current-buffer))
> +  (let* ((prompt (concat prompt
> +			 (and (car org-refile-history)
> +			      (concat " (default " (car org-refile-history) ")"))
> +			 ": "))
> +	 (cbuf (current-buffer))
>  	 (partial-completion-mode nil)
>  	 (cfn (buffer-file-name (buffer-base-buffer cbuf)))
>  	 (cfunc (if (and org-refile-use-outline-path
> @@ -10400,7 +10407,7 @@ This can be done with a 0 prefix: `C-0 C-c C-w'"
>  	 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))
> +			nil 'org-refile-history (car org-refile-history)))
>      (setq pa (or (assoc answ tbl) (assoc (concat answ "/") tbl)))
>      (org-refile-check-position pa)
>      (if pa
> 

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

* Re: [PATCH] Use and show default refiling location.
  2011-03-02 13:46 [PATCH] Use and show default refiling location Tassilo Horn
  2011-03-05 11:47 ` [Accepted] [O] " Bastien Guerry
@ 2011-03-05 11:48 ` Bastien
  2011-03-05 20:35   ` Tassilo Horn
  1 sibling, 1 reply; 5+ messages in thread
From: Bastien @ 2011-03-05 11:48 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: emacs-orgmode

Hi Tassilo,

I've applied your patch.  Thanks for this neat addition!

-- 
 Bastien

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

* Re: [PATCH] Use and show default refiling location.
  2011-03-05 11:48 ` [PATCH] " Bastien
@ 2011-03-05 20:35   ` Tassilo Horn
  2011-03-05 21:53     ` Bastien
  0 siblings, 1 reply; 5+ messages in thread
From: Tassilo Horn @ 2011-03-05 20:35 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode

Bastien <bzg@altern.org> writes:

Hi Bastien,

> I've applied your patch.

Great!

> Thanks for this neat addition!

You're welcome.  BTW, I just noticed that I made a wording error in the
docstring of `org-refile-get-location':

  Prompt the user for a refile location, using PROMPT.
  PROMPT should not be prefixed with a colon and a space, because
                       ^^^^^^^^
  this function prepends the default value from
                ^^^^^^^^
  `org-refile-history' automatically, if that is not empty.

Of course, that has to be "suffixed" and "appends".

Bye,
Tassilo

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

* Re: [PATCH] Use and show default refiling location.
  2011-03-05 20:35   ` Tassilo Horn
@ 2011-03-05 21:53     ` Bastien
  0 siblings, 0 replies; 5+ messages in thread
From: Bastien @ 2011-03-05 21:53 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: emacs-orgmode

Hi Tassilo,

Tassilo Horn <tassilo@member.fsf.org> writes:

>> Thanks for this neat addition!
>
> You're welcome.  BTW, I just noticed that I made a wording error in the
> docstring of `org-refile-get-location':
>
>   Prompt the user for a refile location, using PROMPT.
>   PROMPT should not be prefixed with a colon and a space, because
>                        ^^^^^^^^
>   this function prepends the default value from
>                 ^^^^^^^^
>   `org-refile-history' automatically, if that is not empty.
>
> Of course, that has to be "suffixed" and "appends".

Fixed, thanks!

-- 
 Bastien

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

end of thread, other threads:[~2011-03-05 21:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-02 13:46 [PATCH] Use and show default refiling location Tassilo Horn
2011-03-05 11:47 ` [Accepted] [O] " Bastien Guerry
2011-03-05 11:48 ` [PATCH] " Bastien
2011-03-05 20:35   ` Tassilo Horn
2011-03-05 21:53     ` Bastien

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