summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2016-11-06 08:59:47 +0100
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2016-11-06 08:59:47 +0100
commitbd061b91f3aad74bada102a3851bcf2ef9766b96 (patch)
tree485e4d501b8e6c1be6cf4d21f786cc538b79670d
parentf5645675a336d8f56fa9e6bd63832bdbac71f315 (diff)
parentb89dfaa904d32b645b975ef363d0eb192581408a (diff)
downloadorg-mode-bd061b91f3aad74bada102a3851bcf2ef9766b96.tar.gz
Merge branch 'maint'
-rw-r--r--lisp/org-capture.el33
1 files changed, 19 insertions, 14 deletions
diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index 5b07b29..c5c6eba 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -1007,25 +1007,30 @@ Store them in the capture property list."
:decrypted decrypted-hl-pos))))
(defun org-capture-expand-file (file)
- "Expand functions and symbols for FILE.
-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."
+ "Expand functions, symbols and file names for FILE.
+When FILE is a function, call it. When it is a form, evaluate
+it. When it is a variable, return its value. When it is
+a string, treat it as a file name, possibly expanding it
+according to `org-directory', and return it. If it is the empty
+string, however, return `org-default-notes-file'. In any other
+case, raise an error."
(cond
((equal file "") org-default-notes-file)
+ ((stringp file) (expand-file-name file org-directory))
((functionp file) (funcall file))
- ((and (symbolp file) (boundp file)) (symbol-value file))
- (t file)))
+ ((and (symbolp file) (bound-and-true-p file)))
+ (t (error "Invalid file location: %S" file))))
(defun org-capture-target-buffer (file)
- "Get a buffer for FILE."
- (setq file (org-capture-expand-file file))
- (setq file (or (org-string-nw-p file)
- org-default-notes-file
- (error "No notes file specified, and no default available")))
- (or (org-find-base-buffer-visiting file)
- (progn (org-capture-put :new-buffer t)
- (find-file-noselect (expand-file-name file org-directory)))))
+ "Get a buffer for FILE.
+FILE is a generalized file location, as handled by
+`org-capture-expand-file'."
+ (let ((file (or (org-string-nw-p (org-capture-expand-file file))
+ org-default-notes-file
+ (error "No notes file specified, and no default available"))))
+ (or (org-find-base-buffer-visiting file)
+ (progn (org-capture-put :new-buffer t)
+ (find-file-noselect file)))))
(defun org-capture-place-template (&optional inhibit-wconf-store)
"Insert the template at the target location, and display the buffer.