* bug#39802: (info "(emacs) Init Rebinding") needs to say it is impossible to unbind local keys
@ 2020-02-26 15:48 積丹尼 Dan Jacobson
2020-02-26 16:17 ` Noam Postavsky
0 siblings, 1 reply; 13+ messages in thread
From: 積丹尼 Dan Jacobson @ 2020-02-26 15:48 UTC (permalink / raw)
To: 39802
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"
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#39802: (info "(emacs) Init Rebinding") needs to say it is impossible to unbind local keys
2020-02-26 15:48 bug#39802: (info "(emacs) Init Rebinding") needs to say it is impossible to unbind local keys 積丹尼 Dan Jacobson
@ 2020-02-26 16:17 ` Noam Postavsky
2020-02-26 16:31 ` 積丹尼 Dan Jacobson
0 siblings, 1 reply; 13+ messages in thread
From: Noam Postavsky @ 2020-02-26 16:17 UTC (permalink / raw)
To: 積丹尼 Dan Jacobson; +Cc: 39802
積丹尼 Dan Jacobson <jidanni@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?
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#39802: (info "(emacs) Init Rebinding") needs to say it is impossible to unbind local keys
2020-02-26 16:17 ` Noam Postavsky
@ 2020-02-26 16:31 ` 積丹尼 Dan Jacobson
2020-02-26 17:04 ` Noam Postavsky
0 siblings, 1 reply; 13+ messages in thread
From: 積丹尼 Dan Jacobson @ 2020-02-26 16:31 UTC (permalink / raw)
To: Noam Postavsky; +Cc: 39802
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.
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#39802: (info "(emacs) Init Rebinding") needs to say it is impossible to unbind local keys
2020-02-26 16:31 ` 積丹尼 Dan Jacobson
@ 2020-02-26 17:04 ` Noam Postavsky
2020-02-26 23:22 ` 積丹尼 Dan Jacobson
0 siblings, 1 reply; 13+ messages in thread
From: Noam Postavsky @ 2020-02-26 17:04 UTC (permalink / raw)
To: 積丹尼 Dan Jacobson; +Cc: 39802
積丹尼 Dan Jacobson <jidanni@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.
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#39802: (info "(emacs) Init Rebinding") needs to say it is impossible to unbind local keys
2020-02-26 17:04 ` Noam Postavsky
@ 2020-02-26 23:22 ` 積丹尼 Dan Jacobson
2020-02-27 13:14 ` Noam Postavsky
0 siblings, 1 reply; 13+ messages in thread
From: 積丹尼 Dan Jacobson @ 2020-02-26 23:22 UTC (permalink / raw)
To: Noam Postavsky; +Cc: 39802
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)))
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#39802: (info "(emacs) Init Rebinding") needs to say it is impossible to unbind local keys
2020-02-26 23:22 ` 積丹尼 Dan Jacobson
@ 2020-02-27 13:14 ` Noam Postavsky
2020-02-27 13:26 ` Robert Pluim
2020-02-28 7:52 ` Eli Zaretskii
0 siblings, 2 replies; 13+ messages in thread
From: Noam Postavsky @ 2020-02-27 13:14 UTC (permalink / raw)
To: 積丹尼 Dan Jacobson; +Cc: 39802
[-- Attachment #1: Type: text/plain, Size: 390 bytes --]
retitle 39802 (info "(emacs) Init Rebinding") doesn't explain how to unbind local keys
tags 39802 + patch
quit
積丹尼 Dan Jacobson <jidanni@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.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 2182 bytes --]
From 980d36d8748ff4598132b704487487691e165334 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@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
^ permalink raw reply related [flat|nested] 13+ messages in thread
* bug#39802: (info "(emacs) Init Rebinding") needs to say it is impossible to unbind local keys
2020-02-27 13:14 ` Noam Postavsky
@ 2020-02-27 13:26 ` Robert Pluim
2020-02-28 7:52 ` Eli Zaretskii
1 sibling, 0 replies; 13+ messages in thread
From: Robert Pluim @ 2020-02-27 13:26 UTC (permalink / raw)
To: Noam Postavsky; +Cc: 39802, 積丹尼 Dan Jacobson
>>>>> On Thu, 27 Feb 2020 08:14:56 -0500, Noam Postavsky <npostavs@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
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#39802: (info "(emacs) Init Rebinding") needs to say it is impossible to unbind local keys
2020-02-27 13:14 ` Noam Postavsky
2020-02-27 13:26 ` Robert Pluim
@ 2020-02-28 7:52 ` Eli Zaretskii
2020-02-28 8:48 ` Phil Sainty
2020-02-28 10:04 ` Noam Postavsky
1 sibling, 2 replies; 13+ messages in thread
From: Eli Zaretskii @ 2020-02-28 7:52 UTC (permalink / raw)
To: Noam Postavsky; +Cc: 39802, jidanni
> From: Noam Postavsky <npostavs@gmail.com>
> Date: Thu, 27 Feb 2020 08:14:56 -0500
> Cc: 39802@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.
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#39802: (info "(emacs) Init Rebinding") needs to say it is impossible to unbind local keys
2020-02-28 7:52 ` Eli Zaretskii
@ 2020-02-28 8:48 ` Phil Sainty
2020-02-28 12:30 ` 積丹尼 Dan Jacobson
2020-02-28 10:04 ` Noam Postavsky
1 sibling, 1 reply; 13+ messages in thread
From: Phil Sainty @ 2020-02-28 8:48 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 39802, Noam Postavsky, jidanni
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
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#39802: (info "(emacs) Init Rebinding") needs to say it is impossible to unbind local keys
2020-02-28 7:52 ` Eli Zaretskii
2020-02-28 8:48 ` Phil Sainty
@ 2020-02-28 10:04 ` Noam Postavsky
2020-02-28 12:56 ` Eli Zaretskii
1 sibling, 1 reply; 13+ messages in thread
From: Noam Postavsky @ 2020-02-28 10:04 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 39802, jidanni
Eli Zaretskii <eliz@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.)
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#39802: (info "(emacs) Init Rebinding") needs to say it is impossible to unbind local keys
2020-02-28 8:48 ` Phil Sainty
@ 2020-02-28 12:30 ` 積丹尼 Dan Jacobson
0 siblings, 0 replies; 13+ messages in thread
From: 積丹尼 Dan Jacobson @ 2020-02-28 12:30 UTC (permalink / raw)
To: Phil Sainty; +Cc: Noam Postavsky, 39802
>>>>> "PS" == Phil Sainty <psainty@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.
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#39802: (info "(emacs) Init Rebinding") needs to say it is impossible to unbind local keys
2020-02-28 10:04 ` Noam Postavsky
@ 2020-02-28 12:56 ` Eli Zaretskii
2020-03-04 3:13 ` Noam Postavsky
0 siblings, 1 reply; 13+ messages in thread
From: Eli Zaretskii @ 2020-02-28 12:56 UTC (permalink / raw)
To: Noam Postavsky; +Cc: 39802, jidanni
> From: Noam Postavsky <npostavs@gmail.com>
> Cc: 39802@debbugs.gnu.org, jidanni@jidanni.org
> Date: Fri, 28 Feb 2020 05:04:57 -0500
>
> Eli Zaretskii <eliz@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.
^ permalink raw reply [flat|nested] 13+ messages in thread
* bug#39802: (info "(emacs) Init Rebinding") needs to say it is impossible to unbind local keys
2020-02-28 12:56 ` Eli Zaretskii
@ 2020-03-04 3:13 ` Noam Postavsky
0 siblings, 0 replies; 13+ messages in thread
From: Noam Postavsky @ 2020-03-04 3:13 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 39802, jidanni
tags 39802 fixed
close 39802 27.1
quit
Eli Zaretskii <eliz@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
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2020-03-04 3:13 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-02-26 15:48 bug#39802: (info "(emacs) Init Rebinding") needs to say it is impossible to unbind local keys 積丹尼 Dan Jacobson
2020-02-26 16:17 ` Noam Postavsky
2020-02-26 16:31 ` 積丹尼 Dan Jacobson
2020-02-26 17:04 ` Noam Postavsky
2020-02-26 23:22 ` 積丹尼 Dan Jacobson
2020-02-27 13:14 ` Noam Postavsky
2020-02-27 13:26 ` Robert Pluim
2020-02-28 7:52 ` Eli Zaretskii
2020-02-28 8:48 ` Phil Sainty
2020-02-28 12:30 ` 積丹尼 Dan Jacobson
2020-02-28 10:04 ` Noam Postavsky
2020-02-28 12:56 ` Eli Zaretskii
2020-03-04 3:13 ` Noam Postavsky
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.