emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] org mode capture to headline at point


From: Ian McB
Subject: Re: [O] org mode capture to headline at point
Date: Tue, 24 May 2016 15:27:09 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

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.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]