summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien <bastien.guerry@wikimedia.fr>2011-02-11 15:21:50 +0000
committerBastien Guerry <bzg@altern.org>2011-02-12 19:07:52 +0100
commit08650cbb5c814858e0a3864320ff96895e7def9c (patch)
treeb1a1c907a83ed893edb3da1c8347e6ea4d35548e
parent03c33d0d387fb7cd5dfd1fa8d5567bfd1263bbd7 (diff)
downloadorg-mode-08650cbb5c814858e0a3864320ff96895e7def9c.tar.gz
Allow (currentfile) for capture templates.
* org-capture.el (org-capture-templates): document currentfile for capture template. (org-capture-templates): Allow to use currentfile for capture templates. (org-capture-set-target-location): Handle currentfile as a way to setting the capture buffer. * org.texi (Template elements): document currentfile for capture templates.
-rw-r--r--doc/org.texi4
-rw-r--r--lisp/org-capture.el12
2 files changed, 16 insertions, 0 deletions
diff --git a/doc/org.texi b/doc/org.texi
index 6be63bf..31c71e6 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -6314,6 +6314,10 @@ Valid values are:
@item (file "path/to/file")
Text will be placed at the beginning or end of that file.
+@item (currentfile)
+Text will be placed at the beginning or end of the file
+@code{org-capture} is called from.
+
@item (id "id of existing org entry")
Filing as child of this entry, or in the body of the entry.
diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index e258308..2f9b379 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -120,6 +120,10 @@ target Specification of where the captured item should be placed.
(file \"path/to/file\")
Text will be placed at the beginning or end of that file
+ (currentfile)
+ Text will be placed at the beginning or end of the file
+ org-capture is called from
+
(id \"id of existing org entry\")
File as child of this entry, or in the body of the entry
@@ -266,6 +270,8 @@ calendar | %:type %:date"
(list :tag "File"
(const :format "" file)
(file :tag " File"))
+ (list :tag "Current file"
+ (const :format "" currentfile))
(list :tag "ID"
(const :format "" id)
(string :tag " ID"))
@@ -632,6 +638,12 @@ already gone. Any prefix argument will be passed to the refile comand."
(set-buffer (org-capture-target-buffer (nth 1 target)))
(setq target-entry-p nil))
+ ((eq (car target) 'currentfile)
+ (if (not (and (buffer-file-name) (org-mode-p)))
+ (error "Cannot call this capture template outside of an Org buffer")
+ (set-buffer (org-capture-target-buffer (buffer-file-name)))
+ (setq target-entry-p nil)))
+
((eq (car target) 'id)
(let ((loc (org-id-find (nth 1 target))))
(if (not loc)