From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stephen Berman Newsgroups: gmane.emacs.bugs Subject: bug#48199: 28.0.50; Org mode surprisingly usurps Calendar key binding Date: Sun, 09 May 2021 19:21:31 +0200 Message-ID: <878s4nomas.fsf__4958.63219709776$1620581082$gmane$org@gmx.net> References: <87eeen243m.fsf@gmx.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16955"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) To: 48199@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun May 09 19:24:38 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lfnAS-0004IM-Ue for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 09 May 2021 19:24:37 +0200 Original-Received: from localhost ([::1]:59570 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lfnAS-0004Vm-0l for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 09 May 2021 13:24:36 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34992) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lfn7y-0001G8-Kt; Sun, 09 May 2021 13:22:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:44880) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lfn7y-0007ex-C9; Sun, 09 May 2021 13:22:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lfn7y-0006PN-7H; Sun, 09 May 2021 13:22:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stephen Berman Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, emacs-orgmode@gnu.org Resent-Date: Sun, 09 May 2021 17:22:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48199 X-GNU-PR-Package: emacs,org-mode X-Debbugs-Original-Cc: emacs-orgmode@gnu.org Original-Received: via spool by 48199-submit@debbugs.gnu.org id=B48199.162058090424617 (code B ref 48199); Sun, 09 May 2021 17:22:02 +0000 Original-Received: (at 48199) by debbugs.gnu.org; 9 May 2021 17:21:44 +0000 Original-Received: from localhost ([127.0.0.1]:56424 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lfn7g-0006Oz-1s for submit@debbugs.gnu.org; Sun, 09 May 2021 13:21:44 -0400 Original-Received: from mout.gmx.net ([212.227.17.22]:60865) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lfn7b-0006Ot-WD for 48199@debbugs.gnu.org; Sun, 09 May 2021 13:21:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1620580894; bh=tkpTp0oUrFuyx7jVWFud3kN3HD2OaIY1qY6SMGisd04=; h=X-UI-Sender-Class:From:To:Cc:Subject:References:Date:In-Reply-To; b=fooRshISv3SiXj5SOSUonyFceNbQh7/12B2Nt0zB0ck+7CfZNdVYZX6XfPu3AqIuv /o8+68UmgjF6fkzwu/Uu1WD4BBCacbln0yFsMzrp/twHEyPZSIGZVocn6CNMaApgxt wsnxNN+lX8j37K4DMLOgFd8Wup9irskQCknzF4Uk= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from strobe-jhalfs ([188.109.201.244]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MpUUm-1lA2nx3BVc-00pv01; Sun, 09 May 2021 19:21:33 +0200 In-Reply-To: <87eeen243m.fsf@gmx.net> (Stephen Berman's message of "Mon, 03 May 2021 18:07:25 +0200") X-Provags-ID: V03:K1:34zAiCTSWsdxswe9y4MBJE0GRnKdEPnGPvf7R6yRt8fnnlPYV/L Qjzels3zkyLzgh2Rbx+KGaCr5ZZSHORgtd4089TeHm6Nqz/tT/ZygN9Fm9/s8uJJ3DTyplk S/rTjTQiOaNuXxKbgjUEJhBo/59BDnMf9xJ26zwzQxkMiv2hyK6COdUdEU8Hq1s3cqWWFEB 2CsTCcY1DLMIKk5JG2yRg== X-UI-Out-Filterresults: notjunk:1;V03:K0:PkWXqQh4bKY=:2oDJAj2wf3ICCvnxtrKnVN WOWf6zmzlLeEAhdrLGdTJ3tDvYRcqy1nD49LBBSTaGytqvcEZormlST9qJ61586D7A//Tj9YU 2CQJCYtwr/i+H78plVpWjZN7mnsw3qaGlA6V+ynQx2qV8b9uPh34Iy/KgXvftlVOjHr/CS2pl /iYmyUewaTRwMJZNfV90p0PV7/dJMhQnDT3pxqUPe7wXWW0k9kqWhEJuxkgNVsME9HFHcoipU WxNY6y9tqwcDgBzsSLy/vW50FxmjCQfaCIQWNIhAIpVjQKaKuIRdZS4ZdM5jqG5FcG25ok92f 7sdnTJptUMsoWPTJdrHW+7dYpEgyncLZ8TzgqH24JvpN59KegdPhrwtYH1I7Nh22wyhMP13Ls UikOpncEuKBNyfWbBdJ1GVeELYqgBoaLFAly0NjGPF39W+ORT0kq6m6MiXA88/9M/PDK2mwT6 +L13jn3lWo9n8c80qeJs0pAoPNo9VlxLeeL81TLn0u3rS2yLirXKrS3+hg6PUDYMVR2N8nYjm 7hQqr7NXbLlusvYKhszuTQgJIlAErL4FprQb4xlrLPwzefSj/MJDMlRMdrovE7Umm/ed83n98 PgVTUUwLvv7Z70ui5p75g6s71fWbOqNajTcZ6EnRyFNM+rCTpqJP0oy91YVLyuJRAhmAW1Adr +HUB56boEBIhtvoMMm+5mXkTcXGMcGmIPC0bsLUzf7NRulQGJDG+hGKX2SHiv7uGI93z9wSoQ Zlicy/n969qo+vdzNmmHGBdinyX7RWaMusD5zLLctpANw3qTGQwSzx7ZQrjhijYSNnjITXsH X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:206097 Archived-At: --=-=-= Content-Type: text/plain [I added emacs-orgmode@gnu.org in the Cc:] On Mon, 03 May 2021 18:07:25 +0200 Stephen Berman 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: --=-=-= Content-Type: text/x-patch Content-Disposition: inline Content-Description: org-compat.el patch Content-Transfer-Encoding: quoted-printable diff --git a/lisp/org/org-compat.el b/lisp/org/org-compat.el index 1f4e2e8308..b68e5b58fc 100644 =2D-- 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))) --=-=-= Content-Type: text/plain 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 --=-=-=--