emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Rasmus <rasmus@gmx.us>
To: emacs-orgmode@gnu.org
Subject: Re: Prompt org-capture for buffer?
Date: Wed, 07 Feb 2018 16:47:40 +0100	[thread overview]
Message-ID: <87h8qshkdf.fsf@gmx.us> (raw)
In-Reply-To: CAFAhFSU5dVFPkWuMr=AZawWbEhDe0xGosSQbE=4sqtOXLhu35A@mail.gmail.com

Lawrence Bottorff <borgauf@gmail.com> writes:

> I've got this
>
>  '(org-capture-templates
>    (quote
>     (("a" "Normal add" entry (file "~/org/notes.org")
>       "* %(plainutc)\n%x%?"))))
>
> But it wants to put my captured things into ~/org/notes.org . Is there any
> way to have it prompt for which buffer to add to -- or even just put it in
> the active buffer?

You could either use "file+function" or "function" and write a function to
find location or file/buffer and location, respectively.  See the
‘org-capture-templates’ docstring.

             (file+function "path/to/file" function-finding-location)
                 A function to find the right location in the file

             (function function-finding-location)
                Most general way: write your own function which both visits
                the file and moves point to the right location

Functions take no arguments and in the case of file+function, the function
is run from the file buffer.

Example:

            (file+function "~/doc.org"
                           (lambda ()
                             (org-goto-local-search-headings
                              (ido-completing-read
                               "File note to: "
                               (org-element-map
                                   (org-element-parse-buffer)
                                   'headline
                                 (lambda (hl)
                                   (and (= (org-element-property :level hl) 1)
                                        (org-element-property :title hl)))))
                              nil nil)
                             (forward-line 1))
             :prepend t
             :empty-lines-after 1)


Hope it helps,
Rasmus

-- 
. . . It begins of course with The Internet.  A Net of Peers

      reply	other threads:[~2018-02-07 15:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-06 20:28 Prompt org-capture for buffer? Lawrence Bottorff
2018-02-07 15:47 ` Rasmus [this message]

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=87h8qshkdf.fsf@gmx.us \
    --to=rasmus@gmx.us \
    --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).