From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Alex Schroeder Newsgroups: gmane.emacs.devel Subject: Re: Customizing key bindings Date: Tue, 10 Sep 2002 19:57:27 +0200 Sender: emacs-devel-admin@gnu.org Message-ID: <87k7ltiv7c.fsf@emacswiki.org> References: <20020903130247.GA6318@gnu.org> <20020903173120.GA29981@gnu.org> <87ptvttnyo.fsf@emacswiki.org> <200209061736.g86HaDi00352@rum.cs.yale.edu> <874rd1ki2s.fsf_-_@emacswiki.org> <20020907234343.GC26845@gnu.org> NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1031680649 18213 127.0.0.1 (10 Sep 2002 17:57:29 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Tue, 10 Sep 2002 17:57:29 +0000 (UTC) Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 17opGS-0004jW-00 for ; Tue, 10 Sep 2002 19:57:28 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 17opqy-0001UZ-00 for ; Tue, 10 Sep 2002 20:35:12 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 17opG5-0008Hz-00; Tue, 10 Sep 2002 13:57:05 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10) id 17opE8-00083Y-00 for emacs-devel@gnu.org; Tue, 10 Sep 2002 13:55:04 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10) id 17opE5-00082X-00 for emacs-devel@gnu.org; Tue, 10 Sep 2002 13:55:03 -0400 Original-Received: from relay01.cablecom.net ([62.2.33.101]) by monty-python.gnu.org with esmtp (Exim 4.10) id 17opE4-000825-00 for emacs-devel@gnu.org; Tue, 10 Sep 2002 13:55:00 -0400 Original-Received: from smtp.swissonline.ch (mail-4.swissonline.ch [62.2.32.85]) by relay01.cablecom.net (8.12.5/8.12.5/SOL/AWF/MXRELAY/20020820) with ESMTP id g8AHsw20001197 for ; Tue, 10 Sep 2002 19:54:58 +0200 (CEST) (envelope-from alex@emacswiki.org) Original-Received: from confusibombus (dclient217-162-239-98.hispeed.ch [217.162.239.98]) by smtp.swissonline.ch (8.11.6/8.11.6/SMTPSOL/AWF/2002040101) with ESMTP id g8AHswF01621 for ; Tue, 10 Sep 2002 19:54:58 +0200 (MEST) Original-Received: from alex by confusibombus with local (Exim 3.35 #1 (Debian)) id 17opGR-0000E2-00 for ; Tue, 10 Sep 2002 19:57:27 +0200 Original-To: emacs-devel@gnu.org X-Face: ^BC$`[IcggstLPyen&dqF+b2'zyK#r.mU*'Nms}@&4zw%SJ#5!/7SMVjBS7'lb;QK)|IPU5U'o1'522W4TyzB3Ab*IBo^iw]l4|kUbdZuUDO6=Um-.4IzhNiV'B"@K#jy_(wW|Zbk[34flKY^|PrQ?$u2\fKg^]AY>wOX#H32i In-Reply-To: (Richard Stallman's message of "Mon, 09 Sep 2002 19:33:44 -0400") Original-Lines: 62 User-Agent: Gnus/5.090008 (Oort Gnus v0.08) Emacs/21.2.90 (i686-pc-linux-gnu) Errors-To: emacs-devel-admin@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.devel:7814 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:7814 My code implements #2. The reason for choosing that approach are trivial: I don't want to touch the C code, so changing define-key is out of the question (for me). Now, if #2 had been difficult to do, then we would have returned to #1. But #2 was rather easy to do. This is why I see no reason to do #1 at the moment. I realize this is not a real argument. :) It just seems more pragmatic at the moment. Alex. Richard Stallman writes: > Another question is `if there the implementation uses two keymaps > (either for nesting at lookup time, or just for bookkeeping purposes), > where is the second one stored?' I really dislike your idea of having > two separate lisp variable to store them. > > In my two-keymap proposal, the second one is found only as the parent > of the first. The first is marked somehow as a customization keymap > so that define-key knows to keep moving and define in its parent. > > My two-keymap proposal is #1 below. > > ====================================================================== > Here's what I think the :set for a keymap should do. > Actually, I have two alternative ideas: > > 1. Create a new keymap, as above, but make its parent be > the keymap that was the value of SYM before. Put the > symbol `custom' in the keymap to mark it as made here. > > If Custom had already run and done this, strip off the > keymap it made before, and make a new one. > > Change define-key so that it skips that keymap and makes the change in > the parent. > > Now all changes made outside Custom will be permanent. However, the > bindings specified with Custom will shadow those changes. In some > cases the user might not like that, but I don't see that any > alternative is clearly better. > > [In fact, it seems to me that this is more correct than any other > alternative.] > > 2. Instead of making a new keymap, just install the changes in the > original keymap, saving the original definitions. > > More precisely, here's what :set would do: > > * Reinstall all the saved original bindings > > * For each key that has a Custom key binding, > save is current binding. > > * Install the Custom key bindings. > > This way, changes made outside Custom all take effect immediately. > If the key has no Custom binding, the change is permanent. > If the key does have a Custom binding, the change is lost when > Custom runs again, but maybe that is reasonable in this case.