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 00:06:39 +0200 Sender: emacs-devel-admin@gnu.org Message-ID: <871y827r80.fsf@emacswiki.org> References: <200208271621.g7RGLNm30516@rum.cs.yale.edu> <874rdfaytt.fsf@pot.cnuce.cnr.it> <5xvg5sh06u.fsf@kfs2.cua.dk> <20020830235528.GA13207@gnu.org> <87ofbji88u.fsf@emacswiki.org> <87sn0scb0b.fsf@emacswiki.org> <87bs7ama8g.fsf@emacswiki.org> <87lm6dkjf8.fsf_-_@emacswiki.org> NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1031609190 29861 127.0.0.1 (9 Sep 2002 22:06:30 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 9 Sep 2002 22:06:30 +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 17oWft-0007lV-00 for ; Tue, 10 Sep 2002 00:06:29 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 17oXG0-0006pY-00 for ; Tue, 10 Sep 2002 00:43:48 +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 17oWfo-0002n3-00; Mon, 09 Sep 2002 18:06:24 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10) id 17oWdj-0002eh-00 for emacs-devel@gnu.org; Mon, 09 Sep 2002 18:04:15 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10) id 17oWdh-0002eV-00 for emacs-devel@gnu.org; Mon, 09 Sep 2002 18:04:14 -0400 Original-Received: from relay01.cablecom.net ([62.2.33.101]) by monty-python.gnu.org with esmtp (Exim 4.10) id 17oWdg-0002eR-00 for emacs-devel@gnu.org; Mon, 09 Sep 2002 18:04:13 -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 g89M4B20034425 for ; Tue, 10 Sep 2002 00:04:11 +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 g89M4BF10713 for ; Tue, 10 Sep 2002 00:04:11 +0200 (MEST) Original-Received: from alex by confusibombus with local (Exim 3.35 #1 (Debian)) id 17oWg3-00006b-00 for ; Tue, 10 Sep 2002 00:06:39 +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: (Per Abrahamsen's message of "Sat, 07 Sep 2002 17:10:44 +0200") Original-Lines: 54 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:7767 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:7767 I included the changes by Per for the :key-sequence-keymap property, reverted my changes to widget-get-ancestor, etc. I also allow nil for the command widget, atm. Perhaps a better solution needs to be found (a choice widget?). The benefit of allowing nil is that this automatically results in that key being undefined (since the code eventually calls define-key with DEF being nil). I like this much better than having two lists, one with keys to add and one with keys to remove... While playing around with emacs-lisp-mode-map (see below), I was still vexed a few times. At one time, it seemed that setting customizations for the current session did not change the keybindings for all emacs-lisp-mode buffers. I had to run M-x emacs-lisp-mode to achieve that. The next time it worked, however. Adding bindings, deleting them again, and defining them to nil seemed to work as well, but suddenly I had a situation where I thought I had undone all customizations, but my test-key still had one of the bindings I had added before. So I hope other people will take the example below and spend a few minutes fooling around with it. To test saving and loading, I proceeded as follows, with an emacs that had no customizations set and custom-file set to "~/.custom.el". Store the value of a keymap in a variable. Load the code. (setq test emacs-lisp-mode-map) (load-file "~/elisp/cus-key.el") Now simulate a call to defkeymap. (defkeymap emacs-lisp-mode-map test "foo") Customize it, add a new keybinding, save for future sessions. (customize-option 'emacs-lisp-mode-map) Now save the following in test.el and start emacs -q -l test.el: (require 'lisp-mode) (setq test emacs-lisp-mode-map) (load-file "~/elisp/cus-key.el") (defkeymap emacs-lisp-mode-map test "foo") (load-file "~/.custom.el") ;; (customize-option 'emacs-lisp-mode-map) The new emacs-lisp-mode-map should contain your new binding, and it should be customizable. Now switch between the Customization buffer and *scratch* to test stuff using C-h k. Alex.