emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Bastien Guerry <bzg@altern.org>
To: emacs-orgmode@gnu.org
Subject: [Accepted] using (id "Name") target in org-capture-templates
Date: Sat, 12 Feb 2011 19:09:19 +0100 (CET)	[thread overview]
Message-ID: <20110212180919.250FC8860@myhost.localdomain> (raw)
In-Reply-To: 87wrl6yipt.fsf@gnu.org

Patch 593 (http://patchwork.newartisans.com/patch/593/) is now "Accepted".

Maintainer comment: none

This relates to the following submission:

http://mid.gmane.org/%3C87wrl6yipt.fsf%40gnu.org%3E

Here is the original message containing the patch:

> Content-Type: text/plain; charset="utf-8"
> MIME-Version: 1.0
> Content-Transfer-Encoding: 7bit
> Subject: [Orgmode] using (id "Name") target in org-capture-templates
> Date: Fri, 11 Feb 2011 15:21:50 -0000
> From: Bastien <bastien.guerry@wikimedia.fr>
> X-Patchwork-Id: 593
> Message-Id: <87wrl6yipt.fsf@gnu.org>
> To: "Sullivan\, Gregory \(US SSA\)" <gregory.sullivan@baesystems.com>
> Cc: "Emacs-orgmode@gnu.org" <Emacs-orgmode@gnu.org>
> 
> Hi Gregory,
> 
> "Sullivan, Gregory (US SSA)" <gregory.sullivan@baesystems.com> 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.
> 
> 
> >From a276dc40c860e636be7c8d743bd01b401461a8f5 Mon Sep 17 00:00:00 2001
> From: Bastien Guerry <bzg@altern.org>
> 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
> 
> 

  reply	other threads:[~2011-02-12 18:09 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-22 19:33 using (id "Name") target in org-capture-templates Sullivan, Gregory (US SSA)
2010-12-23 11:41 ` Giovanni Ridolfi
2011-01-06 16:54   ` Sullivan, Gregory (US SSA)
2011-02-11 10:21     ` Bastien
2011-02-12 18:09       ` Bastien Guerry [this message]
2011-02-22 18:55       ` Sullivan, Gregory (US SSA)
2011-02-27 11:37         ` Bastien
2011-02-28  1:38           ` Sullivan, Gregory (US SSA)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110212180919.250FC8860@myhost.localdomain \
    --to=bzg@altern.org \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).