emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Phil Hudson <phil.hudson@iname.com>
To: emacs-orgmode@gnu.org
Subject: [PATCH] org-capture.el: Support all capture template target-file variants in Customize
Date: Mon, 16 May 2016 09:34:30 +0100	[thread overview]
Message-ID: <87vb2e2yg9.fsf@quiz.hudson-it.ddns.net> (raw)

From ef813011fbe2fd47e5bdd623a6cff0878074de0c Mon Sep 17 00:00:00 2001
From: Phil Hudson <phil.hudson@iname.com>
Date: Mon, 16 May 2016 09:32:06 +0100
Subject: [PATCH] org-capture.el: Support all capture template target-file
 variants in Customize

* lisp/org-capture.el (`org-capture-templates'): Adjust the
  `org-capture-templates' defcustom template to support specifying the capture
  target file using either a literal pathname, a function, a variable or a
  form, as documented.  Previously the Customize UI supported specifying only a
  literal pathname.
  (org-capture-templates): Clarify the documentation for the 'function' method
  for setting up the capture target.

* doc/org.texi (Template elements): Clarify the 'function' method for setting up
  the capture target.
---
 doc/org.texi        |  4 ++--
 lisp/org-capture.el | 31 ++++++++++++++++++-------------
 2 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/doc/org.texi b/doc/org.texi
index 17b01c2..0bfee39 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -7206,8 +7206,8 @@ A function to find the right location in the file.
 File to the entry that is currently being clocked.
 
 @item (function function-finding-location)
-Most general way, write your own function to find both
-file and location.
+Most general way: write your own function which both visits
+the file and moves point to the right location.
 @end table
 
 @item template
diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index 34a6817..2b0cb0c 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -166,8 +166,8 @@ target       Specification of where the captured item should be placed.
                 File to the entry that is currently being clocked
 
              (function function-finding-location)
-                Most general way, write your own function to find both
-                file and location
+                Most general way: write your own function which both visits
+                the file and moves point to the right location
 
 template     The template for creating the capture item.  If you leave this
              empty, an appropriate default template will be used.  See below
@@ -299,7 +299,12 @@ you can escape ambiguous cases with a backward slash, e.g., \\%i."
   :group 'org-capture
   :version "24.1"
   :type
-  '(repeat
+  (let ((file-variants '(choice :tag "  Filename"
+				(file :tag "  Literal")
+				(function :tag "  Function")
+				(variable :tag "  Variable")
+				(sexp :tag "  Form"))))
+  `(repeat
     (choice :value ("" "" entry (file "~/org/notes.org") "")
 	    (list :tag "Multikey description"
 		  (string :tag "Keys       ")
@@ -316,38 +321,38 @@ you can escape ambiguous cases with a backward slash, e.g., \\%i."
 		  (choice :tag "Target location"
 			  (list :tag "File"
 				(const :format "" file)
-				(file :tag "  File"))
+				,file-variants)
 			  (list :tag "ID"
 				(const :format "" id)
 				(string :tag "  ID"))
 			  (list :tag "File & Headline"
 				(const :format "" file+headline)
-				(file   :tag "  File    ")
+				,file-variants
 				(string :tag "  Headline"))
 			  (list :tag "File & Outline path"
 				(const :format "" file+olp)
-				(file   :tag "  File    ")
+				,file-variants
 				(repeat :tag "Outline path" :inline t
 					(string :tag "Headline")))
 			  (list :tag "File & Regexp"
 				(const :format "" file+regexp)
-				(file   :tag "  File  ")
+				,file-variants
 				(regexp :tag "  Regexp"))
 			  (list :tag "File & Date tree"
 				(const :format "" file+datetree)
-				(file :tag "  File"))
+				,file-variants)
 			  (list :tag "File & Date tree, prompt for date"
 				(const :format "" file+datetree+prompt)
-				(file :tag "  File"))
+				,file-variants)
 			  (list :tag "File & Week tree"
 				(const :format "" file+weektree)
-				(file :tag "  File"))
+				,file-variants)
 			  (list :tag "File & Week tree, prompt for date"
 				(const :format "" file+weektree+prompt)
-				(file :tag "  File"))
+				,file-variants)
 			  (list :tag "File & function"
 				(const :format "" file+function)
-				(file :tag "  File    ")
+				,file-variants
 				(sexp :tag "  Function"))
 			  (list :tag "Current clocking task"
 				(const :format "" clock))
@@ -375,7 +380,7 @@ you can escape ambiguous cases with a backward slash, e.g., \\%i."
 				   ((const :format "%v " :clock-resume) (const t))
 				   ((const :format "%v " :unnarrowed) (const t))
 				   ((const :format "%v " :table-line-pos) (const t))
-				   ((const :format "%v " :kill-buffer) (const t))))))))
+				   ((const :format "%v " :kill-buffer) (const t)))))))))
 
 (defcustom org-capture-before-finalize-hook nil
   "Hook that is run right before a capture process is finalized.
-- 
2.8.0.rc3


-- 
Phil Hudson                   http://hudson-it.ddns.net
@UWascalWabbit                 PGP/GnuPG ID: 0x887DCA63

             reply	other threads:[~2016-05-16  8:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-16  8:34 Phil Hudson [this message]
2016-05-16  9:24 ` [PATCH] org-capture.el: Support all capture template target-file variants in Customize Nicolas Goaziou

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=87vb2e2yg9.fsf@quiz.hudson-it.ddns.net \
    --to=phil.hudson@iname.com \
    --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).