emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* my capture template generates a literal "%?"
@ 2012-08-09  7:20 G
  2012-08-09 14:37 ` Nick Dokos
  0 siblings, 1 reply; 5+ messages in thread
From: G @ 2012-08-09  7:20 UTC (permalink / raw)
  To: emacs-orgmode

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?

Geralb

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: my capture template generates a literal "%?"
  2012-08-09  7:20 my capture template generates a literal "%?" G
@ 2012-08-09 14:37 ` Nick Dokos
  2012-08-09 14:48   ` Nick Dokos
  0 siblings, 1 reply; 5+ messages in thread
From: Nick Dokos @ 2012-08-09 14:37 UTC (permalink / raw)
  To: G; +Cc: emacs-orgmode

G <gsqual@googlemail.com> 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.

Nick

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: my capture template generates a literal "%?"
  2012-08-09 14:37 ` Nick Dokos
@ 2012-08-09 14:48   ` Nick Dokos
  2012-08-09 15:35     ` Nick Dokos
  0 siblings, 1 reply; 5+ messages in thread
From: Nick Dokos @ 2012-08-09 14:48 UTC (permalink / raw)
  To: nicholas.dokos; +Cc: G, emacs-orgmode

Nick Dokos <nicholas.dokos@hp.com> wrote:

> G <gsqual@googlemail.com> 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.

Nick

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: my capture template generates a literal "%?"
  2012-08-09 14:48   ` Nick Dokos
@ 2012-08-09 15:35     ` Nick Dokos
  2012-08-10  9:49       ` Bastien
  0 siblings, 1 reply; 5+ messages in thread
From: Nick Dokos @ 2012-08-09 15:35 UTC (permalink / raw)
  Cc: G, emacs-orgmode

Nick Dokos <nicholas.dokos@hp.com> wrote:

> Nick Dokos <nicholas.dokos@hp.com> wrote:
> 
> > G <gsqual@googlemail.com> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: my capture template generates a literal "%?"
  2012-08-09 15:35     ` Nick Dokos
@ 2012-08-10  9:49       ` Bastien
  0 siblings, 0 replies; 5+ messages in thread
From: Bastien @ 2012-08-10  9:49 UTC (permalink / raw)
  To: nicholas.dokos; +Cc: G, emacs-orgmode

Hi,

Nick Dokos <nicholas.dokos@hp.com> writes:

> 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.

There was indeed a problem here, I just fixed it.

Thanks for the directions,

-- 
 Bastien

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-08-10  9:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-09  7:20 my capture template generates a literal "%?" G
2012-08-09 14:37 ` Nick Dokos
2012-08-09 14:48   ` Nick Dokos
2012-08-09 15:35     ` Nick Dokos
2012-08-10  9:49       ` Bastien

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).