In dired-query use read-char-from-minibuffer with bound help-char (bug#42708)
* lisp/dired-aux.el (dired-query): Replace read-char-choice call with read-char-from-minibuffer. * lisp/subr.el (read-char-choice): Restore the previous version that uses read-key. (read-char-from-minibuffer): Bind help-char to help-form-show when help-form is non-nil.
This commit is contained in:
parent
3e07b871c4
commit
17894ef565
3 changed files with 35 additions and 22 deletions
5
etc/NEWS
5
etc/NEWS
|
|
@ -1321,6 +1321,11 @@ visited errors, so you can have an overview what errors were already visited.
|
|||
If 'tab-always-indent' is 'complete', this new user option can be used to
|
||||
further tweak whether to complete or indent.
|
||||
|
||||
---
|
||||
*** 'dired-query' now uses 'read-char-from-minibuffer'.
|
||||
Using it instead of 'read-char-choice' allows using 'C-x o'
|
||||
to switch to the help window displayed after typing 'C-h'.
|
||||
|
||||
---
|
||||
*** 'zap-up-to-char' now uses 'read-char-from-minibuffer'.
|
||||
This allows navigating through the history of characters that have
|
||||
|
|
|
|||
|
|
@ -1380,7 +1380,7 @@ return t; if SYM is q or ESC, return nil."
|
|||
(format " [Type yn!q or %s] "
|
||||
(key-description (vector help-char)))
|
||||
" [Type y, n, q or !] ")))
|
||||
(set sym (setq char (read-char-choice prompt char-choices)))
|
||||
(set sym (setq char (read-char-from-minibuffer prompt char-choices)))
|
||||
(if (memq char '(?y ?\s ?!)) t)))))
|
||||
|
||||
|
||||
|
|
|
|||
50
lisp/subr.el
50
lisp/subr.el
|
|
@ -2618,15 +2618,7 @@ keyboard-quit events while waiting for a valid input."
|
|||
(unless (get-text-property 0 'face prompt)
|
||||
(setq prompt (propertize prompt 'face 'minibuffer-prompt)))
|
||||
(setq char (let ((inhibit-quit inhibit-keyboard-quit))
|
||||
(read-char-from-minibuffer
|
||||
prompt
|
||||
;; If we have a dynamically bound `help-form'
|
||||
;; here, then the `C-h' (i.e., `help-char')
|
||||
;; character should output that instead of
|
||||
;; being a command char.
|
||||
(if help-form
|
||||
(cons help-char chars)
|
||||
chars))))
|
||||
(read-key prompt)))
|
||||
(and show-help (buffer-live-p (get-buffer helpbuf))
|
||||
(kill-buffer helpbuf))
|
||||
(cond
|
||||
|
|
@ -2774,20 +2766,36 @@ the function will ignore any input that is not one of CHARS.
|
|||
Optional argument HISTORY, if non-nil, should be a symbol that
|
||||
specifies the history list variable to use for navigating in input
|
||||
history using `M-p' and `M-n', with `RET' to select a character from
|
||||
history."
|
||||
history.
|
||||
If the caller has set `help-form', there is no need to explicitly add
|
||||
`help-char' to chars. It's bound automatically to `help-form-show'."
|
||||
(let* ((empty-history '())
|
||||
(map (if (consp chars)
|
||||
(or (gethash chars read-char-from-minibuffer-map-hash)
|
||||
(puthash chars
|
||||
(let ((map (make-sparse-keymap)))
|
||||
(set-keymap-parent map read-char-from-minibuffer-map)
|
||||
(dolist (char chars)
|
||||
(define-key map (vector char)
|
||||
'read-char-from-minibuffer-insert-char))
|
||||
(define-key map [remap self-insert-command]
|
||||
'read-char-from-minibuffer-insert-other)
|
||||
map)
|
||||
read-char-from-minibuffer-map-hash))
|
||||
(or (and (gethash chars read-char-from-minibuffer-map-hash)
|
||||
;; Don't use cached keymap with `help-char'.
|
||||
(not help-form))
|
||||
(let ((map (make-sparse-keymap))
|
||||
(msg help-form))
|
||||
(set-keymap-parent map read-char-from-minibuffer-map)
|
||||
;; If we have a dynamically bound `help-form'
|
||||
;; here, then the `C-h' (i.e., `help-char')
|
||||
;; character should output that instead of
|
||||
;; being a command char.
|
||||
(when help-form
|
||||
(define-key map (vector help-char)
|
||||
(lambda ()
|
||||
(interactive)
|
||||
(let ((help-form msg)) ; lexically bound msg
|
||||
(help-form-show)))))
|
||||
(dolist (char chars)
|
||||
(define-key map (vector char)
|
||||
'read-char-from-minibuffer-insert-char))
|
||||
(define-key map [remap self-insert-command]
|
||||
'read-char-from-minibuffer-insert-other)
|
||||
(unless help-form
|
||||
;; Don't cache keymap with `help-char'.
|
||||
(puthash chars map read-char-from-minibuffer-map-hash))
|
||||
map))
|
||||
read-char-from-minibuffer-map))
|
||||
(result
|
||||
(read-from-minibuffer prompt nil map nil
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue