emacs-devel
[Top][All Lists]
Advanced

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

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


From: Alex Schroeder
Subject: Re: Customizing key bindings (was: Re: [CVS] f7, f8 bound..)
Date: Mon, 02 Sep 2002 23:55:16 +0200
User-agent: Gnus/5.090008 (Oort Gnus v0.08) Emacs/21.2.90 (i686-pc-linux-gnu)

Per Abrahamsen <address@hidden> writes:

> (defcustom global-key-bindings nil ...

Cool, it works (after adding a paren at the right place).  How about
this addition.  A side note: Why is the default value for function
types the string "ignore"?

Alex.

(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.

While entering the name of a key, you can either type keys yourself
just as they appear in the manual, as in C-c a.  You must use angle
brackets for function keys, as in <f7>.  The easiest thing is probably
to hit C-q and then just type the key.  C-q will insert the correct
string representation for you.

While entering the name of a command, you can use M-TAB to comlete
the function name."
  ;; Note that we cannot use \\[quoted-key-insert] because the keymap
  ;; is not the same.
  :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))

(defun quoted-key-insert (key)
  "Insert a string representation of the next key typed.
The string representation is a representation understood
by `read-kbd-macro'."
  (interactive "KPress a key: ")
  (insert (edmacro-format-keys key)))

(define-key custom-global-keymap (kbd "C-q") 'quoted-key-insert)

Alex.




reply via email to

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