From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Klaus-Dieter Bauer Newsgroups: gmane.emacs.help Subject: Re: Customizing per-keymap key bindings through the customize interface? Date: Thu, 27 Jun 2013 16:36:59 +0200 Message-ID: References: <8c49d765-2115-4db3-8507-b6f2c991d547@default> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1372343870 31455 80.91.229.3 (27 Jun 2013 14:37:50 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 27 Jun 2013 14:37:50 +0000 (UTC) Cc: emacs help To: Drew Adams Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jun 27 16:37:52 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UsDKa-0001dM-8X for geh-help-gnu-emacs@m.gmane.org; Thu, 27 Jun 2013 16:37:52 +0200 Original-Received: from localhost ([::1]:51856 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UsDKZ-0006J9-Rb for geh-help-gnu-emacs@m.gmane.org; Thu, 27 Jun 2013 10:37:51 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52175) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UsDKI-0006BY-1P for help-gnu-emacs@gnu.org; Thu, 27 Jun 2013 10:37:37 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UsDKE-0001Nx-9r for help-gnu-emacs@gnu.org; Thu, 27 Jun 2013 10:37:33 -0400 Original-Received: from mail-ve0-x22f.google.com ([2607:f8b0:400c:c01::22f]:62893) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UsDKE-0001Ns-4N for help-gnu-emacs@gnu.org; Thu, 27 Jun 2013 10:37:30 -0400 Original-Received: by mail-ve0-f175.google.com with SMTP id da11so740647veb.34 for ; Thu, 27 Jun 2013 07:37:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=Z/lZf/wF3SOnOMVMr24URfoQ5OM57TxijpxAjHRDtZU=; b=dmzolYFAlH35GkUdO9mGtQLCcIaLdwwN91LoFDGoftR5YFk+aa06Mfgo+Erp004cgD GWjVpZyOldZQWYbiPK5Xe2kGZTyjVZjzznAc7efhwr9EYnli2GSxMzhI2KIv9B13lxVS ua0SW+GjGe1/lYRt4opzWxwrFf/D2K+uQbvZawY0SrSQZZG72TJm05BJ2seB+hXu6hCv vFEdhOCEo+v4qSEs9ZSwkCqciuL2PD12Jr14TT8n4FoZTvf8+SBIBEUWYnvyaV6CEFl/ S02WMo46bgOzke5vx9DLhX+6H/VysI3PEhNgvVaaBxBnXDCEPtV4lQ0bhssu/xXr+slT tKWA== X-Received: by 10.58.146.196 with SMTP id te4mr3597563veb.62.1372343849644; Thu, 27 Jun 2013 07:37:29 -0700 (PDT) Original-Received: by 10.220.224.73 with HTTP; Thu, 27 Jun 2013 07:36:59 -0700 (PDT) In-Reply-To: <8c49d765-2115-4db3-8507-b6f2c991d547@default> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400c:c01::22f X-Content-Filtered-By: Mailman/MimeDel 2.1.14 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 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-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:91777 Archived-At: Thanks, that helped already. Bottomline: No, none exists, writing such a solution is not a waste of time. On a related note, is there some widget-type that allows handling invalid entries preventing display of the bare s-expression, when e.g. only one entry of an alist is not a cons? I thought of something like (choice INTENDED-TYPE (sexp :tag "Invalid entry")) but I'd rather have a solution where no dropdown menu is shown when the value is valid. kind regards, Klaus-Dieter Bauer 2013/6/27 Drew Adams > > Is there currently some package available that allows managing custom > > key bindings on a per-keymap-basis through the `customize` interface? > > Not really, AFAIK. But there might be some related discussion on > emacs-devel or the Emacs bug list. > > > I got a bit annoyed recently by losing track of all the custom > > keybindings I have made, so I wrote a function, that automatically > > adds an entry in a menu in global-map for every custom keybinding. > > Now I am intending to extend this to utilizing the custom interface for > > creating keybindings on a per-mode basis. > > > > While relatively easy to do, I'd prefer a commonly used solution, if > > there is any. > > > > PS: I'm still not sure whether such questions should go to emacs-help or > > emacs-devel. > > Either is probably OK in this case. emacs-devel might be a bit better, > since this would be a new development/feature. But with help-gnu-emacs > you might get more info about existing 3rd-party features. You can also > file Emacs enhancement requests, using `M-x report-emacs-bug'. > > > FWIW, I sometimes provide user options that have key-binding values. > Not a complete solution, but it can make things easier. > > For example, option `icicle-top-level-key-bindings' is an alist whose > entries are of defcustom :type `icicle-key-definition', which means that > they have the form (KEY COMMAND CONDITION), where KEY is either a key > sequence (string or vector) to bind COMMAND to or a command to remap > to COMMAND. COMMAND is bound according to the value of KEY, unless the > result of evaluating CONDITION is nil. > > In Customize, to specify a key sequence, you choose `Key' in the `Value > Menu', then enter a key description such as that returned by `C-h k'. > For convenience, you can also insert a key in the key description by > hitting `C-q' then the key. For example, to enter the key description > `C-c M-k' you can use `C-q C-c C-q M-k'. > > Attached is what key bindings look like in Customize. > > In Lisp (e.g., to define the default value for a key-binding option), > an unconditional key binding looks like this: > ("\C-c=" icicle-imenu t) > > A conditional key binding looks like this: > ([f10] lacarte-execute-menu-command > (fboundp 'lacarte-execute-menu-command)) > > A conditional binding that remaps another command looks like this: > (bmkp-tag-a-file icicle-tag-a-file (fboundp 'bmkp-tag-a-file)) > > KEY can also be expressed using `kbd', of course: > `(,(kbd "C-c =") icicle-imenu t) > or > (list (kbd "C-c =") 'icicle-imenu t) > > > This is the code that defines custom type `icicle-key-definition': > > (define-widget 'icicle-key-definition 'lazy > "Key definition type for Icicle mode keys. > A list of three components: KEY, COMMAND, CONDITION, that represents > an `icicle-mode-map' binding of COMMAND according to KEY, if CONDITION > evaluates to non-nil. > > KEY is either a key sequence (string or vector) or a command. > COMMAND is a command. > CONDITION is a sexp. > > If KEY is a command, then the binding represented is its remapping to > COMMAND." > :indent 1 :offset 0 :tag "" > :type > '(list > (choice > (key-sequence :tag "Key" :value [ignore]) > ;; Use `symbolp' instead of `commandp', > ;; in case the library defining the command is not loaded. > (restricted-sexp :tag "Command to remap" > :match-alternatives (symbolp) :value ignore)) > ;; Use `symbolp' instead of `commandp'... > (restricted-sexp :tag "Command" > :match-alternatives (symbolp) :value ignore) > (sexp :tag "Condition"))) > > The code is here: > http://www.emacswiki.org/emacs-en/download/icicles-opt.el > > HTH.