diff options
| author | Nicolas Richard | 2014-12-05 07:29:26 +0100 |
|---|---|---|
| committer | Nicolas Richard | 2014-12-05 17:46:43 +0100 |
| commit | 2a06fc15b2a3e6287f18025806fb2eabec801fc0 (patch) | |
| tree | bae3a0d631d577c6d80544d5159ca367ec0426c0 /lisp | |
| parent | 3f199630bdd2d000b2901dd5319ae528887e015f (diff) | |
| download | emacs-2a06fc15b2a3e6287f18025806fb2eabec801fc0.tar.gz emacs-2a06fc15b2a3e6287f18025806fb2eabec801fc0.zip | |
(widget-choose) Let numeric keypad work
Fixes: debbugs:19268
* wid-edit.el (widget-choose): Let numeric keypad work
and remove old menu-related code.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/wid-edit.el | 69 |
2 files changed, 31 insertions, 43 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 2fc3562ac5a..72adfb1f467 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2014-12-05 Nicolas Richard <theonewiththeevillook@yahoo.fr> | ||
| 2 | |||
| 3 | * wid-edit.el (widget-choose): Let numeric keypad work (bug#19268) | ||
| 4 | and remove old menu-related code. | ||
| 5 | |||
| 1 | 2014-12-05 Lars Magne Ingebrigtsen <larsi@gnus.org> | 6 | 2014-12-05 Lars Magne Ingebrigtsen <larsi@gnus.org> |
| 2 | 7 | ||
| 3 | * net/eww.el (eww-display-pdf): Let mailcap determine how to | 8 | * net/eww.el (eww-display-pdf): Let mailcap determine how to |
diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el index 92e52bff55e..e901431bfcd 100644 --- a/lisp/wid-edit.el +++ b/lisp/wid-edit.el | |||
| @@ -232,23 +232,20 @@ minibuffer." | |||
| 232 | (t | 232 | (t |
| 233 | ;; Construct a menu of the choices | 233 | ;; Construct a menu of the choices |
| 234 | ;; and then use it for prompting for a single character. | 234 | ;; and then use it for prompting for a single character. |
| 235 | (let* ((overriding-terminal-local-map (make-sparse-keymap)) | 235 | (let* ((next-digit ?0) |
| 236 | (next-digit ?0) | 236 | (map (make-sparse-keymap)) |
| 237 | map choice some-choice-enabled value) | 237 | choice some-choice-enabled value) |
| 238 | ;; Define SPC as a prefix char to get to this menu. | ||
| 239 | (define-key overriding-terminal-local-map " " | ||
| 240 | (setq map (make-sparse-keymap title))) | ||
| 241 | (with-current-buffer (get-buffer-create " widget-choose") | 238 | (with-current-buffer (get-buffer-create " widget-choose") |
| 242 | (erase-buffer) | 239 | (erase-buffer) |
| 243 | (insert "Available choices:\n\n") | 240 | (insert "Available choices:\n\n") |
| 244 | (while items | 241 | (while items |
| 245 | (setq choice (car items) items (cdr items)) | 242 | (setq choice (pop items)) |
| 246 | (if (consp choice) | 243 | (when (consp choice) |
| 247 | (let* ((name (car choice)) | 244 | (let* ((name (car choice)) |
| 248 | (function (cdr choice))) | 245 | (function (cdr choice))) |
| 249 | (insert (format "%c = %s\n" next-digit name)) | 246 | (insert (format "%c = %s\n" next-digit name)) |
| 250 | (define-key map (vector next-digit) function) | 247 | (define-key map (vector next-digit) function) |
| 251 | (setq some-choice-enabled t))) | 248 | (setq some-choice-enabled t))) |
| 252 | ;; Allocate digits to disabled alternatives | 249 | ;; Allocate digits to disabled alternatives |
| 253 | ;; so that the digit of a given alternative never varies. | 250 | ;; so that the digit of a given alternative never varies. |
| 254 | (setq next-digit (1+ next-digit))) | 251 | (setq next-digit (1+ next-digit))) |
| @@ -257,43 +254,29 @@ minibuffer." | |||
| 257 | (forward-line)) | 254 | (forward-line)) |
| 258 | (or some-choice-enabled | 255 | (or some-choice-enabled |
| 259 | (error "None of the choices is currently meaningful")) | 256 | (error "None of the choices is currently meaningful")) |
| 260 | (define-key map [?\C-g] 'keyboard-quit) | ||
| 261 | (define-key map [t] 'keyboard-quit) | ||
| 262 | (define-key map [?\M-\C-v] 'scroll-other-window) | 257 | (define-key map [?\M-\C-v] 'scroll-other-window) |
| 263 | (define-key map [?\M--] 'negative-argument) | 258 | (define-key map [?\M--] 'negative-argument) |
| 264 | (setcdr map (nreverse (cdr map))) | ||
| 265 | ;; Read a char with the menu, and return the result | ||
| 266 | ;; that corresponds to it. | ||
| 267 | (save-window-excursion | 259 | (save-window-excursion |
| 268 | (let ((buf (get-buffer " widget-choose"))) | 260 | (let ((buf (get-buffer " widget-choose"))) |
| 269 | (fit-window-to-buffer (display-buffer buf)) | 261 | (fit-window-to-buffer (display-buffer buf)) |
| 270 | (let ((cursor-in-echo-area t) | 262 | (let ((cursor-in-echo-area t) |
| 271 | keys | ||
| 272 | (char 0) | ||
| 273 | (arg 1)) | 263 | (arg 1)) |
| 274 | (while (not (or (and (integerp char) | 264 | (while (not value) |
| 275 | (>= char ?0) (< char next-digit)) | 265 | (setq value (lookup-key map (read-key-sequence (format "%s: " title)))) |
| 276 | (eq value 'keyboard-quit))) | 266 | (unless value |
| 277 | ;; Unread a SPC to lead to our new menu. | 267 | (user-error "Canceled")) |
| 278 | (setq unread-command-events (cons ?\s unread-command-events)) | 268 | (when |
| 279 | (setq keys (read-key-sequence title)) | 269 | (cond ((eq value 'scroll-other-window) |
| 280 | (setq value | 270 | (let ((minibuffer-scroll-window |
| 281 | (lookup-key overriding-terminal-local-map keys t) | 271 | (get-buffer-window buf))) |
| 282 | char (aref keys 1)) | 272 | (if (> 0 arg) |
| 283 | (cond ((eq value 'scroll-other-window) | 273 | (scroll-other-window-down |
| 284 | (let ((minibuffer-scroll-window | 274 | (window-height minibuffer-scroll-window)) |
| 285 | (get-buffer-window buf))) | 275 | (scroll-other-window)) |
| 286 | (if (> 0 arg) | 276 | (setq arg 1))) |
| 287 | (scroll-other-window-down | 277 | ((eq value 'negative-argument) |
| 288 | (window-height minibuffer-scroll-window)) | 278 | (setq arg -1))) |
| 289 | (scroll-other-window)) | 279 | (setq value nil)))))) |
| 290 | (setq arg 1))) | ||
| 291 | ((eq value 'negative-argument) | ||
| 292 | (setq arg -1)) | ||
| 293 | (t | ||
| 294 | (setq arg 1))))))) | ||
| 295 | (when (eq value 'keyboard-quit) | ||
| 296 | (error "Canceled")) | ||
| 297 | value)))) | 280 | value)))) |
| 298 | 281 | ||
| 299 | ;;; Widget text specifications. | 282 | ;;; Widget text specifications. |