From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alex Kost Newsgroups: gmane.emacs.help Subject: Re: Redefine the `special-mode-map' Date: Fri, 09 Jan 2015 17:46:13 +0300 Message-ID: <87a91sau6i.fsf@gmail.com> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1420815068 7291 80.91.229.3 (9 Jan 2015 14:51:08 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 9 Jan 2015 14:51:08 +0000 (UTC) Cc: help-gnu-emacs To: Alexander Shukaev Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Jan 09 15:51:02 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Y9api-0000a8-8h for geh-help-gnu-emacs@m.gmane.org; Fri, 09 Jan 2015 15:46:38 +0100 Original-Received: from localhost ([::1]:50937 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y9aph-0002d5-Oy for geh-help-gnu-emacs@m.gmane.org; Fri, 09 Jan 2015 09:46:37 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57642) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y9apV-0002cz-32 for help-gnu-emacs@gnu.org; Fri, 09 Jan 2015 09:46:26 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y9apO-0006cv-Ia for help-gnu-emacs@gnu.org; Fri, 09 Jan 2015 09:46:25 -0500 Original-Received: from mail-lb0-x235.google.com ([2a00:1450:4010:c04::235]:59402) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y9apO-0006cq-Bh for help-gnu-emacs@gnu.org; Fri, 09 Jan 2015 09:46:18 -0500 Original-Received: by mail-lb0-f181.google.com with SMTP id l4so8425748lbv.12 for ; Fri, 09 Jan 2015 06:46:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=BP3tuw0wEUwzCizRUKy/a3OuFQeigdDAHziWgPOlbjA=; b=HD+nEFcNUOZPE4AHpR2zzE8vCoDEMgYdRujO0u7hBWSO7jCWVaklMFPQHzYkV072FK aR7eMCxCwA1Ap0X9eJxJZHzKuXK+XNVOe49PHAozixHv1XaSe1bp14R/Cx8ls4PeBFhz GVsSYXuQqN+XC6Em1L418ilbSRdNtLR4hoGHAGRfiaciMWYWi2tdrvFMmO0mTZaEovSa KzvKvqLjUJP5GOWWgpGn4xKVRvYEbLOJD+ic5K/dFR/AJ4INSTOjOsktGgJrYXBVUy/t VoUicTpD+Z8F+Ej2C4LQiVIlhSUX+Fbp2sRShM8qzWFNRgg8YUnVfAq5KxmUXglPwSps SzZA== X-Received: by 10.152.87.46 with SMTP id u14mr21919572laz.36.1420814776460; Fri, 09 Jan 2015 06:46:16 -0800 (PST) Original-Received: from leviafan ([217.107.192.158]) by mx.google.com with ESMTPSA id o7sm1914505lao.3.2015.01.09.06.46.14 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Jan 2015 06:46:15 -0800 (PST) In-Reply-To: (Alexander Shukaev's message of "Fri, 9 Jan 2015 05:26:41 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c04::235 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:101964 Archived-At: Alexander Shukaev (2015-01-09 07:26 +0300) wrote: > Hello everyone, > > I'd like to redefine the `special-mode-map'. Accordingly, in the very > beginning of my Emacs configuration I've added the following code: > > (let ((keymap (make-sparse-keymap))) > (suppress-keymap keymap) > (define-key keymap (kbd "q") #'quit-window) > (define-key keymap (kbd "r") #'revert-buffer) > (setq special-mode-map keymap)) > > I assume that all the modes which are either derived from `special-mode' or > have `special-mode-map' as a parent to their respective maps should indeed > inherit the above key bindings. > > However, this is not the case. [C-h][b] shows that the above code had no > effect and that the default value of `special-mode-map' was still used as a > parent to construct child maps. In contrast, to complicate things, > [C-h][v]special-mode-map shows that `special-mode-map' contains all the > above changes. So what is going on? How to solve this problem? The problem is you set the whole map variable to a new value. If you really need to "kill" all the bindings there, you may do it like this: (setcdr special-mode-map nil) And then use your: (define-key special-mode-map (kbd "q") #'quit-window) ... But do not set `special-mode-map' to another value. -- Alex