From mboxrd@z Thu Jan 1 00:00:00 1970 From: York Zhao Subject: Re: org-capture with function type target Date: Sun, 17 Nov 2013 20:32:57 -0500 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary=001a11c3a8cc1814b704eb698788 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:57603) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ViDi0-0001Rq-3I for emacs-orgmode@gnu.org; Sun, 17 Nov 2013 20:33:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ViDhy-0000jI-MU for emacs-orgmode@gnu.org; Sun, 17 Nov 2013 20:33:00 -0500 Received: from mail-ie0-x236.google.com ([2607:f8b0:4001:c03::236]:42848) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ViDhy-0000jC-Ef for emacs-orgmode@gnu.org; Sun, 17 Nov 2013 20:32:58 -0500 Received: by mail-ie0-f182.google.com with SMTP id as1so1615531iec.13 for ; Sun, 17 Nov 2013 17:32:57 -0800 (PST) In-Reply-To: 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-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode --001a11c3a8cc1814b704eb698788 Content-Type: text/plain; charset=ISO-8859-1 To whom it may concern, Please find attached my patch to address this issue. Please let me know if the patch is acceptable. Thanks, York On Sat, Nov 16, 2013 at 8:13 PM, York Zhao wrote: > Hi list, > > I'm been so frustrated when trying to use function as `target' in an > org-capture' template, here is my example: > > 1. Create a file "~/test.org" and add a line "* Level 1", make sure to add a > newline character after the inserted line > 2. Set org-capture-template as: > (setq org-capture-templates > `(("t" > "Test" > entry > (function > (lambda () > (set-buffer (org-capture-target-buffer "~/test.org")) > (goto-char (point-max)))) > "* Level 2" > :immediate-finish t))) > 3. Type "C-c c t" > 4. The result of "test.org" becomes: > > * Level 1 > * Level 2 > > But what I wanted is: > > * Level 1 > ** Level 2 > > I looked into "org-capture.el" and figured out that it is because when > `:exact-position' is set, function `org-capture-place-entry' never insert > template as a child of current entry. And `:exact-position' is set when Target > is a function. > > I don't understand why it is designed this way, does it have to be this way? > what can I do if I want to insert "Level 2" as a child of "Level 1" while using > a function as template target? > > > Thanks, > > York --001a11c3a8cc1814b704eb698788 Content-Type: application/octet-stream; name="0001-org-capture-place-entry-Do-not-special-casing-for-ex.patch" Content-Disposition: attachment; filename="0001-org-capture-place-entry-Do-not-special-casing-for-ex.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_ho51gx0t0 RnJvbSAwYzBjNzFlODdhNzFkZjNlNThiZWYzNThiMDc5MmNmNTVjYzE3ZDI2IE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBZb3JrIFpoYW8gPGd0ZHBsYXRmb3JtQGdtYWlsLmNvbT4KRGF0 ZTogU3VuLCAxNyBOb3YgMjAxMyAxODo0ODo1NSAtMDUwMApTdWJqZWN0OiBbUEFUQ0hdIChvcmct Y2FwdHVyZS1wbGFjZS1lbnRyeSk6IERvIG5vdCBzcGVjaWFsIGNhc2luZyBmb3IKIGA6ZXhhY3Qt cG9zaXRpb24nIGNhcHR1cmUgdGFyZ2V0CgpBc3N1bWluZyBmaWxlICJ0ZXN0Lm9yZyIgaGFzIGEg c2luZ2xlIGhlYWRsaW5lICIqIExldmVsIDEiIChlbmRlZCB3aXRoCm5ld2xpbmUgY2hhcmFjdGVy KSwgd2hlbiB0cnlpbmcgdG8gdXNlIGZ1bmN0aW9uIHR5cGUgY2FwdHVyZSB0YXJnZXQgaW4KYW4g b3JnLWNhcHR1cmUgdGVtcGxhdGUsIGFzIHNob3duIGluIHRoZSBleGFtcGxlOgoKKHNldHEgb3Jn LWNhcHR1cmUtdGVtcGxhdGVzCiAgICAgIGAoKCJ0IgogICAgICAgICAiVGVzdCBmdW5jdGlv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