emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Re: bug#48199: 28.0.50; Org mode surprisingly usurps Calendar key binding
       [not found] <87eeen243m.fsf@gmx.net>
@ 2021-05-09 17:21 ` Stephen Berman
  2021-06-25  9:15   ` Stephen Berman
  0 siblings, 1 reply; 6+ messages in thread
From: Stephen Berman @ 2021-05-09 17:21 UTC (permalink / raw)
  To: 48199; +Cc: emacs-orgmode

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

[I added emacs-orgmode@gnu.org in the Cc:]

On Mon, 03 May 2021 18:07:25 +0200 Stephen Berman <stephen.berman@gmx.net> wrote:

> By default `i' is a prefix key in calendar-mode for commands that insert
> diary entries.  But if you happen to display a buffer that activates
> org-mode machinery, then `i' in calendar-mode becomes bound to
> org-agenda-diary-entry and typing it can raise a wrong-type-argument
> error.  This can happen by visiting a file in Org mode.  To reproduce:
>
> 0. emacs -Q
> 1. (sanity check:) Type `M-x calendar RET' and then in the Calendar
>    buffer type `i C-h': the *Help* buffer displays all the commands
>    invoked by `i' plus one or more keys.
> 2. Visit the file `ORG-NEWS' (e.g. by typing `C-h n C-x C-f O TAB RET').
> 3. Type `M-x calendar RET' and then in the Calendar buffer type `i'
> => Wrong type argument: commandp, org-agenda-diary-entry
>
> This can also catch users by surprise, e.g. in Gnus.  To reproduce,
> replace step 2 above by the following:
>
> 2a. Type `M-x gnus', answer `y' at the prompt; in the Gnus buffer type
>     `B RET news.gmane.io RET'.
> 2b. In the *Gnus Browse Server* buffer type `C-s humani' to put point on
>     the gmane.emacs.humanities group; type RET to enter it.
> 2c. Type `j <87sg6wulu6.fsf@localhost> RET', which displays an article
>     containing an org-mode source code block.
> 3. As above, resulting in the same error (when done from emacs -Q).
>
> The Org mode manual (info "(org) Agenda Commands") does describe its use
> of the `i' binding in the Calendar, and if Org mode has its own versions
> of the commands that use `i' by default in calendar-mode, then
> overriding the calendar-mode bindings is no problem for Org Agenda
> users, but those bindings should not be overridden just by displaying a
> buffer that happens to be in org-mode or happens to contain an Org
> source code block.

The following patch fixes the problem for me:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: org-compat.el patch --]
[-- Type: text/x-patch, Size: 631 bytes --]

diff --git a/lisp/org/org-compat.el b/lisp/org/org-compat.el
index 1f4e2e8308..b68e5b58fc 100644
--- a/lisp/org/org-compat.el
+++ b/lisp/org/org-compat.el
@@ -1151,8 +1151,8 @@ org--setup-calendar-bindings
     ((guard (not (lookup-key calendar-mode-map "c")))
      (local-set-key "c" #'org-calendar-goto-agenda))
     (_ nil))
-  (unless (and (boundp 'org-agenda-diary-file)
-	       (eq org-agenda-diary-file 'diary-file))
+  (when (and (boundp 'org-agenda-diary-file)
+	     (not (eq org-agenda-diary-file 'diary-file)))
     (local-set-key org-calendar-insert-diary-entry-key
 		   #'org-agenda-diary-entry)))


[-- Attachment #3: Type: text/plain, Size: 1162 bytes --]


I have to admit, though, that I don't understand why the version with
`unless' results in the bug, since in the recipes I gave
org-agenda-diary-file is unbound and, indeed, when I instrument the
unpatched org--setup-calendar-bindings and step through it on calling
`calendar', the org-calendar-insert-diary-entry-key local-set-key call
is skipped as expected.  But "c" does get locally set, so if I type `c'
in the Calendar buffer, it displays the Org Agenda, and if I then type
`i' in the Calendar buffer, I now get prompted with a choice menu for
the type of diary entry, but whichever I choose, the result is the
user-error "Don't know which date to use for diary entry", evidently
because there is indeed no org-agenda-diary-file with the necessary text
properties.  So somehow the "i" binding is made even though the code
should prevent this (and does under Edebug but not when executed
normally).

With the above patch, after typing `c' in the Calendar buffer, `i' is
still unbound, as it should be, but if I changed the value of
org-agenda-diary-file from the default 'diary-file to some file, then
`i' works with Org Agenda as documented.

Steve Berman

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

* Re: bug#48199: 28.0.50; Org mode surprisingly usurps Calendar key binding
  2021-05-09 17:21 ` bug#48199: 28.0.50; Org mode surprisingly usurps Calendar key binding Stephen Berman
