unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Simon Josefsson <jas@extundo.com>
Subject: Customize key bindings?
Date: Mon, 29 Dec 2003 23:28:22 +0100	[thread overview]
Message-ID: <ilu7k0f1cop.fsf@latte.josefsson.org> (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

             reply	other threads:[~2003-12-29 22:28 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-12-29 22:28 Simon Josefsson [this message]
2003-12-30  2:17 ` Customize key bindings? 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ilu7k0f1cop.fsf@latte.josefsson.org \
    --to=jas@extundo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).