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: Wed, 23 Nov 2016 12:51:20 +0300 Message-ID: <87fumicynb.fsf@gmail.com> References: <20161121002838.rkoniry5n6aemrzt@doriath.local> <87twb0sqnr.fsf@gmail.com> <871sy3jpu4.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1479894729 15086 195.159.176.226 (23 Nov 2016 09:52:09 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 23 Nov 2016 09:52:09 +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 10:52:05 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 1c9UDk-00034p-1k for geh-help-gnu-emacs@m.gmane.org; Wed, 23 Nov 2016 10:52:04 +0100 Original-Received: from localhost ([::1]:60580 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c9UDn-0007HO-7Q for geh-help-gnu-emacs@m.gmane.org; Wed, 23 Nov 2016 04:52:07 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43206) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c9UD5-0007Fg-5a for help-gnu-emacs@gnu.org; Wed, 23 Nov 2016 04:51:24 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c9UD2-0003eW-3g for help-gnu-emacs@gnu.org; Wed, 23 Nov 2016 04:51:23 -0500 Original-Received: from mail-wm0-x22f.google.com ([2a00:1450:400c:c09::22f]:36787) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c9UD1-0003e5-T6 for help-gnu-emacs@gnu.org; Wed, 23 Nov 2016 04:51:20 -0500 Original-Received: by mail-wm0-x22f.google.com with SMTP id g23so69884140wme.1 for ; Wed, 23 Nov 2016 01:51:19 -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=wU1W0FGuOt+wzAhGD2G46dUk8Ex78qTjNpFgHtkTzvk=; b=q8PLMCpdEmIQCItXpmcrcOcBmdAG/snvWojxSoHA7N0pBURRiAjtxvHPMIGtNTofTh V3ujZwOuGO/OaqXvufT2cfp59woaKThRJwEXIbcqrWUMRBIEaCuJJRYGWnzBzJp0+HdP rYUI78BQ5s9aouKfJMJGUJNuVuwBIdMiFlwfKgqq4ioQUTayS8ouArcWZGxHyRZj/1h3 5/Y7dq2IhG6ExtGITANRTNj6Lbiv1lJfKzpnman+dXMrcLX3p5aT4Exx94MNqW8G7J7D mIABiMan5QDFT5+FaAHjR9EcIG0BGlm4L+GgyySxdZ6jnpV7G0tFZGabtrIXq8QAO7xk xe5g== 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=wU1W0FGuOt+wzAhGD2G46dUk8Ex78qTjNpFgHtkTzvk=; b=Y1uahdcB7eRAdnPlBl9Kc8ZtG+9GcX/ISlBZ/nXnKx879u47ZU1GwuPqVYAVWCXM5a T2MDd7fbneET9mfZENHIXdQqr6EH0+p9FxaDR9XQWzXp62vFi8Fc/li3SpIw+0m6i/xQ d056qKgKIZ7+DrQEkLfFrnwX7NkgJ40mYddy6/lBVLu3qH2qNZ97bsHGcHVlpDNtlMHM 0iyBbe3/aFZx+cPKGrrXMeqcLF5MrVkQCILkUCkJouUdTSyeMe7M4vzXdq0/EQN9LgBa R7aR5jY8ft/jJeK6pO7DaH1OIiXgmjCMdCcr168/dPewP5EsLwd9/CdPZTwkTWEkLVpa gT9Q== X-Gm-Message-State: AKaTC0264Jetb6UXZe/60HSAJ0XNEHNzuU0EMM50r8WIYH37inFOWjXKE6XfUYkxU8OcpQ== X-Received: by 10.25.19.220 with SMTP id 89mr72850lft.179.1479894678520; Wed, 23 Nov 2016 01:51:18 -0800 (PST) Original-Received: from leviafan ([217.107.192.156]) by smtp.gmail.com with ESMTPSA id u63sm7007024lja.34.2016.11.23.01.51.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Nov 2016 01:51:17 -0800 (PST) In-Reply-To: (Stefan Monnier's message of "Tue, 22 Nov 2016 20:12:18 -0500") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::22f 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:111772 Archived-At: Stefan Monnier (2016-11-22 20:12 -0500) wrote: >> Well, yes, I think I do something very unusual: I rebind hundreds and >> hundreds of default key bindings. > > While it's not usual to do that for hundreds of them, rebinding is > normal, so it's something we want to (and do) support. > >> And my use case is: I often want to just remove a key from some map so >> that a key from its parent map will take precedence. > > Do you have a more concrete description of when you want to do that? Here is an example. I want to use some strange keys in all the modes that derive from 'special-mode', so I do this: (define-key special-mode-map (kbd "o") 'backward-char) (define-key special-mode-map (kbd "u") 'forward-char) OK, so far so good, but then I face some mode that also binds these keys: --8<---------------cut here---------------start------------->8--- (defvar very-special-mode-map (let ((map (make-sparse-keymap))) (set-keymap-parent map special-mode-map) (define-key map (kbd "o") 'find-file) (define-key map (kbd "u") 'undo) map)) (define-derived-mode very-special-mode special-mode "Very Special") --8<---------------cut here---------------end--------------->8--- 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: (define-key very-special-mode-map (kbd "o") nil) (define-key very-special-mode-map (kbd "u") nil) 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) I met the described case pretty often, and I really miss this "remove key" functionality. It would be really convenient for me if I could do: (remove-key ) or since I want to unbind many keys: (dolist (key ) (remove-key key)) -- Alex