emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* what would cause failure in template for org capture?
@ 2021-07-21 11:36 Eric S Fraga
  2021-07-21 15:21 ` Nick Dokos
  0 siblings, 1 reply; 14+ messages in thread
From: Eric S Fraga @ 2021-07-21 11:36 UTC (permalink / raw)
  To: Emacs Org mode mailing list

Hello all,

I am getting this error message:

org-capture: Capture abort: Unknown template placeholder: "%^G"

when attempting to capture a task using this template:

#+begin_src emacs-lisp
  (add-to-list 'org-capture-templates
               '("t"
                 "todo"
                 entry (file+headline "~/s/notes/todo.org" "refile")
                 "* %^{Task}   %^G\n%i%?\n%U\n"))
#+end_src

The error happens after having entered the information for the Task in
the template so next would be the tags.

This was working until recently.  Both Emacs and org are up to date
relative to their git repositories.  The only change done recently in my
configuration is a move from ivy to selectrum for completion.

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.4.6-598-g604bfd
: Latest paper written in org: https://arxiv.org/abs/2106.05096


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

* Re: what would cause failure in template for org capture?
  2021-07-21 11:36 what would cause failure in template for org capture? Eric S Fraga
@ 2021-07-21 15:21 ` Nick Dokos
  2021-07-21 15:25   ` Eric S Fraga
  2021-07-21 15:38   ` Eric S Fraga
  0 siblings, 2 replies; 14+ messages in thread
From: Nick Dokos @ 2021-07-21 15:21 UTC (permalink / raw)
  To: emacs-orgmode

Eric S Fraga <e.fraga@ucl.ac.uk> writes:

> Hello all,
>
> I am getting this error message:
>
> org-capture: Capture abort: Unknown template placeholder: "%^G"
>
> when attempting to capture a task using this template:
>
> #+begin_src emacs-lisp
>   (add-to-list 'org-capture-templates
>                '("t"
>                  "todo"
>                  entry (file+headline "~/s/notes/todo.org" "refile")
>                  "* %^{Task}   %^G\n%i%?\n%U\n"))
> #+end_src
>
> The error happens after having entered the information for the Task in
> the template so next would be the tags.
>
> This was working until recently.  Both Emacs and org are up to date
> relative to their git repositories.  The only change done recently in my
> configuration is a move from ivy to selectrum for completion.

FWIW, it's working for me. There was a change on July 8 having to do
with tags completion (using completing-read-multiple), but I'm running
with that change and I don't see a problem. OTOH, I'm not using
selectrum (or ivy for that matter), so the change may be interacting
badly with it.

I would probably edebug `org-capture-fille-template` and check that the
code around l.1733 in `org-capture.el' behaves as expected.

-- 
Nick

"There are only two hard problems in computer science: cache
invalidation, naming things, and off-by-one errors." -Martin Fowler



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

* Re: what would cause failure in template for org capture?
  2021-07-21 15:21 ` Nick Dokos
@ 2021-07-21 15:25   ` Eric S Fraga
  2021-07-21 15:38   ` Eric S Fraga
  1 sibling, 0 replies; 14+ messages in thread
From: Eric S Fraga @ 2021-07-21 15:25 UTC (permalink / raw)
  To: Nick Dokos; +Cc: emacs-orgmode

On Wednesday, 21 Jul 2021 at 11:21, Nick Dokos wrote:
> FWIW, it's working for me. There was a change on July 8 having to do
> with tags completion (using completing-read-multiple), 

which kind of supports my suspicion that it has to do with
selectrum. :-(

> I would probably edebug `org-capture-fille-template` and check that the
> code around l.1733 in `org-capture.el' behaves as expected.

Yet another reason for me to learn edebug finally...  I'll see if I can
find some time.

Thank you,
eric

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.4.6-598-g604bfd
: Latest paper written in org: https://arxiv.org/abs/2106.05096


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

* Re: what would cause failure in template for org capture?
  2021-07-21 15:21 ` Nick Dokos
  2021-07-21 15:25   ` Eric S Fraga
@ 2021-07-21 15:38   ` Eric S Fraga
  2021-07-21 16:23     ` tomas
  1 sibling, 1 reply; 14+ messages in thread
From: Eric S Fraga @ 2021-07-21 15:38 UTC (permalink / raw)
  To: Nick Dokos; +Cc: emacs-orgmode

ummmm figured why not learn edebug *now*.

so I instrument that method, start the capture, tell edebug to go when
it stops in that function, and the capture works.  And now it works
whether instrumented or not.  Hey hum.  A total mystery but at least it
works.

Maybe native compilation has something to do with this?  This is me
grasping at straws, mind you.

I'll update if/when this problem re-asserts itself.

Thanks again,
eric

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.4.6-598-g604bfd
: Latest paper written in org: https://arxiv.org/abs/2106.05096


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

* Re: what would cause failure in template for org capture?
  2021-07-21 15:38   ` Eric S Fraga
@ 2021-07-21 16:23     ` tomas
  2021-07-23 14:41       ` Eric S Fraga
  0 siblings, 1 reply; 14+ messages in thread
From: tomas @ 2021-07-21 16:23 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 434 bytes --]

