Commit 2a06fc15 authored by Nicolas Richard's avatar Nicolas Richard
Browse files

(widget-choose) Let numeric keypad work

Fixes: debbugs:19268

* wid-edit.el (widget-choose): Let numeric keypad work
and remove old menu-related code.
parent 3f199630
2014-12-05 Nicolas Richard <theonewiththeevillook@yahoo.fr>
* wid-edit.el (widget-choose): Let numeric keypad work (bug#19268)
and remove old menu-related code.
2014-12-05 Lars Magne Ingebrigtsen <larsi@gnus.org> 2014-12-05 Lars Magne Ingebrigtsen <larsi@gnus.org>
   
* net/eww.el (eww-display-pdf): Let mailcap determine how to * net/eww.el (eww-display-pdf): Let mailcap determine how to
......
...@@ -232,23 +232,20 @@ minibuffer." ...@@ -232,23 +232,20 @@ minibuffer."
(t (t
;; Construct a menu of the choices ;; Construct a menu of the choices
;; and then use it for prompting for a single character. ;; and then use it for prompting for a single character.
(let* ((overriding-terminal-local-map (make-sparse-keymap)) (let* ((next-digit ?0)
(next-digit ?0) (map (make-sparse-keymap))
map choice some-choice-enabled value) choice some-choice-enabled value)
;; Define SPC as a prefix char to get to this menu.
(define-key overriding-terminal-local-map " "
(setq map (make-sparse-keymap title)))
(with-current-buffer (get-buffer-create " widget-choose") (with-current-buffer (get-buffer-create " widget-choose")
(erase-buffer) (erase-buffer)
(insert "Available choices:\n\n") (insert "Available choices:\n\n")
(while items (while items
(setq choice (car items) items (cdr items)) (setq choice (pop items))
(if (consp choice) (when (consp choice)
(let* ((name (car choice)) (let* ((name (car choice))
(function (cdr choice))) (function (cdr choice)))
(insert (format "%c = %s\n" next-digit name)) (insert (format "%c = %s\n" next-digit name))
(define-key map (vector next-digit) function) (define-key map (vector next-digit) function)
(setq some-choice-enabled t))) (setq some-choice-enabled t)))
;; Allocate digits to disabled alternatives ;; Allocate digits to disabled alternatives
;; so that the digit of a given alternative never varies. ;; so that the digit of a given alternative never varies.
(setq next-digit (1+ next-digit))) (setq next-digit (1+ next-digit)))
...@@ -257,43 +254,29 @@ minibuffer." ...@@ -257,43 +254,29 @@ minibuffer."
(forward-line)) (forward-line))
(or some-choice-enabled (or some-choice-enabled
(error "None of the choices is currently meaningful")) (error "None of the choices is currently meaningful"))
(define-key map [?\C-g] 'keyboard-quit)
(define-key map [t] 'keyboard-quit)
(define-key map [?\M-\C-v] 'scroll-other-window) (define-key map [?\M-\C-v] 'scroll-other-window)
(define-key map [?\M--] 'negative-argument) (define-key map [?\M--] 'negative-argument)
(setcdr map (nreverse (cdr map)))
;; Read a char with the menu, and return the result
;; that corresponds to it.
(save-window-excursion (save-window-excursion
(let ((buf (get-buffer " widget-choose"))) (let ((buf (get-buffer " widget-choose")))
(fit-window-to-buffer (display-buffer buf)) (fit-window-to-buffer (display-buffer buf))
(let ((cursor-in-echo-area t) (let ((cursor-in-echo-area t)
keys
(char 0)
(arg 1)) (arg 1))
(while (not (or (and (integerp char) (while (not value)
(>= char ?0) (< char next-digit)) (setq value (lookup-key map (read-key-sequence (format "%s: " title))))
(eq value 'keyboard-quit))) (unless value
;; Unread a SPC to lead to our new menu. (user-error "Canceled"))
(setq unread-command-events (cons ?\s unread-command-events)) (when
(setq keys (read-key-sequence title)) (cond ((eq value 'scroll-other-window)
(setq value (let ((minibuffer-scroll-window
(lookup-key overriding-terminal-local-map keys t) (get-buffer-window buf)))
char (aref keys 1)) (if (> 0 arg)
(cond ((eq value 'scroll-other-window) (scroll-other-window-down
(let ((minibuffer-scroll-window (window-height minibuffer-scroll-window))
(get-buffer-window buf))) (scroll-other-window))
(if (> 0 arg) (setq arg 1)))
(scroll-other-window-down ((eq value 'negative-argument)
(window-height minibuffer-scroll-window)) (setq arg -1)))
(scroll-other-window)) (setq value nil))))))
(setq arg 1)))
((eq value 'negative-argument)
(setq arg -1))
(t
(setq arg 1)))))))
(when (eq value 'keyboard-quit)
(error "Canceled"))
value)))) value))))
;;; Widget text specifications. ;;; Widget text specifications.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment