From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian McB Subject: Re: org mode capture to headline at point Date: Tue, 24 May 2016 15:27:09 +0000 (UTC) Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:41540) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5EHd-0005Qc-Rq for emacs-orgmode@gnu.org; Tue, 24 May 2016 11:30:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b5EHX-0005zn-71 for emacs-orgmode@gnu.org; Tue, 24 May 2016 11:30:12 -0400 Received: from plane.gmane.org ([80.91.229.3]:38752) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5EHX-0005xp-0W for emacs-orgmode@gnu.org; Tue, 24 May 2016 11:30:07 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1b5EHT-0003hm-SS for emacs-orgmode@gnu.org; Tue, 24 May 2016 17:30:04 +0200 Received: from 173.63-130-109.adsl-dyn.isp.belgacom.be ([173.63-130-109.adsl-dyn.isp.belgacom.be]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 24 May 2016 17:30:03 +0200 Received: from yanmcbe by 173.63-130-109.adsl-dyn.isp.belgacom.be with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 24 May 2016 17:30:03 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org Xebar Saram 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.