summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1997-06-27 06:04:19 +0000
committerRichard M. Stallman <rms@gnu.org>1997-06-27 06:04:19 +0000
commitd4b8422faf9bd0a39ef0ed66ae069bcc0a3331c7 (patch)
treeb24070079db53569489c1ad01dd3ccd3445bc66a /lisp
parent0f3335c0588bc816b3f2d09097dfcd2bf208af46 (diff)
downloademacs-d4b8422faf9bd0a39ef0ed66ae069bcc0a3331c7.tar.gz
(widget-choice-action): Use widget-edit-functions.
(widget-toggle-action): Likewise. (widget-choose): Use only digits, except for C-g. Allocate digits to disabled commands too. Don't use a keyboard menu; instead, display a buffer listing all the alternatives. Put cursor in echo area.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/wid-edit.el45
1 files changed, 24 insertions, 21 deletions
diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el
index e90d62e12b3..98fa79a327c 100644
--- a/lisp/wid-edit.el
+++ b/lisp/wid-edit.el
@@ -269,31 +269,34 @@ minibuffer."
;; Define SPC as a prefix char to get to this menu.
(define-key overriding-terminal-local-map " "
(setq map (make-sparse-keymap title)))
- (while items
- (setq choice (car items) items (cdr items))
- (if (consp choice)
- (let* ((name (car choice))
- (function (cdr choice))
- (character (aref name 0)))
- ;; Pick a character for this choice;
- ;; avoid duplication.
- (when (lookup-key map (vector character))
- (setq character (downcase character))
- (when (lookup-key map (vector character))
- (setq character next-digit
- next-digit (1+ next-digit))))
- (define-key map (vector character)
- (cons (format "%c = %s" character name) function)))))
- (define-key map [?\C-g] '("Quit" . keyboard-quit))
+ (save-excursion
+ (set-buffer (get-buffer-create " widget-choose"))
+ (erase-buffer)
+ (insert "Available choices:\n\n")
+ (while items
+ (setq choice (car items) items (cdr items))
+ (if (consp choice)
+ (let* ((name (car choice))
+ (function (cdr choice)))
+ (insert (format "%c = %s\n" next-digit name))
+ (define-key map (vector next-digit) function)))
+ ;; Allocate digits to disabled alternatives
+ ;; so that the digit of a given alternative never varies.
+ (setq next-digit (1+ next-digit)))
+ (insert "\nC-g = Quit"))
+ (define-key map [?\C-g] 'keyboard-quit)
(define-key map [t] 'keyboard-quit)
(setcdr map (nreverse (cdr map)))
;; Unread a SPC to lead to our new menu.
(setq unread-command-events (cons ?\ unread-command-events))
;; Read a char with the menu, and return the result
;; that corresponds to it.
- (setq value
- (lookup-key overriding-terminal-local-map
- (read-key-sequence title) t))
+ (save-window-excursion
+ (display-buffer (get-buffer " widget-choose"))
+ (let ((cursor-in-echo-area t))
+ (setq value
+ (lookup-key overriding-terminal-local-map
+ (read-key-sequence title) t))))
(when (eq value 'keyboard-quit)
(error "Canceled"))
value))))
@@ -1993,7 +1996,7 @@ when he invoked the menu."
(widget-get current :value)))
(widget-setup)
(widget-apply widget :notify widget event)))
- (run-hooks 'widget-edit-hook))
+ (run-hook-with-args 'widget-edit-functions widget))
(defun widget-choice-validate (widget)
;; Valid if we have made a valid choice.
@@ -2049,7 +2052,7 @@ when he invoked the menu."
;; Toggle value.
(widget-value-set widget (not (widget-value widget)))
(widget-apply widget :notify widget event)
- (run-hooks 'widget-edit-hook))
+ (run-hook-with-args 'widget-edit-functions widget))
;;; The `checkbox' Widget.