]> git.eshelyaron.com Git - emacs.git/commitdiff
(key-sequence): New widget type.
authorRichard M. Stallman <rms@gnu.org>
Thu, 3 Nov 2005 21:46:16 +0000 (21:46 +0000)
committerRichard M. Stallman <rms@gnu.org>
Thu, 3 Nov 2005 21:46:16 +0000 (21:46 +0000)
lisp/wid-edit.el

index 064725c8bfe2c5d7e112c87f111917b6ea3224e5..5f5d3479547421daa645f04f842bdff9879203c8 100644 (file)
@@ -3116,7 +3116,7 @@ It will read a directory name from the minibuffer when invoked."
                       (interactive)
                       (lisp-complete-symbol 'boundp))
   :tag "Variable")
-
+\f
 (defvar widget-coding-system-prompt-value-history nil
   "History of input to `widget-coding-system-prompt-value'.")
 
@@ -3159,6 +3159,29 @@ It will read a directory name from the minibuffer when invoked."
     (widget-apply widget :notify widget event)
     (widget-setup)))
 \f
+(defvar widget-key-sequence-prompt-value-history nil
+  "History of input to `widget-key-sequence-prompt-value'.")
+
+;; This mostly works, but I am pretty sure it needs more change
+;; to be 100% correct.  I don't know what the change should be -- rms.
+
+(define-widget 'key-sequence 'restricted-sexp
+  "A Lisp function."
+  :prompt-value 'widget-field-prompt-value
+  :prompt-internal 'widget-symbol-prompt-internal
+  :prompt-match 'fboundp
+  :prompt-history 'widget-key-sequence-prompt-value-history
+  :action 'widget-field-action
+  :match-alternatives '(stringp vectorp)
+  :validate (lambda (widget)
+             (unless (or (stringp (widget-value widget))
+                         (vectorp (widget-value widget)))
+               (widget-put widget :error (format "Invalid key sequence: %S"
+                                                 (widget-value widget)))
+               widget))
+  :value 'ignore
+  :tag "Key sequence")
+\f
 (define-widget 'sexp 'editable-field
   "An arbitrary Lisp expression."
   :tag "Lisp expression"