From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: my capture template generates a literal "%?" Date: Thu, 09 Aug 2012 11:35:46 -0400 Message-ID: <19288.1344526546@alphaville> References: <502364D2.7030208@googlemail.com> <18245.1344523075@alphaville> <18545.1344523720@alphaville> Reply-To: nicholas.dokos@hp.com Return-path: Received: from eggs.gnu.org ([208.118.235.92]:42525) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SzUmC-0003Y9-DN for emacs-orgmode@gnu.org; Thu, 09 Aug 2012 11:36:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SzUm6-0008VV-6J for emacs-orgmode@gnu.org; Thu, 09 Aug 2012 11:35:56 -0400 Received: from g1t0028.austin.hp.com ([15.216.28.35]:37901) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SzUm5-0008Uy-TV for emacs-orgmode@gnu.org; Thu, 09 Aug 2012 11:35:50 -0400 In-Reply-To: Message from Nick Dokos of "Thu, 09 Aug 2012 10:48:40 EDT." <18545.1344523720@alphaville> 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 Cc: G , emacs-orgmode@gnu.org Nick Dokos wrote: > Nick Dokos wrote: > > > G wrote: > > > > > Hi, > > > > > > I am using Emacs 24.1 in Win7 (64bit) and Org 7.8.11. > > > I would like to have a capture template that just puts me at the end > > > of my journal in plain text (although date tree) after a custom time > > > stamp (e.g. 09:13). I tried the following > > > ("p" "Plain Journal" plain (file+datetree > > > "C:/Users/Geralb/Documents/privat/org/MyAgenda.org") > > > "%<%H:%M>\n\n%?" > > > :unnarrowed t :empty-lines 1) > > > > > > But in this template a literal %? is written and point is thereafter. > > > > > > I tried another template > > > ("e" "Entry Journal" entry (file+datetree > > > "C:/Users/Geralb/Documents/privat/org/MyAgenda.org") > > > "* Um %U von %a\n\n%?\n" > > > :empty-lines 1 :unnarrowed t) > > > > > > And this seems to work, but it's not what I would like to have. > > > > > > Did I write the template wrong? > > > > > > > I don't think so. I can reproduce it and I think it is a bug: %? does > > not seem to be interpreted in the first case, it is interpreted in the > > second case, but I don't know what causes the difference. > > > > D'oh: plain type just inserts things literally. Need more coffee. > D'oh^2: everything else is interpreted, so why not %? ? The problem seems to be in org-capture-place-plain-text: the insertion of the text happens like this ,---- | ... | (setq beg (point)) | (insert txt) | (org-capture-empty-lines-after 1) | (org-capture-position-for-last-stored beg) | (setq end (point)) | (org-capture-mark-kill-region beg (1- end)) | (org-capture-narrow beg (1- end)) | (if (re-search-forward "%\\?" end t) (replace-match "")))) `---- but it seesm that just before the re-search-forward, point is at end, not at beg, so the search is fruitless. We could search backwards to beg instead (but what is the semantics of multiple %? markers in the template?), or we could just (goto-char beg) before the search. Nick