[Top][All Lists]

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

Re: Customizing key bindings

From: Per Abrahamsen
Subject: Re: Customizing key bindings
Date: Sat, 07 Sep 2002 17:10:44 +0200
User-agent: Gnus/5.090007 (Oort Gnus v0.07) Emacs/21.1 (sparc-sun-solaris2.8)

Alex Schroeder <address@hidden> writes:

> The problem with the code above is that none of the parents has a
> correct :keymap property.  What we need, here, is to either set an
> appropriate property from custom-declare-keymap (how?), 

We probably should not use :keymap, as that already has a meaning for
the ediatble-field widget, but somthing else, like

We should also allow a symbol, then the symbol value will be used.

(defun key-sequence-value-create (widget)
  (let ((value (widget-default-get widget))
        (map (or (widget-ancestor-get widget :key-sequence-keymap)
        (button (widget-create-child-and-convert
                 widget '(key-sequence-button)))
        (field (widget-create-child-value
                widget '(key-sequence-field :format " %vOld binding: ")
                (widget-get widget :value))))
    (when (symbolp map)
      (setq (map (symbol-value map))))
    (let* ((command (condition-case nil
                        (lookup-key map (read-kbd-macro value))
                      (error nil)))
           (binding (key-sequence-describe widget command)))
      (widget-put widget :children (list field))
      (widget-put widget :buttons (list binding button)))))

Then we can store it in the type:

(defun custom-declare-keymap (symbol map doc &rest args)
  ;; cut
  (apply 'custom-declare-variable symbol map doc 
         :type `(repeat :key-sequence-keymap ,symbol key-binding)
         :set 'custom-set-keymap
         :get 'custom-get-keymap

> or to search for something else: We need the first parent having a
> :value property that is a keymap.  What do you think?

I think this is close to being a layer violation.  The key-sequence
widget can be useful in many other widget applications than customize,
and looking in the :value field seem somewhat arbitrary.

If this code ever gets accepted, all the widget stuff should go to

> I have retained the alternative (current-global-map), but I don't know
> when it would ever be used...  If it ever got used, that would
> indicate a bug to me.  What do you think, Per?

Maybe the default should be nil, meaning to use key-binding instead of
lookup-key.  For use outside customize.

reply via email to

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