Skip to content

Commit 7e0a4b7

Browse files
committed
* lisp/wid-edit.el (widget-choose): Use read-char-from-minibuffer (bug#17272)
1 parent ebff24c commit 7e0a4b7

File tree

1 file changed

+12
-29
lines changed

1 file changed

+12
-29
lines changed

lisp/wid-edit.el

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,7 @@ minibuffer."
236236
;; Construct a menu of the choices
237237
;; and then use it for prompting for a single character.
238238
(let* ((next-digit ?0)
239-
(map (make-sparse-keymap))
240-
choice some-choice-enabled value)
239+
alist choice some-choice-enabled value)
241240
(with-current-buffer (get-buffer-create " widget-choose")
242241
(erase-buffer)
243242
(insert "Available choices:\n\n")
@@ -247,7 +246,7 @@ minibuffer."
247246
(let* ((name (substitute-command-keys (car choice)))
248247
(function (cdr choice)))
249248
(insert (format "%c = %s\n" next-digit name))
250-
(define-key map (vector next-digit) function)
249+
(push (cons next-digit function) alist)
251250
(setq some-choice-enabled t)))
252251
;; Allocate digits to disabled alternatives
253252
;; so that the digit of a given alternative never varies.
@@ -257,33 +256,17 @@ minibuffer."
257256
(forward-line))
258257
(or some-choice-enabled
259258
(error "None of the choices is currently meaningful"))
260-
(define-key map [?\M-\C-v] 'scroll-other-window)
261-
(define-key map [?\M--] 'negative-argument)
262259
(save-window-excursion
263-
(let ((buf (get-buffer " widget-choose")))
264-
(display-buffer buf
265-
'(display-buffer-in-direction
266-
(direction . bottom)
267-
(window-height . fit-window-to-buffer)))
268-
(let ((cursor-in-echo-area t)
269-
(arg 1))
270-
(while (not value)
271-
(setq value (lookup-key map (read-key-sequence (format "%s: " title))))
272-
(unless value
273-
(user-error "Canceled"))
274-
(when
275-
(cond ((eq value 'scroll-other-window)
276-
(let ((minibuffer-scroll-window
277-
(get-buffer-window buf)))
278-
(if (> 0 arg)
279-
(scroll-other-window-down
280-
(window-height minibuffer-scroll-window))
281-
(scroll-other-window))
282-
(setq arg 1)))
283-
((eq value 'negative-argument)
284-
(setq arg -1)))
285-
(setq value nil))))))
286-
value))))
260+
;; Select window to be able to scroll it from minibuffer
261+
(with-selected-window
262+
(display-buffer (get-buffer " widget-choose")
263+
'(display-buffer-in-direction
264+
(direction . bottom)
265+
(window-height . fit-window-to-buffer)))
266+
(setq value (read-char-from-minibuffer
267+
(format "%s: " title)
268+
(mapcar #'car alist)))))
269+
(cdr (assoc value alist))))))
287270

288271
;;; Widget text specifications.
289272
;;

0 commit comments

Comments
 (0)