emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] org-capture.el: Add new capture template option :refile-to
@ 2021-04-24 22:12 Richard Garner
  2021-05-01 11:15 ` Bastien
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Garner @ 2021-04-24 22:12 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 283 bytes --]


Hi all,

(Resending after messing up the first time.)

The included patch adds a new property :refile-to to org capture
templates, allowing each template to have its own set of refile targets.
I find this really useful in practice and thought others might too.

Richard


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-capture.el-Add-new-capture-template-option-refil.patch --]
[-- Type: text/x-patch, Size: 2593 bytes --]

From 829c1ba4805327645fcb75b35b73ecb3a1700b2f Mon Sep 17 00:00:00 2001
From: Richard Garner <richard.garner@mq.edu.au>
Date: Tue, 13 Apr 2021 13:53:49 +1000
Subject: [PATCH] org-capture.el: Add new capture template option :refile-to

* lisp/org-capture.el (org-capture-refile): bind `org-refile-targets'
to value of local capture template property :refile-to around call to
`org-refile'.

(org-capture-templates): document new capture template property
:refile-to.

TINYCHANGE
---
 lisp/org-capture.el | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index 9fbd00ccd..64ecd5fe1 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -246,6 +246,10 @@ properties are:
 
  :jump-to-captured   When set, jump to the captured entry when finished.
 
+ :refile-to          When exiting capture mode via `org-capture-refile', the
+                     variable `org-refile-targets' will be temporarily bound
+                     to the value of this property.
+
  :empty-lines        Set this to the number of lines that should be inserted
                      before and after the new item.  Default 0, only common
                      other value is 1.
@@ -885,7 +889,8 @@ for `entry'-type templates"))
 	 (pos (make-marker))
 	 (org-capture-is-refiling t)
 	 (kill-buffer (org-capture-get :kill-buffer 'local))
-	 (jump-to-captured (org-capture-get :jump-to-captured 'local)))
+	 (jump-to-captured (org-capture-get :jump-to-captured 'local))
+	 (refile-to (org-capture-get :refile-to 'local)))
     ;; Since `org-capture-finalize' may alter buffer contents (e.g.,
     ;; empty lines) around entry, use a marker to refer to the
     ;; headline to be refiled.  Place the marker in the base buffer,
@@ -895,11 +900,12 @@ for `entry'-type templates"))
     ;; early.  We want to wait for the refiling to be over, so we
     ;; control when the latter function is called.
     (org-capture-put :kill-buffer nil :jump-to-captured nil)
-    (org-capture-finalize)
-    (save-window-excursion
-      (with-current-buffer base
-	(org-with-point-at pos
-	  (call-interactively 'org-refile))))
+    (let ((org-refile-targets (or refile-to org-refile-targets)))
+      (org-capture-finalize)
+      (save-window-excursion
+        (with-current-buffer base
+	  (org-with-point-at pos
+	    (call-interactively 'org-refile)))))
     (when kill-buffer
       (with-current-buffer base (save-buffer))
       (kill-buffer base))
-- 
2.17.2 (Apple Git-113)


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

* Re: [PATCH] org-capture.el: Add new capture template option :refile-to
  2021-04-24 22:12 [PATCH] org-capture.el: Add new capture template option :refile-to Richard Garner
@ 2021-05-01 11:15 ` Bastien
  0 siblings, 0 replies; 5+ messages in thread
From: Bastien @ 2021-05-01 11:15 UTC (permalink / raw)
  To: Richard Garner; +Cc: emacs-orgmode

Hi Richard,

thanks for this addition!

I think ":refile-targets" is more straightforward.  I applied your
patch with this change and a slightly modified commit message.  Also,
I documented this in the manual and added an entry to etc/ORG-NEWS.

Thanks!

-- 
 Bastien


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

* Re: [PATCH] org-capture.el: Add new capture template option :refile-to
  2021-04-24 22:02 Richard Garner
  2021-04-24 22:10 ` Richard Garner
@ 2021-04-25  3:16 ` Timothy
  1 sibling, 0 replies; 5+ messages in thread
From: Timothy @ 2021-04-25  3:16 UTC (permalink / raw)
  To: emacs-orgmode


Marking this patch as cancelled for updates.orgmode.org.


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

* Re: [PATCH] org-capture.el: Add new capture template option :refile-to
  2021-04-24 22:02 Richard Garner
@ 2021-04-24 22:10 ` Richard Garner
  2021-04-25  3:16 ` Timothy
  1 sibling, 0 replies; 5+ messages in thread
From: Richard Garner @ 2021-04-24 22:10 UTC (permalink / raw)
  To: emacs-orgmode


Sorry, messed up the patch attachment, will resend in a new thread.

Richard


Richard Garner <richard.garner@mq.edu.au> writes:

> Hi all,
>
> The included patch adds a new property :refile-to to org capture
> templates, allowing each template to have its own set of refile targets.
> I find this really useful in practice and thought others might too.
>
> Richard
>
> ---
>
> From 829c1ba4805327645fcb75b35b73ecb3a1700b2f Mon Sep 17 00:00:00 2001
> From: Richard Garner <richard.garner@mq.edu.au>
> Subject: 
>
> * lisp/org-capture.el (org-capture-refile): bind `org-refile-targets'
> to value of local capture template property :refile-to around call to
> `org-refile'.
>
> (org-capture-templates): document new capture template property
> :refile-to.
>
> TINYCHANGE
> ---
>  lisp/org-capture.el | 18 ++++++++++++------
>  1 file changed, 12 insertions(+), 6 deletions(-)
>
> diff --git a/lisp/org-capture.el b/lisp/org-capture.el
> index 9fbd00ccd..64ecd5fe1 100644
> --- a/lisp/org-capture.el
> +++ b/lisp/org-capture.el
> @@ -246,6 +246,10 @@ properties are:
>  
>   :jump-to-captured   When set, jump to the captured entry when finished.
>  
> + :refile-to          When exiting capture mode via `org-capture-refile', the
> +                     variable `org-refile-targets' will be temporarily bound
> +                     to the value of this property.
> +
>   :empty-lines        Set this to the number of lines that should be inserted
>                       before and after the new item.  Default 0, only common
>                       other value is 1.
> @@ -885,7 +889,8 @@ for `entry'-type templates"))
>  	 (pos (make-marker))
>  	 (org-capture-is-refiling t)
>  	 (kill-buffer (org-capture-get :kill-buffer 'local))
> -	 (jump-to-captured (org-capture-get :jump-to-captured 'local)))
> +	 (jump-to-captured (org-capture-get :jump-to-captured 'local))
> +	 (refile-to (org-capture-get :refile-to 'local)))
>      ;; Since `org-capture-finalize' may alter buffer contents (e.g.,
>      ;; empty lines) around entry, use a marker to refer to the
>      ;; headline to be refiled.  Place the marker in the base buffer,
> @@ -895,11 +900,12 @@ for `entry'-type templates"))
>      ;; early.  We want to wait for the refiling to be over, so we
>      ;; control when the latter function is called.
>      (org-capture-put :kill-buffer nil :jump-to-captured nil)
> -    (org-capture-finalize)
> -    (save-window-excursion
> -      (with-current-buffer base
> -	(org-with-point-at pos
> -	  (call-interactively 'org-refile))))
> +    (let ((org-refile-targets (or refile-to org-refile-targets)))
> +      (org-capture-finalize)
> +      (save-window-excursion
> +        (with-current-buffer base
> +	  (org-with-point-at pos
> +	    (call-interactively 'org-refile)))))
>      (when kill-buffer
>        (with-current-buffer base (save-buffer))
>        (kill-buffer base))



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

* [PATCH] org-capture.el: Add new capture template option :refile-to
@ 2021-04-24 22:02 Richard Garner
  2021-04-24 22:10 ` Richard Garner
  2021-04-25  3:16 ` Timothy
  0 siblings, 2 replies; 5+ messages in thread
From: Richard Garner @ 2021-04-24 22:02 UTC (permalink / raw)
  To: emacs-orgmode

Hi all,

The included patch adds a new property :refile-to to org capture
templates, allowing each template to have its own set of refile targets.
I find this really useful in practice and thought others might too.

Richard

---

From 829c1ba4805327645fcb75b35b73ecb3a1700b2f Mon Sep 17 00:00:00 2001
From: Richard Garner <richard.garner@mq.edu.au>
Subject: 

* lisp/org-capture.el (org-capture-refile): bind `org-refile-targets'
to value of local capture template property :refile-to around call to
`org-refile'.

(org-capture-templates): document new capture template property
:refile-to.

TINYCHANGE
---
 lisp/org-capture.el | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index 9fbd00ccd..64ecd5fe1 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -246,6 +246,10 @@ properties are:
 
  :jump-to-captured   When set, jump to the captured entry when finished.
 
+ :refile-to          When exiting capture mode via `org-capture-refile', the
+                     variable `org-refile-targets' will be temporarily bound
+                     to the value of this property.
+
  :empty-lines        Set this to the number of lines that should be inserted
                      before and after the new item.  Default 0, only common
                      other value is 1.
@@ -885,7 +889,8 @@ for `entry'-type templates"))
 	 (pos (make-marker))
 	 (org-capture-is-refiling t)
 	 (kill-buffer (org-capture-get :kill-buffer 'local))
-	 (jump-to-captured (org-capture-get :jump-to-captured 'local)))
+	 (jump-to-captured (org-capture-get :jump-to-captured 'local))
+	 (refile-to (org-capture-get :refile-to 'local)))
     ;; Since `org-capture-finalize' may alter buffer contents (e.g.,
     ;; empty lines) around entry, use a marker to refer to the
     ;; headline to be refiled.  Place the marker in the base buffer,
@@ -895,11 +900,12 @@ for `entry'-type templates"))
     ;; early.  We want to wait for the refiling to be over, so we
     ;; control when the latter function is called.
     (org-capture-put :kill-buffer nil :jump-to-captured nil)
-    (org-capture-finalize)
-    (save-window-excursion
-      (with-current-buffer base
-	(org-with-point-at pos
-	  (call-interactively 'org-refile))))
+    (let ((org-refile-targets (or refile-to org-refile-targets)))
+      (org-capture-finalize)
+      (save-window-excursion
+        (with-current-buffer base
+	  (org-with-point-at pos
+	    (call-interactively 'org-refile)))))
     (when kill-buffer
       (with-current-buffer base (save-buffer))
       (kill-buffer base))
-- 
2.17.2 (Apple Git-113)



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

end of thread, other threads:[~2021-05-01 11:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-24 22:12 [PATCH] org-capture.el: Add new capture template option :refile-to Richard Garner
2021-05-01 11:15 ` Bastien
  -- strict thread matches above, loose matches on Subject: below --
2021-04-24 22:02 Richard Garner
2021-04-24 22:10 ` Richard Garner
2021-04-25  3:16 ` Timothy

Code repositories for project(s) associated with this 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).