Browse Source

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.
Bastien 15 years ago
parent
commit
08650cbb5c
2 changed files with 16 additions and 0 deletions
  1. 4 0
      doc/org.texi
  2. 12 0
      lisp/org-capture.el

+ 4 - 0
doc/org.texi

@@ -6314,6 +6314,10 @@ Valid values are:
 @item (file "path/to/file")
 @item (file "path/to/file")
 Text will be placed at the beginning or end of that 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")
 @item (id "id of existing org entry")
 Filing as child of this entry, or in the body of the entry.
 Filing as child of this entry, or in the body of the entry.
 
 

+ 12 - 0
lisp/org-capture.el

@@ -120,6 +120,10 @@ target       Specification of where the captured item should be placed.
              (file \"path/to/file\")
              (file \"path/to/file\")
                  Text will be placed at the beginning or end of that 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\")
              (id \"id of existing org entry\")
                  File as child of this entry, or in the body of the entry
                  File as child of this entry, or in the body of the entry
 
 
@@ -266,6 +270,8 @@ calendar                |  %:type %:date"
 		   (list :tag "File"
 		   (list :tag "File"
 			 (const :format "" file)
 			 (const :format "" file)
 			 (file :tag "  File"))
 			 (file :tag "  File"))
+		   (list :tag "Current file"
+			 (const :format "" currentfile))
 		   (list :tag "ID"
 		   (list :tag "ID"
 			 (const :format "" id)
 			 (const :format "" id)
 			 (string :tag "  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)))
 	(set-buffer (org-capture-target-buffer (nth 1 target)))
 	(setq target-entry-p nil))
 	(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)
        ((eq (car target) 'id)
 	(let ((loc (org-id-find (nth 1 target))))
 	(let ((loc (org-id-find (nth 1 target))))
 	  (if (not loc)
 	  (if (not loc)