From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Per Abrahamsen Newsgroups: gmane.emacs.devel Subject: Re: Customizing key bindings Date: Sat, 07 Sep 2002 17:10:44 +0200 Organization: The Church of Emacs Sender: emacs-devel-admin@gnu.org Message-ID: References: <200208271621.g7RGLNm30516@rum.cs.yale.edu> <5xhehfe3aj.fsf@kfs2.cua.dk> <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 1031411525 26128 127.0.0.1 (7 Sep 2002 15:12:05 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sat, 7 Sep 2002 15:12:05 +0000 (UTC) Cc: emacs-devel@gnu.org Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 17nhFi-0006n5-00 for ; Sat, 07 Sep 2002 17:12:02 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 17nhoj-00037t-00 for ; Sat, 07 Sep 2002 17:48:13 +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 17nhFf-0003Oc-00; Sat, 07 Sep 2002 11:11:59 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10) id 17nhEc-0003Eu-00 for emacs-devel@gnu.org; Sat, 07 Sep 2002 11:10:54 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10) id 17nhEZ-00036a-00 for emacs-devel@gnu.org; Sat, 07 Sep 2002 11:10:53 -0400 Original-Received: from sheridan.dina.kvl.dk ([130.225.40.227]) by monty-python.gnu.org with esmtp (Exim 4.10) id 17nhEY-00035E-00 for emacs-devel@gnu.org; Sat, 07 Sep 2002 11:10:50 -0400 Original-Received: from zuse.dina.kvl.dk (zuse.dina.kvl.dk [130.225.40.245]) by sheridan.dina.kvl.dk (8.9.3/8.9.3/Debian 8.9.3-21) with ESMTP id RAA01646; Sat, 7 Sep 2002 17:10:48 +0200 Original-Received: (from abraham@localhost) by zuse.dina.kvl.dk (8.9.3+Sun/8.9.3) id RAA03464; Sat, 7 Sep 2002 17:10:44 +0200 (MEST) X-Authentication-Warning: zuse.dina.kvl.dk: abraham set sender to abraham@dina.kvl.dk using -f Original-To: Alex Schroeder X-Face: +kRV2]2q}lixHkE{U)mY#+6]{AH=yN~S9@IFiOa@X6?GM|8MBp/ In-Reply-To: <87lm6dkjf8.fsf_-_@emacswiki.org> (Alex Schroeder's message of "Sat, 07 Sep 2002 15:39:55 +0200") Original-Lines: 59 User-Agent: Gnus/5.090007 (Oort Gnus v0.07) Emacs/21.1 (sparc-sun-solaris2.8) 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:7698 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:7698 Alex Schroeder writes: > The problem with the code above is that none of the parents has a > correct :keymap property. What we need, here, is to either set an > appropriate property from custom-declare-keymap (how?), We probably should not use :keymap, as that already has a meaning for the ediatble-field widget, but somthing else, like :key-sequence-keymap. We should also allow a symbol, then the symbol value will be used. (defun key-sequence-value-create (widget) (let ((value (widget-default-get widget)) (map (or (widget-ancestor-get widget :key-sequence-keymap) (current-global-map))) (button (widget-create-child-and-convert widget '(key-sequence-button))) (field (widget-create-child-value widget '(key-sequence-field :format " %vOld binding: ") (widget-get widget :value)))) (when (symbolp map) (setq (map (symbol-value map)))) (let* ((command (condition-case nil (lookup-key map (read-kbd-macro value)) (error nil))) (binding (key-sequence-describe widget command))) (widget-put widget :children (list field)) (widget-put widget :buttons (list binding button))))) Then we can store it in the type: (defun custom-declare-keymap (symbol map doc &rest args) ;; cut (apply 'custom-declare-variable symbol map doc :type `(repeat :key-sequence-keymap ,symbol key-binding) :set 'custom-set-keymap :get 'custom-get-keymap args)) > or to search for something else: We need the first parent having a > :value property that is a keymap. What do you think? I think this is close to being a layer violation. The key-sequence widget can be useful in many other widget applications than customize, and looking in the :value field seem somewhat arbitrary. If this code ever gets accepted, all the widget stuff should go to wid-edit.el. > I have retained the alternative (current-global-map), but I don't know > when it would ever be used... If it ever got used, that would > indicate a bug to me. What do you think, Per? Maybe the default should be nil, meaning to use key-binding instead of lookup-key. For use outside customize.