Browse Source

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'.
Carsten Dominik 10 years ago
parent
commit
cee04fa632
3 changed files with 15 additions and 4 deletions
  1. 7 4
      doc/org.texi
  2. 1 0
      lisp/org-capture.el
  3. 7 0
      lisp/org-macs.el

+ 7 - 4
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

+ 1 - 0
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))))
 

+ 7 - 0
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."