GNU bug report logs -
#39802
(info "(emacs) Init Rebinding") doesn't explain how to unbind local keys
Previous Next
Reported by: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
Date: Wed, 26 Feb 2020 15:49:01 UTC
Severity: wishlist
Tags: fixed, patch
Merged with 39630
Fixed in version 27.1
Done: Noam Postavsky <npostavs <at> gmail.com>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 39802 in the body.
You can then email your comments to 39802 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#39802
; Package
emacs
.
(Wed, 26 Feb 2020 15:49:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Wed, 26 Feb 2020 15:49:01 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
On(info "(emacs) Init Rebinding")
at the end, please have the page "admit" that their is no way to unbind a key from a
local map. That would save the user a lot of guessing.
Currently the page just ends in an example of binding a key in a local
map. Users need to know it is in fact impossible to unbind them.
https://stackoverflow.com/questions/22834506/how-to-unset-a-keybinding-in-a-map-locally-to-a-mode
https://github.com/jwiegley/use-package/issues/103
emacs-version "26.3"
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#39802
; Package
emacs
.
(Wed, 26 Feb 2020 16:18:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 39802 <at> debbugs.gnu.org (full text, mbox):
積丹尼 Dan Jacobson <jidanni <at> jidanni.org> writes:
> On(info "(emacs) Init Rebinding")
> at the end, please have the page "admit" that their is no way to unbind a key from a
> local map.
Your terminology is a bit confusing here. From this description I might
think that you are looking for local-unset-key (that is, "local map" ==
current major mode map, which is how the manual is using it). But based
on the links you posted, I guess you are actually talking about the lack
of buffer-local keymap values?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#39802
; Package
emacs
.
(Wed, 26 Feb 2020 16:33:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 39802 <at> debbugs.gnu.org (full text, mbox):
If
C-. runs the command flyspell-auto-correct-word (found in
flyspell-mode-map), which is an interactive compiled Lisp function in
‘flyspell.el’.
It is bound to C-., C-M-i.
And the user wants to unbind it, well,
(info "(emacs) Init Rebinding")
won't break the bad news to him that it is just not possible.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#39802
; Package
emacs
.
(Wed, 26 Feb 2020 17:05:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 39802 <at> debbugs.gnu.org (full text, mbox):
積丹尼 Dan Jacobson <jidanni <at> jidanni.org> writes:
> If
>
> C-. runs the command flyspell-auto-correct-word (found in
> flyspell-mode-map), which is an interactive compiled Lisp function in
> ‘flyspell.el’.
>
> It is bound to C-., C-M-i.
>
> And the user wants to unbind it, well,
> (info "(emacs) Init Rebinding")
> won't break the bad news to him that it is just not possible.
If I understood correctly, then
(define-key flyspell-mode-map (kbd "C-.") nil)
would work.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#39802
; Package
emacs
.
(Wed, 26 Feb 2020 23:23:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 39802 <at> debbugs.gnu.org (full text, mbox):
OK!
Please add this patch (i.e., fix the source file) to
(info "(emacs) Init Rebinding")
For example, Texinfo mode runs the hook ‘texinfo-mode-hook’. Here’s
-how you can use the hook to add local bindings for ‘C-c n’ and ‘C-c p’
-in Texinfo mode:
+how you can use the hook to add local bindings for ‘C-c n’ and ‘C-c p’,
+and remove one for C-c C-c x, in Texinfo mode:
(add-hook 'texinfo-mode-hook
(lambda ()
(define-key texinfo-mode-map "\C-cp"
'backward-paragraph)
(define-key texinfo-mode-map "\C-cn"
- 'forward-paragraph)))
-
+ 'forward-paragraph)
+ (define-key texinfo-mode-map "\C-c\C-cx"
+ nil)))
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#39802
; Package
emacs
.
(Thu, 27 Feb 2020 13:16:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 39802 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
retitle 39802 (info "(emacs) Init Rebinding") doesn't explain how to unbind local keys
tags 39802 + patch
quit
積丹尼 Dan Jacobson <jidanni <at> jidanni.org> writes:
> OK!
> Please add this patch (i.e., fix the source file) to
> (info "(emacs) Init Rebinding")
I think it would be useful to explain what to do outside of the example,
so I propose a slightly different patch.
[0001-Explain-how-to-unset-mode-bindings-Bug-39802.patch (text/x-diff, inline)]
From 980d36d8748ff4598132b704487487691e165334 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs <at> gmail.com>
Date: Thu, 27 Feb 2020 08:09:44 -0500
Subject: [PATCH] Explain how to unset mode bindings (Bug#39802)
* doc/emacs/custom.texi (Init Rebinding): Explain that passing nil to
define-key will unbind keys, and extend the example accordingly.
---
doc/emacs/custom.texi | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/doc/emacs/custom.texi b/doc/emacs/custom.texi
index f39ce40931..5232ab5cc7 100644
--- a/doc/emacs/custom.texi
+++ b/doc/emacs/custom.texi
@@ -1873,15 +1873,18 @@ Init Rebinding
Language and coding systems may cause problems with key bindings for
non-@acronym{ASCII} characters. @xref{Init Non-ASCII}.
+@findex define-key
As described in @ref{Local Keymaps}, major modes and minor modes can
-define local keymaps. These keymaps are constructed when the mode is
-used for the first time in a session. If you wish to change one of
-these keymaps, you must use the @dfn{mode hook} (@pxref{Hooks}).
+define local keymaps. The function @code{define-key} can be used to
+make changes in a specific keymap. This function can also unset keys,
+when passed @code{nil} as the binding.
-@findex define-key
- For example, Texinfo mode runs the hook @code{texinfo-mode-hook}.
-Here's how you can use the hook to add local bindings for @kbd{C-c n}
-and @kbd{C-c p} in Texinfo mode:
+ Since a mode's keymaps are not constructed until it has been loaded,
+you must delay running code which modifies them until, e.g., by
+putting it no a @dfn{mode hook} (pxref{(Hooks)}). For example,
+Texinfo mode runs the hook @code{texinfo-mode-hook}. Here's how you
+can use the hook to add local bindings for @kbd{C-c n} and @kbd{C-c
+p}, and remove the one for @kbd{C-c C-x x} in Texinfo mode:
@example
(add-hook 'texinfo-mode-hook
@@ -1890,6 +1893,7 @@ Init Rebinding
'backward-paragraph)
(define-key texinfo-mode-map "\C-cn"
'forward-paragraph)))
+ (define-key texinfo-mode-map "\C-c\C-xx" nil)
@end example
@node Modifier Keys
--
2.11.0
Changed bug title to '(info "(emacs) Init Rebinding") doesn't explain how to unbind local keys' from '(info "(emacs) Init Rebinding") needs to say it is impossible to unbind local keys'
Request was from
Noam Postavsky <npostavs <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Thu, 27 Feb 2020 13:16:02 GMT)
Full text and
rfc822 format available.
Added tag(s) patch.
Request was from
Noam Postavsky <npostavs <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Thu, 27 Feb 2020 13:16:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#39802
; Package
emacs
.
(Thu, 27 Feb 2020 13:27:01 GMT)
Full text and
rfc822 format available.
Message #27 received at 39802 <at> debbugs.gnu.org (full text, mbox):
>>>>> On Thu, 27 Feb 2020 08:14:56 -0500, Noam Postavsky <npostavs <at> gmail.com> said:
The text looks good, except for...
Noam> -@findex define-key
Noam> - For example, Texinfo mode runs the hook @code{texinfo-mode-hook}.
Noam> -Here's how you can use the hook to add local bindings for @kbd{C-c n}
Noam> -and @kbd{C-c p} in Texinfo mode:
Noam> + Since a mode's keymaps are not constructed until it has been loaded,
Noam> +you must delay running code which modifies them until, e.g., by
Noam> +putting it no a @dfn{mode hook} (pxref{(Hooks)}). For example,
^^
Robert
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#39802
; Package
emacs
.
(Fri, 28 Feb 2020 07:53:02 GMT)
Full text and
rfc822 format available.
Message #30 received at 39802 <at> debbugs.gnu.org (full text, mbox):
> From: Noam Postavsky <npostavs <at> gmail.com>
> Date: Thu, 27 Feb 2020 08:14:56 -0500
> Cc: 39802 <at> debbugs.gnu.org
>
> +@findex define-key
> As described in @ref{Local Keymaps}, major modes and minor modes can
> -define local keymaps. These keymaps are constructed when the mode is
> -used for the first time in a session. If you wish to change one of
> -these keymaps, you must use the @dfn{mode hook} (@pxref{Hooks}).
> +define local keymaps. The function @code{define-key} can be used to
> +make changes in a specific keymap. This function can also unset keys,
> +when passed @code{nil} as the binding.
This loses useful information in the sentence that starts with "These
keymaps".
Otherwise I'm okay with the proposed change.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#39802
; Package
emacs
.
(Fri, 28 Feb 2020 08:49:02 GMT)
Full text and
rfc822 format available.
Message #33 received at 39802 <at> debbugs.gnu.org (full text, mbox):
Perhaps my answer at https://stackoverflow.com/a/13966287/324105
also provides some helpful wording? (It can be appropriated for
the manual if it's useful.)
-Phil
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#39802
; Package
emacs
.
(Fri, 28 Feb 2020 10:06:03 GMT)
Full text and
rfc822 format available.
Message #36 received at 39802 <at> debbugs.gnu.org (full text, mbox):
Eli Zaretskii <eliz <at> gnu.org> writes:
>> As described in @ref{Local Keymaps}, major modes and minor modes can
>> -define local keymaps. These keymaps are constructed when the mode is
>> -used for the first time in a session.
> This loses useful information in the sentence that starts with "These
> keymaps".
I moved that information to the next paragraph:
+ Since a mode's keymaps are not constructed until it has been loaded,
(I think "until it has been loaded" is more accurate than "used for the
first time", since the file can be loaded without actually using the
mode defined within.)
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#39802
; Package
emacs
.
(Fri, 28 Feb 2020 12:31:01 GMT)
Full text and
rfc822 format available.
Message #39 received at 39802 <at> debbugs.gnu.org (full text, mbox):
>>>>> "PS" == Phil Sainty <psainty <at> orcon.net.nz> writes:
PS> Perhaps my answer at https://stackoverflow.com/a/13966287/324105
PS> also provides some helpful wording? (It can be appropriated for
PS> the manual if it's useful.)
So maybe the patch should say "in addition to
(define-key ...-map ... nil)
one can use
(local-set-key ... ... ...)"
I suppose. But maybe it is "less powerful" but I don't know.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#39802
; Package
emacs
.
(Fri, 28 Feb 2020 12:57:01 GMT)
Full text and
rfc822 format available.
Message #42 received at 39802 <at> debbugs.gnu.org (full text, mbox):
> From: Noam Postavsky <npostavs <at> gmail.com>
> Cc: 39802 <at> debbugs.gnu.org, jidanni <at> jidanni.org
> Date: Fri, 28 Feb 2020 05:04:57 -0500
>
> Eli Zaretskii <eliz <at> gnu.org> writes:
>
> >> As described in @ref{Local Keymaps}, major modes and minor modes can
> >> -define local keymaps. These keymaps are constructed when the mode is
> >> -used for the first time in a session.
>
> > This loses useful information in the sentence that starts with "These
> > keymaps".
>
> I moved that information to the next paragraph:
>
> + Since a mode's keymaps are not constructed until it has been loaded,
I saw it, but that "Since" strikes me as "a bolt out of the blue",
because no text before that explained or mentioned this fact. Leaving
that sentence in place will then go a long way towards making the
"Since" part crystal clear.
IOW, in this and similar cases, repetition facilitates understanding,
and should not be avoided, because we are dealing with something that
won't necessarily be evident to the reader.
> (I think "until it has been loaded" is more accurate than "used for the
> first time", since the file can be loaded without actually using the
> mode defined within.)
I'm okay with rephrasing the original sentence along these lines. But
I think we should not remove it entirely. (Obviously, this is a minor
point.)
Thanks.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#39802
; Package
emacs
.
(Sat, 29 Feb 2020 04:53:02 GMT)
Full text and
rfc822 format available.
Message #45 received at 39802 <at> debbugs.gnu.org (full text, mbox):
Actually 39802 solves the need for 39630 and 39631.
Forcibly Merged 39630 39802.
Request was from
Noam Postavsky <npostavs <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Sat, 29 Feb 2020 05:01:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#39802
; Package
emacs
.
(Sat, 29 Feb 2020 05:19:02 GMT)
Full text and
rfc822 format available.
Message #50 received at 39802 <at> debbugs.gnu.org (full text, mbox):
NP> I don't know about 39631
OK, I suppose to solve 39631 somebody could use the lisp equivalent of
for(all the keys present in a given keymap){use the method of 39802 to unbind it}
So maybe document that in some elisp manual or something, mentioning
that maybe there is no way to zap the whole keymap with one line of lisp(?).
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#39802
; Package
emacs
.
(Sat, 29 Feb 2020 05:24:02 GMT)
Full text and
rfc822 format available.
Message #53 received at 39802 <at> debbugs.gnu.org (full text, mbox):
Noam Postavsky <npostavs <at> gmail.com> writes:
> I don't know about 39631, but 39630 is clearly the same as 39802 (I did
> have a feeling of familiarity when I initially read that one), so it
> doesn't make sense to mark it as wontfix when we are actually fixing it.
Thanks. I had missed the ongoing work in Bug#39802.
Best regards,
Stefan Kangas
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#39802
; Package
emacs
.
(Wed, 04 Mar 2020 03:14:02 GMT)
Full text and
rfc822 format available.
Message #56 received at 39802 <at> debbugs.gnu.org (full text, mbox):
tags 39802 fixed
close 39802 27.1
quit
Eli Zaretskii <eliz <at> gnu.org> writes:
> I saw it, but that "Since" strikes me as "a bolt out of the blue",
> because no text before that explained or mentioned this fact. Leaving
> that sentence in place will then go a long way towards making the
> "Since" part crystal clear.
>
> IOW, in this and similar cases, repetition facilitates understanding,
> and should not be avoided, because we are dealing with something that
> won't necessarily be evident to the reader.
Okay, I see what you mean. I put that sentence back in (with "used"
changed to "loaded") and pushed to emacs-27.
[1: 60418a1ab2]: 2020-03-03 22:04:48 -0500
Explain how to unset mode bindings (Bug#39802)
https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=60418a1ab21b86cb2d46470ae187e74a25d33212
Added tag(s) fixed.
Request was from
Noam Postavsky <npostavs <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Wed, 04 Mar 2020 03:14:02 GMT)
Full text and
rfc822 format available.
bug marked as fixed in version 27.1, send any further explanations to
39802 <at> debbugs.gnu.org and 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
Request was from
Noam Postavsky <npostavs <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Wed, 04 Mar 2020 03:14:02 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Wed, 01 Apr 2020 11:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 5 years and 78 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.