From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.help Subject: Re: unexpected result with keymap inheritance Date: Wed, 23 Nov 2016 08:42:42 -0500 Message-ID: References: <20161121002838.rkoniry5n6aemrzt@doriath.local> <87twb0sqnr.fsf@gmail.com> <871sy3jpu4.fsf@gmail.com> <87fumicynb.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1479920406 7479 195.159.176.226 (23 Nov 2016 17:00:06 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 23 Nov 2016 17:00:06 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) Cc: help-gnu-emacs@gnu.org To: Alex Kost Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Nov 23 18:00:01 2016 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c9ato-0000hy-HQ for geh-help-gnu-emacs@m.gmane.org; Wed, 23 Nov 2016 17:59:56 +0100 Original-Received: from localhost ([::1]:34958 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c9atr-0005LH-Gc for geh-help-gnu-emacs@m.gmane.org; Wed, 23 Nov 2016 11:59:59 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33211) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c9aob-0001am-7h for help-gnu-emacs@gnu.org; Wed, 23 Nov 2016 11:54:34 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c9aoZ-0000ZS-37 for help-gnu-emacs@gnu.org; Wed, 23 Nov 2016 11:54:33 -0500 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:28997) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c9aoY-0000XU-RI for help-gnu-emacs@gnu.org; Wed, 23 Nov 2016 11:54:30 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0CbAgALW9BX/0ahSC1dHAEBBAEBQYJsAQEBAQEehE2FUIRlpX+FEoIDhhYEAgKBaTkUAQIBAQEBAQEBXieEYgEBAwFWIwULCw4mEhQYDSSIVQi8VQEBAQcCASSKfYocBY8dijyHWJE1hguQSx42hG4ehgoBAQE X-IPAS-Result: A0CbAgALW9BX/0ahSC1dHAEBBAEBQYJsAQEBAQEehE2FUIRlpX+FEoIDhhYEAgKBaTkUAQIBAQEBAQEBXieEYgEBAwFWIwULCw4mEhQYDSSIVQi8VQEBAQcCASSKfYocBY8dijyHWJE1hguQSx42hG4ehgoBAQE X-IronPort-AV: E=Sophos;i="5.30,296,1470715200"; d="scan'208";a="280207613" Original-Received: from 45-72-161-70.cpe.teksavvy.com (HELO pastel.home) ([45.72.161.70]) by smtp.teksavvy.com with ESMTP; 23 Nov 2016 11:54:27 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id ABCBE64F9C; Wed, 23 Nov 2016 08:42:42 -0500 (EST) In-Reply-To: <87fumicynb.fsf@gmail.com> (Alex Kost's message of "Wed, 23 Nov 2016 12:51:20 +0300") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.181 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.emacs.help:111775 Archived-At: > Now what I want is just to remove "o" and "u" from > 'very-special-mode-map', so that my keys from 'special-mode-map' will > take precedence, but I can't do it, as with this: I see, yes, that makes sense. I suggest you `M-x report-emacs-bug` and ask for this feature. > I will get " is undefined", so I have to bind my keys to the same > commands in this new map again: > > (define-key very-special-mode-map (kbd "o") 'backward-char) > (define-key very-special-mode-map (kbd "u") 'forward-char) That's the obvious workaround, yes. It's not that terrible, but I agree it's less satisfactory. Another approach if you want these `o` and `u` bindings to apply in every special-mode buffer, is to do (defvar my-special-mode-bindings-map (let ((map (make-sparse-keymap))) (define-key map (kbd "o") 'backward-char) (define-key map (kbd "u") 'forward-char) map)) (define-minor-mode my-special-mode-bindings "Docstring") (add-hook 'special-mode-hook #'my-special-mode-bindings) so you don't have to go through every derivative of special-mode which rebinds those keys and unbind them in their map. Stefan