From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Simon Josefsson Newsgroups: gmane.emacs.devel Subject: Customize key bindings? Date: Mon, 29 Dec 2003 23:28:22 +0100 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1072737097 19933 80.91.224.253 (29 Dec 2003 22:31:37 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 29 Dec 2003 22:31:37 +0000 (UTC) Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Mon Dec 29 23:31:28 2003 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1Ab5v6-0002pI-00 for ; Mon, 29 Dec 2003 23:31:28 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1Ab5v6-0004Bt-00 for ; Mon, 29 Dec 2003 23:31:28 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1Ab6rI-0002WV-DK for emacs-devel@quimby.gnus.org; Mon, 29 Dec 2003 18:31:36 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1Ab6qI-0002ND-V0 for emacs-devel@gnu.org; Mon, 29 Dec 2003 18:30:34 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1Ab6ph-0002Iq-Dh for emacs-devel@gnu.org; Mon, 29 Dec 2003 18:30:30 -0500 Original-Received: from [217.13.230.178] (helo=yxa.extundo.com) by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.24) id 1Ab6pg-0002Et-Mn for emacs-devel@gnu.org; Mon, 29 Dec 2003 18:29:57 -0500 Original-Received: from latte.josefsson.org (yxa.extundo.com [217.13.230.178]) (authenticated bits=0) by yxa.extundo.com (8.12.10/8.12.10) with ESMTP id hBTMSMAU004694 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Mon, 29 Dec 2003 23:28:26 +0100 Original-To: emacs-devel@gnu.org X-Hashcash: 0:031229:emacs-devel@gnu.org:25d49769a0ab5b68 User-Agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:18903 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:18903 Any plans to support customization of key bindings? I have an idea for a custom-key.el that would allow users to add global key bindings via the customize interface. I suspect this is sufficient for many people. It would be sufficient for me. See below. Any further ideas? My needs are satisfied by this, but I'm sure it can be improved. Perhaps custom can be extended with a new type 'kbd' that can read a proper key sequence from the user directly. Looking into why the :set functions need to do set-default for customize-variable to pick up the currently set valued would be useful as well. (See comment about custom bug below.) ;;; custom-key.el --- Add global key bindings via custom interface. ;; Copyright (C) 2003 Free Software Foundation, Inc. ;; Author: Simon Josefsson ;; This file is part of GNU Emacs. ;; GNU Emacs is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 2, or (at your option) ;; any later version. ;; GNU Emacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to the ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, ;; Boston, MA 02111-1307, USA. ;;; Commentary: ;; Put this file in your load-path, and add (require 'custom-key) to ;; your .emacs. ;; ;; Run M-x customize-variable RET custom-key-alist RET and add some ;; key bindings, for example: ;; ;; custom-key-alist's value is ;; (("" . compile) ;; ("" . next-error) ;; ("" . previous-error) ;; ("C-x 4h" . gtk-doc-insert)) ;; ;; Restart Emacs and enjoy the new global key bindings. (defcustom custom-key-alist nil "Association list with key bindings and functions." :type '(alist :key-type (string :tag "Key") :value-type function) :set '(lambda (symbol keyalist) (set-default symbol keyalist) ;; work around custom bug (mapcar (lambda (key) (global-set-key (read-kbd-macro (car key)) (cdr key))) keyalist))) (provide 'custom-key) ;;; custom-key.el ends here