emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH 2/2] org-capture.el: Support all target file specifiction variants in Customize
@ 2016-05-11 22:13 Phil Hudson
  2016-05-13 16:11 ` Nicolas Goaziou
  0 siblings, 1 reply; 2+ messages in thread
From: Phil Hudson @ 2016-05-11 22:13 UTC (permalink / raw)
  To: emacs-orgmode

From 9ca987e6580ef633c961bf2023813d8544a0d36b Mon Sep 17 00:00:00 2001
From: Phil Hudson <phil.hudson@iname.com>
Date: Wed, 11 May 2016 22:49:01 +0100
Subject: [PATCH 2/2] org-capture.el: Support all target file specifiction
 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): Copy the clarification regarding 'function'
  from org-capture.el above to the relevant section in the manual.
---
 doc/org.texi        |  4 ++--
 lisp/org-capture.el | 58 +++++++++++++++++++++++++++++++++++++++++++----------
 2 files changed, 49 insertions(+), 13 deletions(-)

diff --git a/doc/org.texi b/doc/org.texi
index 17b01c2..7a76744 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 sets point at the right location.
 @end table
 
 @item template
diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index 34a6817..9842b13 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 sets point at 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
@@ -316,38 +316,74 @@ 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"))
+				(choice :tag "  Filename"
+					(file :tag "  Literal")
+					(function :tag "  Function")
+					(variable :tag "  Variable")
+					(sexp :tag "  Form")))
 			  (list :tag "ID"
 				(const :format "" id)
 				(string :tag "  ID"))
 			  (list :tag "File & Headline"
 				(const :format "" file+headline)
-				(file   :tag "  File    ")
+				(choice :tag "  Filename"
+					(file :tag "  Literal")
+					(function :tag "  Function")
+					(variable :tag "  Variable")
+					(sexp :tag "  Form"))
 				(string :tag "  Headline"))
 			  (list :tag "File & Outline path"
 				(const :format "" file+olp)
-				(file   :tag "  File    ")
+				(choice :tag "  Filename"
+					(file :tag "  Literal")
+					(function :tag "  Function")
+					(variable :tag "  Variable")
+					(sexp :tag "  Form"))
 				(repeat :tag "Outline path" :inline t
 					(string :tag "Headline")))
 			  (list :tag "File & Regexp"
 				(const :format "" file+regexp)
-				(file   :tag "  File  ")
+				(choice :tag "  Filename"
+					(file :tag "  Literal")
+					(function :tag "  Function")
+					(variable :tag "  Variable")
+					(sexp :tag "  Form"))
 				(regexp :tag "  Regexp"))
 			  (list :tag "File & Date tree"
 				(const :format "" file+datetree)
-				(file :tag "  File"))
+				(choice :tag "  Filename"
+					(file :tag "  Literal")
+					(function :tag "  Function")
+					(variable :tag "  Variable")
+					(sexp :tag "  Form")))
 			  (list :tag "File & Date tree, prompt for date"
 				(const :format "" file+datetree+prompt)
-				(file :tag "  File"))
+				(choice :tag "  Filename"
+					(file :tag "  Literal")
+					(function :tag "  Function")
+					(variable :tag "  Variable")
+					(sexp :tag "  Form")))
 			  (list :tag "File & Week tree"
 				(const :format "" file+weektree)
-				(file :tag "  File"))
+				(choice :tag "  Filename"
+					(file :tag "  Literal")
+					(function :tag "  Function")
+					(variable :tag "  Variable")
+					(sexp :tag "  Form")))
 			  (list :tag "File & Week tree, prompt for date"
 				(const :format "" file+weektree+prompt)
-				(file :tag "  File"))
+				(choice :tag "  Filename"
+					(file :tag "  Literal")
+					(function :tag "  Function")
+					(variable :tag "  Variable")
+					(sexp :tag "  Form")))
 			  (list :tag "File & function"
 				(const :format "" file+function)
-				(file :tag "  File    ")
+				(choice :tag "  Filename"
+					(file :tag "  Literal")
+					(function :tag "  Function")
+					(variable :tag "  Variable")
+					(sexp :tag "  Form"))
 				(sexp :tag "  Function"))
 			  (list :tag "Current clocking task"
 				(const :format "" clock))
-- 
2.8.0.rc3


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

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

* Re: [PATCH 2/2] org-capture.el: Support all target file specifiction variants in Customize
  2016-05-11 22:13 [PATCH 2/2] org-capture.el: Support all target file specifiction variants in Customize Phil Hudson
@ 2016-05-13 16:11 ` Nicolas Goaziou
  0 siblings, 0 replies; 2+ messages in thread
From: Nicolas Goaziou @ 2016-05-13 16:11 UTC (permalink / raw)
  To: Phil Hudson; +Cc: emacs-orgmode

Hello,

Phil Hudson <phil.hudson@iname.com> writes:

> From 9ca987e6580ef633c961bf2023813d8544a0d36b Mon Sep 17 00:00:00 2001
> From: Phil Hudson <phil.hudson@iname.com>
> Date: Wed, 11 May 2016 22:49:01 +0100
> Subject: [PATCH 2/2] org-capture.el: Support all target file specifiction
>  variants in Customize

I cannot apply this patch. Could you rebase against maint and try
sending it again? Thank you.


>  				(const :format "" file)
> -				(file :tag "  File"))
> +				(choice :tag "  Filename"
> +					(file :tag "  Literal")
> +					(function :tag "  Function")
> +					(variable :tag "  Variable")
> +					(sexp :tag "  Form")))

I think you can remove all most of the redundancy using backquote, e.g.,

  (let ((file-sources '(choice :tag "  Filename"
                               (file :tag "  Literal")
                               (function :tag "  Function")
                               (variable :tag "  Variable")
                               (sexp :tag "  Form"))))
    `(repeat
      ...
      (choice :tag "Target location"
              (const :format "" file)
              ,file-sources)
      ...))


Regards,

-- 
Nicolas Goaziou

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

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

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-11 22:13 [PATCH 2/2] org-capture.el: Support all target file specifiction variants in Customize Phil Hudson
2016-05-13 16:11 ` Nicolas Goaziou

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