From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bastien Subject: Re: using (id "Name") target in org-capture-templates Date: Fri, 11 Feb 2011 11:21:50 +0100 Message-ID: <87wrl6yipt.fsf@gnu.org> References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from [140.186.70.92] (port=45293 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pnq8K-0007Gp-Ha for Emacs-orgmode@gnu.org; Fri, 11 Feb 2011 05:21:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pnq8I-0004fr-FP for Emacs-orgmode@gnu.org; Fri, 11 Feb 2011 05:21:48 -0500 Received: from mail-fx0-f41.google.com ([209.85.161.41]:53949) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pnq8I-0004fX-4P for Emacs-orgmode@gnu.org; Fri, 11 Feb 2011 05:21:46 -0500 Received: by fxm12 with SMTP id 12so2673203fxm.0 for ; Fri, 11 Feb 2011 02:21:45 -0800 (PST) In-Reply-To: (Gregory Sullivan's message of "Thu, 6 Jan 2011 11:54:44 -0500") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: "Sullivan, Gregory (US SSA)" Cc: "Emacs-orgmode@gnu.org" --=-=-= Content-Type: text/plain Hi Gregory, "Sullivan, Gregory (US SSA)" writes: > Thanks for the note. I did indeed mean to use headings. > > I think it would be nice to be able to have the file dynamic but the > heading static in capture templates. In my case, I always want to > find a particular heading in the buffer that the capture originated > from. So I had to put the whole target spec in a function, as in: I like the idea of being able to tell capture to use the current file. This patch against latest Org allows you to use (currentfile) like this: ,---- | (setq org-capture-templates | '(("j" "Journal" entry (currentfile) "* %a\n\n%i"))) `---- Let me know if you find this useful. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Allow-currentfile-for-capture-templates.patch >From a276dc40c860e636be7c8d743bd01b401461a8f5 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Fri, 11 Feb 2011 11:17:16 +0100 Subject: [PATCH] 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. --- doc/org.texi | 4 ++++ lisp/org-capture.el | 12 ++++++++++++ 2 files changed, 16 insertions(+), 0 deletions(-) diff --git a/doc/org.texi b/doc/org.texi index f8a7493..be66b75 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) -- 1.7.4 --=-=-= Content-Type: text/plain -- Bastien --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --=-=-=--