all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Noam Postavsky <npostavs@gmail.com>
To: "積丹尼 Dan Jacobson" <jidanni@jidanni.org>
Cc: 39802@debbugs.gnu.org
Subject: bug#39802: (info "(emacs) Init Rebinding") needs to say it is impossible to unbind local keys
Date: Thu, 27 Feb 2020 08:14:56 -0500	[thread overview]
Message-ID: <87eeug9nov.fsf@gmail.com> (raw)
In-Reply-To: <871rqh0w9p.5.fsf@jidanni.org> ("積丹尼 Dan Jacobson"'s message of "Thu, 27 Feb 2020 07:22:10 +0800")

[-- 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


  reply	other threads:[~2020-02-27 13:14 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87eeug9nov.fsf@gmail.com \
    --to=npostavs@gmail.com \
    --cc=39802@debbugs.gnu.org \
    --cc=jidanni@jidanni.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.