emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Customizing key bindings (was: Re: [CVS] f7, f8 bound..)


From: Per Abrahamsen
Subject: Customizing key bindings (was: Re: [CVS] f7, f8 bound..)
Date: Mon, 02 Sep 2002 18:40:03 +0200
User-agent: Gnus/5.090007 (Oort Gnus v0.07) Emacs/21.1 (sparc-sun-solaris2.8)

Here is a version that handle [DEL].

To test, evaluate the code, 

   M-x customize-option <ret> global-key-bindings <ret>

   Activate the [INS] button.

   Enter <f7> in the Key field and apropos in the Command field.

   Activate the [Set for Current Session] button

   Press <f7> to test.

   Activate the [DEL] button.

   Press <f7> to test.

Obviously the UI needs to be improved, but the basic mechanism (except
perhaps the use of use-global-map) should work.  A similar mechanism
can be used for the mode specific maps, instead of fiddling with
use-global-map, we would just change the mode to use
custom-my-mode-map directly.

(defvar custom-global-keymap (let ((map (make-sparse-keymap)))
                               (set-keymap-parent map global-map)
                               map)
  "Global keymap for use by customize.")

(defcustom global-key-bindings nil
  "Global keybindings defined through customize."
  :type '(repeat
          (group (string :tag "Key") (function))
  :set (lambda (sym val)
         (set-default sym val)
         (setq custom-global-keymap (make-sparse-keymap))
         (set-keymap-parent custom-global-keymap global-map)
         (mapc (lambda (bind)
                 (define-key custom-global-keymap (read-kbd-macro (car bind))
                   (cadr bind)))
               val)
         (use-global-map custom-global-keymap)
         val))







reply via email to

[Prev in Thread] Current Thread [Next in Thread]