summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2016-11-04 17:41:27 +0100
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2016-11-04 17:41:27 +0100
commitf5645675a336d8f56fa9e6bd63832bdbac71f315 (patch)
treeb009747c0a0e5fbd348cdf43e2aa4e6e8e16ae00
parentc81f9fff3b111869acc6880cdd56920280494cfc (diff)
downloadorg-mode-f5645675a336d8f56fa9e6bd63832bdbac71f315.tar.gz
Disallow S-exp in capture templates
* lisp/org-capture.el (org-capture-expand-file): Disallow S-exp. (org-capture-templates): * doc/org.texi (Template elements): Update documentation. A function is equivalent to using S-exp, without tainting code with an yet another call to `eval'.
-rw-r--r--doc/org.texi4
-rw-r--r--etc/ORG-NEWS15
-rw-r--r--lisp/org-capture.el13
3 files changed, 22 insertions, 10 deletions
diff --git a/doc/org.texi b/doc/org.texi
index e8d8a6e..ef653b5 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -7159,8 +7159,8 @@ files, targets usually define a node. Entries will become children of this
node. Other types will be added to the table or list in the body of this
node. Most target specifications contain a file name. If that file name is
the empty string, it defaults to @code{org-default-notes-file}. A file can
-also be given as a variable, function, or Emacs Lisp form. When an absolute
-path is not specified for a target, it is taken as relative to
+also be given as a variable or as a function called with no argument. When
+an absolute path is not specified for a target, it is taken as relative to
@code{org-directory}.
Valid values are:
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index dd332a4..8b2d1f6 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -8,6 +8,21 @@ See the end of the file for license conditions.
Please send Org bug reports to mailto:emacs-orgmode@gnu.org.
+* Version 9.1
+
+** Incompatible changes
+
+*** ~org-capture-templates~ no longer accepts S-expressions as file names
+
+Since functions are allowed there, a straightforward way to migrate
+is to turn, e.g.,
+
+: (file (sexp))
+
+into
+
+: (file (lambda () (sexp)))
+
* Version 9.0
** Incompatible changes
diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index 690d342..5b07b29 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -124,8 +124,8 @@ target Specification of where the captured item should be placed.
Most target specifications contain a file name. If that file
name is the empty string, it defaults to `org-default-notes-file'.
- A file can also be given as a variable, function, or Emacs Lisp
- form. When an absolute path is not specified for a
+ A file can also be given as a variable or as a function called
+ with no argument. When an absolute path is not specified for a
target, it is taken as relative to `org-directory'.
Valid values are:
@@ -1008,16 +1008,13 @@ Store them in the capture property list."
(defun org-capture-expand-file (file)
"Expand functions and symbols for FILE.
-When FILE is a function, call it. When it is a form, evaluate
-it. When it is a variable, retrieve the value. When it is
-a string, return it. However, if it is the empty string, return
-`org-default-notes-file' instead."
+When FILE is a function, call it. When it is a variable,
+retrieve its value. When it is the empty string, return
+`org-default-notes-file'. In any other case, return FILE as-is."
(cond
((equal file "") org-default-notes-file)
- ((org-string-nw-p file) file)
((functionp file) (funcall file))
((and (symbolp file) (boundp file)) (symbol-value file))
- ((consp file) (eval file))
(t file)))
(defun org-capture-target-buffer (file)