summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Dominik <carsten.dominik@gmail.com>2010-07-20 07:54:11 +0200
committerCarsten Dominik <carsten.dominik@gmail.com>2010-07-20 09:05:31 +0200
commitcee04fa632570b12e9950386282bfde02a02ff6b (patch)
treeb5428888aa74dbef9e12c232f528e4ee9e807273
parentb1c7f8ee6ba8d04ee5b45ee47c636d83b029430b (diff)
downloadorg-mode-cee04fa632570b12e9950386282bfde02a02ff6b.tar.gz
Make org-capture use `org-default-notes-file' if the file is not specified
* lisp/org-macs.el (org-string-nw-p): New function. * lisp/org-capture.el (org-capture-import-remember-templates): Interpret an empty string as request to use `org-default-notes-file'. (org-capture-target-buffer): If the FILE is not a (non-empty) string, use `org-default-notes-file'.
-rw-r--r--doc/org.texi11
-rw-r--r--lisp/org-capture.el1
-rw-r--r--lisp/org-macs.el7
3 files changed, 15 insertions, 4 deletions
diff --git a/doc/org.texi b/doc/org.texi
index a6012ca..b2a6173 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -5950,6 +5950,7 @@ The following customization sets a default target file for notes, and defines
a global key@footnote{Please select your own key, @kbd{C-c c} is only a
suggestion.} for capturing new material.
+@vindex org-default-notes-file
@example
(setq org-default-notes-file (concat org-directory "/notes.org"))
(define-key global-map "\C-cc" 'org-capture)
@@ -6083,10 +6084,12 @@ Text to be inserted as it is.
@end table
@item target
-Specification of where the captured item should be placed.
-In Org-mode 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.
+@vindex org-default-notes-file
+Specification of where the captured item should be placed. In Org-mode
+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}.
Valid values are:
@table @code
diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index a9597cd..cbeb9a8 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -651,6 +651,7 @@ already gone."
(defun org-capture-target-buffer (file)
"Get a buffer for FILE."
+ (setq file (or (org-string-nw-p file) org-default-notes-file))
(or (org-find-base-buffer-visiting file)
(find-file-noselect (expand-file-name file org-directory))))
diff --git a/lisp/org-macs.el b/lisp/org-macs.el
index ba1d5f0..77527d2 100644
--- a/lisp/org-macs.el
+++ b/lisp/org-macs.el
@@ -38,11 +38,18 @@
(defmacro declare-function (fn file &optional arglist fileonly))))
(declare-function org-add-props "org-compat" (string plist &rest props))
+(declare-function org-string-match-p "org-compat" (&rest args))
(defmacro org-bound-and-true-p (var)
"Return the value of symbol VAR if it is bound, else nil."
`(and (boundp (quote ,var)) ,var))
+(defun org-string-nw-p (s)
+ "Is S a string with a non-white character?"
+ (and (stringp s)
+ (org-string-match-p "\\S-" s)
+ s))
+
(defun org-not-nil (v)
"If V not nil, and also not the string \"nil\", then return V.
Otherwise return nil."