unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Customize key bindings?
@ 2003-12-29 22:28 Simon Josefsson
  2003-12-30  2:17 ` Luc Teirlinck
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Simon Josefsson @ 2003-12-29 22:28 UTC (permalink / raw)


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 <simon@josefsson.org>

;; 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
;; (("<f5>" . compile)
;;  ("<f6>" . next-error)
;;  ("<f7>" . 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

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2004-01-03 23:25 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-12-29 22:28 Customize key bindings? Simon Josefsson
2003-12-30  2:17 ` Luc Teirlinck
2003-12-30 10:56   ` Simon Josefsson
2003-12-30 14:38 ` Alex Schroeder
2003-12-30 20:21   ` Simon Josefsson
2003-12-30 19:43 ` Richard Stallman
2003-12-30 20:34   ` Simon Josefsson
2004-01-02 16:11     ` Kai Grossjohann
2004-01-03 23:25 ` Simon Josefsson

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).