all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ian McB <yanmcbe@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: org mode capture to headline at point
Date: Tue, 24 May 2016 15:27:09 +0000 (UTC)	[thread overview]
Message-ID: <loom.20160524T172408-47@post.gmane.org> (raw)
In-Reply-To: CAOQHXPq1AeBh1Gd0oEB_5A-6QM9x1_i0wW8wsRoz_WJAWrsafg@mail.gmail.com

Xebar Saram <zeltakc <at> gmail.com> writes:

> 
> Hi all
> any one knows how to launch a capture (thats pre defined) but auto refile
that capture to the/beneath the current header at point?
> 
> thx
> 
> Z
> 


A while back I stumbled onto this thread looking for the same problem. Like
Phil Hudson suggested I created a capture template using a custom function.
I'll share my solution below.

one of the capture templates using the function:
     ("ss" "Future subtask" entry
      (function my-org-move-point-to-capture)
      "* TODO %?
  :PROPERTIES:
  :Created: %U
  :END:")

the necessary function
(defun my-org-move-point-to-capture ()
  (cond ((org-at-heading-p) (org-beginning-of-line))
        (t (org-previous-visible-heading 1))))

So pretty simple all in all. Keep in mind I'm pretty new to Elisp, Emacs and
org-mode. One gotcha in writing the function which I didn't find easily
documented was that (point) needs to end up over the asterisk starting a
headline to result in the capture being a subheading of that headline. The
behaviour to end up at that asterisk is different depending on whether point
is in the body of the heading or on the headline itself at the time of
capturing.

Hope this is useful. I've been wanting to subscribe to this list for a while
now, to ask about some bugs and strange behaviours.

  parent reply	other threads:[~2016-05-24 15:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-13 15:08 org mode capture to headline at point Xebar Saram
2016-05-13 17:07 ` Phil Hudson
2016-05-24 15:27 ` Ian McB [this message]
2016-05-28  5:49   ` Xebar Saram
2016-05-28 14:00     ` yanmcbe
2016-05-29 15:07       ` Xebar Saram

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

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

  git send-email \
    --in-reply-to=loom.20160524T172408-47@post.gmane.org \
    --to=yanmcbe@gmail.com \
    --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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.