From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.bugs 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 Message-ID: <87eeug9nov.fsf@gmail.com> References: <87blplic2s.5.fsf@jidanni.org> <85ftex9vc0.fsf@gmail.com> <8736axia2u.5.fsf@jidanni.org> <85d0a19t6i.fsf@gmail.com> <871rqh0w9p.5.fsf@jidanni.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="89836"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) Cc: 39802@debbugs.gnu.org To: =?UTF-8?Q?=E7=A9=8D=E4=B8=B9=E5=B0=BC?= Dan Jacobson Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Feb 27 14:16:14 2020 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 1j7J1Q-000NGh-If for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 27 Feb 2020 14:16:12 +0100 Original-Received: from localhost ([::1]:59410 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7J1P-0001aL-HV for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 27 Feb 2020 08:16:11 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56710) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7J1H-0001Yg-LS for bug-gnu-emacs@gnu.org; Thu, 27 Feb 2020 08:16:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j7J1G-0000sZ-I9 for bug-gnu-emacs@gnu.org; Thu, 27 Feb 2020 08:16:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:52867) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j7J1G-0000sU-D3 for bug-gnu-emacs@gnu.org; Thu, 27 Feb 2020 08:16:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1j7J1G-00012R-8P for bug-gnu-emacs@gnu.org; Thu, 27 Feb 2020 08:16:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 27 Feb 2020 13:16:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 39802 X-GNU-PR-Package: emacs Original-Received: via spool by 39802-submit@debbugs.gnu.org id=B39802.15828093053889 (code B ref 39802); Thu, 27 Feb 2020 13:16:02 +0000 Original-Received: (at 39802) by debbugs.gnu.org; 27 Feb 2020 13:15:05 +0000 Original-Received: from localhost ([127.0.0.1]:58840 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j7J0K-00010a-Sa for submit@debbugs.gnu.org; Thu, 27 Feb 2020 08:15:05 -0500 Original-Received: from mail-qk1-f169.google.com ([209.85.222.169]:46655) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j7J0J-0000zl-IK; Thu, 27 Feb 2020 08:15:03 -0500 Original-Received: by mail-qk1-f169.google.com with SMTP id u124so2962264qkh.13; Thu, 27 Feb 2020 05:15:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=GLC7sicfrpEsaKIdbtQ8b83wr3kgXKYopSBXJ+H8Z+4=; b=d8st+AHr8vHND/Db1I4u962c33E8zY+dFKexEbvQsyw+sJjG78pBi9SbiX4YG1ZSY7 IPnDd4DmS37U8AY2rK2T16Ov9czuz3ovdFUeDlKnqP5qVv8QTjsxOFIRO2OSvrrOGtgM 2FQ3lrtAg9tFll7OBxYzw+GKqXy22pus2Mq2orIq5+CAGGl7h0Nw5teOel4WD7q/5Cgk C0E/y0Sw10xos/+KKthkCw1V/jbtWJJw2gjIYBpB2Fd0wHp2IswwTvmBIV3+BmxePy2o 57AuEtLWRW5UynGn5eVQoXpv9QJbkEROdj6lunGkCnsaEhto3itJrxCyhey7nJsB6Y4h IXZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=GLC7sicfrpEsaKIdbtQ8b83wr3kgXKYopSBXJ+H8Z+4=; b=c+roqPIYHpgiayulHwqI8X+XdSov4oB6WoHlAoQwHw7QK7nkZsn1uLmbxOV5jazwl+ iuro6E+0mk/ZIvvT/NNcq5Xjf3DNF1MEvhVeBUIFK8nah8oQbJ5itPyzcXGN34UctSLb DM+rfBY/j54kWhQdh7anQPpLEWq80XAmF4agleiUeCWf5VxrwiGPYjmBXc9fOuRLjUVF bQAEdxrJmXo0MgCAR9tEXBUZYhq5LimYvL/WeMGZCY+7lPcTFgSRgyO2ggwe/xf6gS1+ ssYJKHX07rAxfysfZ3hBnNT1YcA5IraFGEOiQoxyoEhkE3m3Bk5qUf/4IxS/l9Zlmgs6 2eyg== X-Gm-Message-State: APjAAAX5VU6eZXiJAl2RtqWaFtLzMkCYVFYgTWpvzqn1pVnrUDJujVLK EBTfWCVNjTKICGK4dZBVlIWcdK8YGdI= X-Google-Smtp-Source: APXvYqyGzC58Ym1AGhHecjDDmStfuIePukgd59zz81Xk8BA715cfme3HBGmJ94R0C8605/UYSdviSw== X-Received: by 2002:a37:816:: with SMTP id 22mr5189221qki.455.1582809298069; Thu, 27 Feb 2020 05:14:58 -0800 (PST) Original-Received: from minid (cbl-45-2-119-47.yyz.frontiernetworks.ca. [45.2.119.47]) by smtp.gmail.com with ESMTPSA id i28sm3204930qtc.57.2020.02.27.05.14.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Feb 2020 05:14:57 -0800 (PST) In-Reply-To: <871rqh0w9p.5.fsf@jidanni.org> ("=?UTF-8?Q?=E7=A9=8D=E4=B8=B9=E5=B0=BC?= Dan Jacobson"'s message of "Thu, 27 Feb 2020 07:22:10 +0800") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 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:176529 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable retitle 39802 (info "(emacs) Init Rebinding") doesn't explain how to unbind= local keys tags 39802 + patch quit =E7=A9=8D=E4=B8=B9=E5=B0=BC Dan Jacobson 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. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Explain-how-to-unset-mode-bindings-Bug-39802.patch Content-Description: patch >From 980d36d8748ff4598132b704487487691e165334 Mon Sep 17 00:00:00 2001 From: Noam Postavsky 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 --=-=-=--