summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2016-11-06 11:20:25 +0100
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2016-11-06 11:20:25 +0100
commit88a3c2483ee47b342e9bb7d2c1645dce11179bf5 (patch)
treecf859adbb13212337f0f5d8837d3cb0e51e09608
parent6b168ab03496f62317f77026711ac1a91ad815bf (diff)
downloadorg-mode-88a3c2483ee47b342e9bb7d2c1645dce11179bf5.tar.gz
org-capture: Improve error handling for file locations
* lisp/org-capture.el (org-capture-expand-file): Return an error on invalid locations. (org-capture-target-buffer): Remove useless checks.
-rw-r--r--lisp/org-capture.el17
1 files changed, 8 insertions, 9 deletions
diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index 5d1b7d5..9331f49 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -1012,20 +1012,19 @@ 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) (bound-and-true-p file)))
- (t (error "Invalid file location: %S" file))))
+ (let ((location (cond ((equal file "") org-default-notes-file)
+ ((stringp file) (expand-file-name file org-directory))
+ ((functionp file) (funcall file))
+ ((and (symbolp file) (bound-and-true-p file)))
+ (t nil))))
+ (or (org-string-nw-p location)
+ (error "Invalid file location: %S" location))))
(defun org-capture-target-buffer (file)
"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"))))
+ (let ((file (org-capture-expand-file file)))
(or (org-find-base-buffer-visiting file)
(progn (org-capture-put :new-buffer t)
(find-file-noselect file)))))