From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Alex Kost Newsgroups: gmane.emacs.help Subject: Re: unexpected result with keymap inheritance Date: Thu, 24 Nov 2016 00:23:39 +0300 Message-ID: <87a8cplwkk.fsf@gmail.com> 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 1479936254 8001 195.159.176.226 (23 Nov 2016 21:24:14 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 23 Nov 2016 21:24:14 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.95 (gnu/linux) Cc: help-gnu-emacs@gnu.org To: Stefan Monnier Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Nov 23 22:24:10 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 1c9f1V-0000xu-O3 for geh-help-gnu-emacs@m.gmane.org; Wed, 23 Nov 2016 22:24:09 +0100 Original-Received: from localhost ([::1]:36458 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c9f1Z-0001rR-8P for geh-help-gnu-emacs@m.gmane.org; Wed, 23 Nov 2016 16:24:13 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38365) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c9f19-0001rM-Vs for help-gnu-emacs@gnu.org; Wed, 23 Nov 2016 16:23:49 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c9f15-0000Xl-1y for help-gnu-emacs@gnu.org; Wed, 23 Nov 2016 16:23:47 -0500 Original-Received: from mail-lf0-x232.google.com ([2a00:1450:4010:c07::232]:35974) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c9f14-0000WO-QI for help-gnu-emacs@gnu.org; Wed, 23 Nov 2016 16:23:42 -0500 Original-Received: by mail-lf0-x232.google.com with SMTP id t196so13877513lff.3 for ; Wed, 23 Nov 2016 13:23:42 -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; bh=kheunn3yAsDlIt/WeqGcc3EuU9Au/8nj2VXHw/ZXv4I=; b=uQJ8tj6ERRwxnb3hT6k9wtwRY4lH9QgPHBQqIXAG8a+tmv6bKUtjQtPkXiiknoVKKC DSF+asm09YXhWNouHLxevaZgpl3MbO+R5il9zWXQr4SzaepKTMS1xtWbgJAY5AUVcMFp mhJMLgjalEXSZYPwDqJF84sK9z6wyWIx2UEYAYbhrSlpp2cL5QEATDbTdfna1eiopmt4 Z8+yXQzZjlcjt/UFgAdmapjBW8/M4aTWcAxv+S6Gl9ZdKodpVsilcLDG/WvRPSnlDeLX 0RrQnICzZ89Gh1t3WhMI2ZIDO3ZYVsTv0L8QoUaOkY0jsIF3+7Y0kBaVnzv1iY/rBwYX Bd1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=kheunn3yAsDlIt/WeqGcc3EuU9Au/8nj2VXHw/ZXv4I=; b=F9AJjWmUnQBYMw/2+T/nmOugqs3J2WVP3U+Tflxtc3xQSbPzrVol2bRMrOZVg4BrKj 7806sIqRCIGRkW2bpRfd0BLQnNUEdZhk1O1wL8VsT7HCe3jSGXv4Cd+xvvGQq5d/GfI5 BqluATrhQCCuc+71S+6u6q2JV9Kl2KsqkjMO04GSXKRrGKrYJplf0eymgpM9cNlRIfnc lQJ5QhTW4WqnKXEQwVudFKKlHQyj0sjlk5j7NdbFlikCfRoytlcAAQ9RdkONRzcjRQlq lXcqM7SjQKqRV1Nydkh+saovHuqPHMCmtoLi7pT8HyufPiBithr33+CU6nMbGuiCEkX3 wszg== X-Gm-Message-State: AKaTC038B047HxsEDks+fL6N/v+ANsmBZ6joKvtfjChtnxGCiu3uh6cUBNW7nLT0NTPEoA== X-Received: by 10.25.5.7 with SMTP id 7mr1563079lff.125.1479936220940; Wed, 23 Nov 2016 13:23:40 -0800 (PST) Original-Received: from leviafan ([217.107.192.156]) by smtp.gmail.com with ESMTPSA id h30sm7578243lji.28.2016.11.23.13.23.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Nov 2016 13:23:40 -0800 (PST) In-Reply-To: (Stefan Monnier's message of "Wed, 23 Nov 2016 08:42:42 -0500") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c07::232 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:111778 Archived-At: Stefan Monnier (2016-11-23 08:42 -0500) wrote: >> 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. Thanks, but there are tons of Emacs bugs, and I wouldn't like to bother you and other contributors with just another feature request. >> 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. Yes, I thought about this variant some time ago, but it doesn't suit my needs. In reality I want something more complex than the described example. Like, in a couple of modes (derived from special-mode), I want to use other commands for "o"/"u" keys, so I can bind them as usual. But if I used a minor mode, its keys would take precedence over the major modes, so I would have another problem. Also I rebind many keys in many minor modes, and these keys would surely conflict with the keys from my minor modes that I would define as you suggest. But thanks for your answers! I really appreciate that you spent your time on my question. -- Alex