@ 2021-06-25  9:15   ` Stephen Berman
  0 siblings, 0 replies; 6+ messages in thread
From: Stephen Berman @ 2021-06-25  9:15 UTC (permalink / raw)
  To: 48199-done; +Cc: emacs-orgmode

On Sun, 09 May 2021 19:21:31 +0200 Stephen Berman <stephen.berman@gmx.net> wrote:

> [I added emacs-orgmode@gnu.org in the Cc:]
>
> On Mon, 03 May 2021 18:07:25 +0200 Stephen Berman <stephen.berman@gmx.net> wrote:
>
>> By default `i' is a prefix key in calendar-mode for commands that insert
>> diary entries.  But if you happen to display a buffer that activates
>> org-mode machinery, then `i' in calendar-mode becomes bound to
>> org-agenda-diary-entry and typing it can raise a wrong-type-argument
>> error.  This can happen by visiting a file in Org mode.  To reproduce:
>>
>> 0. emacs -Q
>> 1. (sanity check:) Type `M-x calendar RET' and then in the Calendar
>>    buffer type `i C-h': the *Help* buffer displays all the commands
>>    invoked by `i' plus one or more keys.
>> 2. Visit the file `ORG-NEWS' (e.g. by typing `C-h n C-x C-f O TAB RET').
>> 3. Type `M-x calendar RET' and then in the Calendar buffer type `i'
>> => Wrong type argument: commandp, org-agenda-diary-entry
>>
>> This can also catch users by surprise, e.g. in Gnus.  To reproduce,
>> replace step 2 above by the following:
>>
>> 2a. Type `M-x gnus', answer `y' at the prompt; in the Gnus buffer type
>>     `B RET news.gmane.io RET'.
>> 2b. In the *Gnus Browse Server* buffer type `C-s humani' to put point on
>>     the gmane.emacs.humanities group; type RET to enter it.
>> 2c. Type `j <87sg6wulu6.fsf@localhost> RET', which displays an article
>>     containing an org-mode source code block.
>> 3. As above, resulting in the same error (when done from emacs -Q).
>>
>> The Org mode manual (info "(org) Agenda Commands") does describe its use
>> of the `i' binding in the Calendar, and if Org mode has its own versions
>> of the commands that use `i' by default in calendar-mode, then
>> overriding the calendar-mode bindings is no problem for Org Agenda
>> users, but those bindings should not be overridden just by displaying a
>> buffer that happens to be in org-mode or happens to contain an Org
>> source code block.
>
> The following patch fixes the problem for me:
>
> diff --git a/lisp/org/org-compat.el b/lisp/org/org-compat.el
> index 1f4e2e8308..b68e5b58fc 100644
> --- a/lisp/org/org-compat.el
> +++ b/lisp/org/org-compat.el
> @@ -1151,8 +1151,8 @@ org--setup-calendar-bindings
>      ((guard (not (lookup-key calendar-mode-map "c")))
>       (local-set-key "c" #'org-calendar-goto-agenda))
>      (_ nil))
> -  (unless (and (boundp 'org-agenda-diary-file)
> -	       (eq org-agenda-diary-file 'diary-file))
> +  (when (and (boundp 'org-agenda-diary-file)
> +	     (not (eq org-agenda-diary-file 'diary-file)))
>      (local-set-key org-calendar-insert-diary-entry-key
>  		   #'org-agenda-diary-entry)))
>
>
>
> I have to admit, though, that I don't understand why the version with
> `unless' results in the bug, since in the recipes I gave
> org-agenda-diary-file is unbound and, indeed, when I instrument the
> unpatched org--setup-calendar-bindings and step through it on calling
> `calendar', the org-calendar-insert-diary-entry-key local-set-key call
> is skipped as expected.  But "c" does get locally set, so if I type `c'
> in the Calendar buffer, it displays the Org Agenda, and if I then type
> `i' in the Calendar buffer, I now get prompted with a choice menu for
> the type of diary entry, but whichever I choose, the result is the
> user-error "Don't know which date to use for diary entry", evidently
> because there is indeed no org-agenda-diary-file with the necessary text
> properties.  So somehow the "i" binding is made even though the code
> should prevent this (and does under Edebug but not when executed
> normally).
>
> With the above patch, after typing `c' in the Calendar buffer, `i' is
> still unbound, as it should be, but if I changed the value of
> org-agenda-diary-file from the default 'diary-file to some file, then
> `i' works with Org Agenda as documented.
>
> Steve Berman

On Thu, 24 Jun 2021 17:04:02 +0200 Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:

> Hello,
>
> Stephen Berman <stephen.berman@gmx.net> writes:
>
>> Yeah, the next time Org is merged to the Emacs master branch, forcing me
>> to first stash and then reapply my patch locally, I'll ask if anyone
>> objects to the patch being committed to master.
>
> Sure, go ahead.

Thanks, done in commit 19f2f26 on master.  Closing the bug.

Steve Berman


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

* Re: bug#48199: 28.0.50; Org mode surprisingly usurps Calendar key binding
  2021-08-27  3:37   ` Lars Ingebrigtsen
  2021-08-27  4:33     ` Yuchen Pei
@ 2021-08-27  6:42     ` tomas
  1 sibling, 0 replies; 6+ messages in thread
From: tomas @ 2021-08-27  6:42 UTC (permalink / raw)
  To: emacs-orgmode

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