On Wed, Jul 21, 2021 at 04:38:58PM +0100, Eric S Fraga wrote:
> ummmm figured why not learn edebug *now*.
> 
> so I instrument that method, start the capture, tell edebug to go when
> it stops in that function, and the capture works.  And now it works
> whether instrumented or not.  Hey hum.  A total mystery but at least it
> works.

So edebug fixed it? Good :-)

(Now I'm hiding again under my stone ;-)

Cheers
 - t

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: what would cause failure in template for org capture?
  2021-07-21 16:23     ` tomas
@ 2021-07-23 14:41       ` Eric S Fraga
  2021-07-23 15:20         ` tomas
  2021-07-24  0:37         ` Tim Cross
  0 siblings, 2 replies; 14+ messages in thread
From: Eric S Fraga @ 2021-07-23 14:41 UTC (permalink / raw)
  To: tomas; +Cc: emacs-orgmode

On Wednesday, 21 Jul 2021 at 18:23, tomas@tuxteam.de wrote:
> So edebug fixed it? Good :-)

Well, it fixed it until I started Emacs again (which I don't do often,
luckily, as it's my window manager).  So, to get org-capture to work
again, I need to instrument the function and then it works.  I have no
idea how to debug this when it works just fine when instrumented.

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.4.6-598-g604bfd
: Latest paper written in org: https://arxiv.org/abs/2106.05096


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

* Re: what would cause failure in template for org capture?
  2021-07-23 14:41       ` Eric S Fraga
@ 2021-07-23 15:20         ` tomas
  2021-07-24  0:37         ` Tim Cross
  1 sibling, 0 replies; 14+ messages in thread
From: tomas @ 2021-07-23 15:20 UTC (permalink / raw)
  To: Org Mode List

[-- Attachment #1: Type: text/plain, Size: 260 bytes --]

On Fri, Jul 23, 2021 at 03:41:49PM +0100, Eric S Fraga wrote:
> On Wednesday, 21 Jul 2021 at 18:23, tomas@tuxteam.de wrote:
> > So edebug fixed it? Good :-)
> 
> Well, it fixed it until I started Emacs again

Gah. Sorry to hear that :-(

Cheers
 - t

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: what would cause failure in template for org capture?
  2021-07-23 14:41       ` Eric S Fraga
  2021-07-23 15:20         ` tomas
@ 2021-07-24  0:37         ` Tim Cross
  2021-07-24  3:03           ` No Wayman
  2021-07-24 12:28           ` Eric S Fraga
  1 sibling, 2 replies; 14+ messages in thread
From: Tim Cross @ 2021-07-24  0:37 UTC (permalink / raw)
  To: emacs-orgmode


Eric S Fraga <e.fraga@ucl.ac.uk> writes:

> On Wednesday, 21 Jul 2021 at 18:23, tomas@tuxteam.de wrote:
>> So edebug fixed it? Good :-)
>
> Well, it fixed it until I started Emacs again (which I don't do often,
> luckily, as it's my window manager).  So, to get org-capture to work
> again, I need to instrument the function and then it works.  I have no
> idea how to debug this when it works just fine when instrumented.

Hi Eric,

from an earlier thread, I recall you mentioned you were using native
compilation? This is almost certainly the cause of your problem.

From your description, I suspect that the compiled version of your code
is not complete and not loading correctly. This is why the problem is
solved when you try to use edebug on it as instrumenting the function
will result in the uncompiled *.el files being loaded. My advice would
be not to use native compilation. Native compilation is probably a good
advance for Emacs, but I think it is at least 18 months away from being
ready for prime time.

When running native compilation support, I found
- Absolutely no performance improvement
- Large packages with complex dependencies did not build correctly
- The native compilation caching scheme was unreliable and inconsistent

I would try re-building without native compilation and re-install org to
see if that fixes your problem.

Tim


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

* Re: what would cause failure in template for org capture?
  2021-07-24  0:37         ` Tim Cross
@ 2021-07-24  3:03           ` No Wayman
  2021-07-24  4:13             ` Tim Cross
  2021-07-27 14:06             ` Gregor Zattler
  2021-07-24 12:28           ` Eric S Fraga
  1 sibling, 2 replies; 14+ messages in thread
From: No Wayman @ 2021-07-24  3:03 UTC (permalink / raw)
  To: theophilusx; +Cc: emacs-orgmode


> from an earlier thread, I recall you mentioned you were using 
> native
> compilation? This is almost certainly the cause of your problem.

This does smell like a byte-compilation problem.
Seems to be a failure with any interactive, single-character 
%-escaped patterns in a template string (e.g. %^g, %^C, %^t).
I've narrowed it down to a call to pcase in 
`org-capture-fill-template'.
As Eric mentions, the problem disappears if the function is 
re-evaluated/instrumented.
I have disabled native compilation and the problem persists with 
just a freshly byte-compiled elc of org-capture.
Tested this with the following recipe:

1. eval the following:
(org-capture-fill-template "%^t") ;fails with `unrecognized 
template placeholder: %^t`
2. eval org-capture-fill-template's definition, and then re-eval 
the above. Works properly. User is prompted for a time.
3. byte compile org-capture-fill-template: (byte-compile 
#'org-capture-fill-template)
4. eval (org-capture-fill-template "%^t") ; error is back


Running Emacs 28.0.50
Repository revision: 903ecd7bea7d8f99a7dc84150728219283d79bf0
Repository branch: master





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

* Re: what would cause failure in template for org capture?
  2021-07-24  3:03           ` No Wayman
@ 2021-07-24  4:13             ` Tim Cross
  2021-07-27 14:06             ` Gregor Zattler
  1 sibling, 0 replies; 14+ messages in thread
From: Tim Cross @ 2021-07-24  4:13 UTC (permalink / raw)
  To: No Wayman; +Cc: emacs-orgmode


No Wayman <iarchivedmywholelife@gmail.com> writes:

>> from an earlier thread, I recall you mentioned you were using native
>> compilation? This is almost certainly the cause of your problem.
>
> This does smell like a byte-compilation problem.
> Seems to be a failure with any interactive, single-character %-escaped patterns
> in a template string (e.g. %^g, %^C, %^t).
> I've narrowed it down to a call to pcase in `org-capture-fill-template'.
> As Eric mentions, the problem disappears if the function is
> re-evaluated/instrumented.
> I have disabled native compilation and the problem persists with just a freshly
> byte-compiled elc of org-capture.
> Tested this with the following recipe:
>
> 1. eval the following:
> (org-capture-fill-template "%^t") ;fails with `unrecognized template
> placeholder: %^t`
> 2. eval org-capture-fill-template's definition, and then re-eval the above.
> Works properly. User is prompted for a time.
> 3. byte compile org-capture-fill-template: (byte-compile
> #'org-capture-fill-template)
> 4. eval (org-capture-fill-template "%^t") ; error is back
>
>
> Running Emacs 28.0.50
> Repository revision: 903ecd7bea7d8f99a7dc84150728219283d79bf0
> Repository branch: master

Need to see if this can be reproduced in emacs 27.2. If it cannot, I
would suspect a bug in Emacs 28 and possibly something which should be
reported as an emacs bug (rather than an org bug).


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

* Re: what would cause failure in template for org capture?
  2021-07-24  0:37         ` Tim Cross
  2021-07-24  3:03           ` No Wayman
@ 2021-07-24 12:28           ` Eric S Fraga
  1 sibling, 0 replies; 14+ messages in thread
From: Eric S Fraga @ 2021-07-24 12:28 UTC (permalink / raw)
  To: Tim Cross; +Cc: emacs-orgmode

On Saturday, 24 Jul 2021 at 10:37, Tim Cross wrote:
> My advice would be not to use native compilation. 

Probably good advice but, for me, native compilation has (generally)
been working very well and has had significant performance
improvement.  I use Emacs as my window manager (EXWM) and every little
bit of speed helps.

Yes, there are some issues and org-capture may be one of them.  As you
say in another followup, this is probably an Emacs bug and not for org.

thank you,
eric

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.4.6-598-g604bfd
: Latest paper written in org: https://arxiv.org/abs/2106.05096


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

* Re: what would cause failure in template for org capture?
  2021-07-24  3:03           ` No Wayman
  2021-07-24  4:13             ` Tim Cross
@ 2021-07-27 14:06             ` Gregor Zattler
  2021-07-27 16:37               ` No Wayman
  1 sibling, 1 reply; 14+ messages in thread
From: Gregor Zattler @ 2021-07-27 14:06 UTC (permalink / raw)
  To: emacs-orgmode

Hi No, Eric,

* No Wayman <iarchivedmywholelife@gmail.com> [2021-07-23; 23:03]:
>> from an earlier thread, I recall you mentioned you were using
>> native
>> compilation? This is almost certainly the cause of your problem.
>
> This does smell like a byte-compilation problem.
> Seems to be a failure with any interactive, single-character
> %-escaped patterns in a template string (e.g. %^g, %^C, %^t).
> I've narrowed it down to a call to pcase in
> `org-capture-fill-template'.
> As Eric mentions, the problem disappears if the function is
> re-evaluated/instrumented.
> I have disabled native compilation and the problem persists with
> just a freshly byte-compiled elc of org-capture.
> Tested this with the following recipe:
>
> 1. eval the following:
> (org-capture-fill-template "%^t") ;fails with `unrecognized
> template placeholder: %^t`
> 2. eval org-capture-fill-template's definition, and then re-eval
> the above. Works properly. User is prompted for a time.
> 3. byte compile org-capture-fill-template: (byte-compile
> #'org-capture-fill-template)
> 4. eval (org-capture-fill-template "%^t") ; error is back
>
>
> Running Emacs 28.0.50
> Repository revision: 903ecd7bea7d8f99a7dc84150728219283d79bf0
> Repository branch: master

this is now emacs bug 49746
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=49746

Because of No's email I did a git bisect and found a commit
which changes the byte compiler.

Ciao; Gregor
--
 -... --- .-. . -.. ..--.. ...-.-



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

* Re: what would cause failure in template for org capture?
  2021-07-27 14:06             ` Gregor Zattler
@ 2021-07-27 16:37               ` No Wayman
  2021-07-28 10:00                 ` Eric S Fraga
  0 siblings, 1 reply; 14+ messages in thread
From: No Wayman @ 2021-07-27 16:37 UTC (permalink / raw)
  To: telegraph; +Cc: emacs-orgmode


Thanks for doing the bisect.
I was in the process of doing it myself and comparing disassembled 
byte-code when I saw the patch had been pushed.
For anyone curious, this particular bug was a byte compilation 
error.
When byte-compiled, org-capture-fill-template was attempting to 
compare strings
via a jump-table-eq bytecode instruction instead of a 
jump-table-equal.

Resolved on Emacs master as of 
949dd41c31dab69f7a5067bba324c28bb2cfbf8e


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

* Re: what would cause failure in template for org capture?
  2021-07-27 16:37               ` No Wayman
@ 2021-07-28 10:00                 ` Eric S Fraga
  0 siblings, 0 replies; 14+ messages in thread
From: Eric S Fraga @ 2021-07-28 10:00 UTC (permalink / raw)
  To: No Wayman; +Cc: emacs-orgmode

On Tuesday, 27 Jul 2021 at 12:37, No Wayman wrote:
> Resolved on Emacs master as of
> 949dd41c31dab69f7a5067bba324c28bb2cfbf8e

Excellent.  Re-building now!  Thank you (and Gregor) for bisecting and
reporting.

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.4.6-598-g604bfd
: Latest paper written in org: https://arxiv.org/abs/2106.05096


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

end of thread, other threads:[~2021-07-28 10:06 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-07-21 11:36 what would cause failure in template for org capture? Eric S Fraga
2021-07-21 15:21 ` Nick Dokos
2021-07-21 15:25   ` Eric S Fraga
2021-07-21 15:38   ` Eric S Fraga
2021-07-21 16:23     ` tomas
2021-07-23 14:41       ` Eric S Fraga
2021-07-23 15:20         ` tomas
2021-07-24  0:37         ` Tim Cross
2021-07-24  3:03           ` No Wayman
2021-07-24  4:13             ` Tim Cross
2021-07-27 14:06             ` Gregor Zattler
2021-07-27 16:37               ` No Wayman
2021-07-28 10:00                 ` Eric S Fraga
2021-07-24 12:28           ` Eric S Fraga

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