[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/consult fc17dc2171 1/2: Fix #518 (#520)
From: |
ELPA Syncer |
Subject: |
[elpa] externals/consult fc17dc2171 1/2: Fix #518 (#520) |
Date: |
Sat, 19 Feb 2022 10:57:21 -0500 (EST) |
branch: externals/consult
commit fc17dc2171437c52ec20a37f9a62a7630d985960
Author: Omar AntolĂn Camarena <omar.antolin@gmail.com>
Commit: GitHub <noreply@github.com>
Fix #518 (#520)
In terminal Emacs, given M-char, (read-key) will return 27 and set
last-input-event to char. This change turns that situation into what
would have been read in graphical Emacs, letting the rest of the code
remain unchanged.
---
consult-register.el | 32 ++++++++++++++++++++------------
1 file changed, 20 insertions(+), 12 deletions(-)
diff --git a/consult-register.el b/consult-register.el
index 6bafebab3d..8ffe22de73 100644
--- a/consult-register.el
+++ b/consult-register.el
@@ -230,6 +230,7 @@ This function is derived from `register-read-with-preview'."
(prefix (car action-list))
(action-list (cdr action-list))
(action (car (nth 0 action-list)))
+ (key)
(reg)
(preview
(lambda ()
@@ -252,20 +253,27 @@ This function is derived from
`register-read-with-preview'."
(help-chars (seq-remove #'get-register (cons help-char
help-event-list))))
(unwind-protect
(while (not reg)
- (while (memq (read-key (propertize (caddr (assq action action-list))
- 'face 'minibuffer-prompt))
+ (while (memq (setq key
+ (read-key (propertize (caddr (assq action
action-list))
+ 'face 'minibuffer-prompt)))
help-chars)
(funcall preview))
- (cond
- ((or (eq ?\C-g last-input-event)
- (eq 'escape last-input-event)
- (eq ?\C-\[ last-input-event))
- (keyboard-quit))
- ((and (numberp last-input-event) (assq (logxor #x8000000
last-input-event) action-list))
- (setq action (logxor #x8000000 last-input-event)))
- ((characterp last-input-event)
- (setq reg last-input-event))
- (t (error "Non-character input-event"))))
+ (let ((input (if (and (eql key ?\e) (characterp last-input-event))
+ ;; in terminal Emacs M-letter is read as two keys,
ESC and the letter,
+ ;; use what would have been read in graphical Emacs
+ (logior #x8000000 last-input-event)
+ last-input-event)))
+
+ (cond
+ ((or (eq ?\C-g input)
+ (eq 'escape input)
+ (eq ?\C-\[ input))
+ (keyboard-quit))
+ ((and (numberp input) (assq (logxor #x8000000 input) action-list))
+ (setq action (logxor #x8000000 input)))
+ ((characterp input)
+ (setq reg input))
+ (t (error "Non-character input-event")))))
(when (timerp timer)
(cancel-timer timer))
(let ((w (get-buffer-window buffer)))