On Fri, Aug 27, 2021 at 05:37:40AM +0200, Lars Ingebrigtsen wrote:
> Yuchen Pei <hi@ypei.me> writes:
> 
> >> This bug seems to be still around, as it just happened to me. Steps
> >> to
> >> reproduce:
> >>
> >> - Build a recent version e.g. commit efaed29f3d with `make`
> >> - ./src/emacs
> >> - M-x calendar RET
> >> - i
> >>
> >> results in "command-execute: Wrong type argument: commandp,
> >> org-agenda-diary-entry".  Can anyone else reproduce it?
> 
> I can't reproduce this with "emacs -Q", or after visiting etc/ORG-NEWS,
> with the current Emacs trunk.

FWIW, I've seen that problem too, but it seems fixed now (I'm running
currently commit fba64e1697174369b87e3de0c189a0fb0963c49c).

Cheers
 - t

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

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

* bug#48199: 28.0.50; Org mode surprisingly usurps Calendar key binding
  2021-08-27  3:37   ` Lars Ingebrigtsen
@ 2021-08-27  4:33     ` Yuchen Pei
  2021-08-27  6:42     ` tomas
  1 sibling, 0 replies; 6+ messages in thread
From: Yuchen Pei @ 2021-08-27  4:33 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 48199

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


Lars Ingebrigtsen <larsi@gnus.org> writes:

> Yuchen Pei <hi@ypei.me> writes:
>
>>> This bug seems to be still around, as it just happened to 
>>> me. Steps
>>> to
>>> reproduce:
>>>
>>> - Build a recent version e.g. commit efaed29f3d with `make`
>>> - ./src/emacs
>>> - M-x calendar RET
>>> - i
>>>
>>> results in "command-execute: Wrong type argument: commandp,
>>> org-agenda-diary-entry".  Can anyone else reproduce it?
>
> I can't reproduce this with "emacs -Q", or after visiting 
> etc/ORG-NEWS,
> with the current Emacs trunk.

You are right.  I add `-Q` to the emacs invocation and the problem 
is gone.  I'm gonna try to re-archive this bug.

-- 
Best,
Yuchen

PGP Key: 47F9 D050 1E11 8879 9040  4941 2126 7E93 EF86 DFD0
           <https://ypei.me/assets/ypei-pubkey.txt>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 243 bytes --]

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

* bug#48199: 28.0.50; Org mode surprisingly usurps Calendar key binding
  2021-08-27  3:32 ` Yuchen Pei
@ 2021-08-27  3:37   ` Lars Ingebrigtsen
  2021-08-27  4:33     ` Yuchen Pei
  2021-08-27  6:42     ` tomas
  0 siblings, 2 replies; 6+ messages in thread
From: Lars Ingebrigtsen @ 2021-08-27  3:37 UTC (permalink / raw)
  To: Yuchen Pei; +Cc: 48199

Yuchen Pei <hi@ypei.me> writes:

>> This bug seems to be still around, as it just happened to me. Steps
>> to
>> reproduce:
>>
>> - Build a recent version e.g. commit efaed29f3d with `make`
>> - ./src/emacs
>> - M-x calendar RET
>> - i
>>
>> results in "command-execute: Wrong type argument: commandp,
>> org-agenda-diary-entry".  Can anyone else reproduce it?

I can't reproduce this with "emacs -Q", or after visiting etc/ORG-NEWS,
with the current Emacs trunk.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




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

* bug#48199: 28.0.50; Org mode surprisingly usurps Calendar key binding
       [not found] <87eeagbr0l.fsf@ypei.me>
@ 2021-08-27  3:32 ` Yuchen Pei
  2021-08-27  3:37   ` Lars Ingebrigtsen
  0 siblings, 1 reply; 6+ messages in thread
From: Yuchen Pei @ 2021-08-27  3:32 UTC (permalink / raw)
  To: 48199

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

Looks like this email hadn't go through before I unarchived the 
bug.  Apologies for any duplicate messages.
Yuchen Pei <hi@ypei.me> writes:

> This bug seems to be still around, as it just happened to 
> me. Steps to
> reproduce:
>
> - Build a recent version e.g. commit efaed29f3d with `make`
> - ./src/emacs
> - M-x calendar RET
> - i
>
> results in "command-execute: Wrong type argument: commandp,
> org-agenda-diary-entry".  Can anyone else reproduce it?


-- 
Best,
Yuchen

PGP Key: 47F9 D050 1E11 8879 9040  4941 2126 7E93 EF86 DFD0
           <https://ypei.me/assets/ypei-pubkey.txt>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 243 bytes --]

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

end of thread, other threads:[~2021-08-27  6:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <87eeen243m.fsf@gmx.net>
2021-05-09 17:21 ` bug#48199: 28.0.50; Org mode surprisingly usurps Calendar key binding Stephen Berman
2021-06-25  9:15   ` Stephen Berman
     [not found] <87eeagbr0l.fsf@ypei.me>
2021-08-27  3:32 ` Yuchen Pei
2021-08-27  3:37   ` Lars Ingebrigtsen
2021-08-27  4:33     ` Yuchen Pei
2021-08-27  6:42     ` tomas

Code repositories for project(s) associated with this 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).