diff options
| author | Lars Ingebrigtsen | 2019-10-28 12:11:46 +0100 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2019-10-28 12:12:00 +0100 |
| commit | 3478f2f3d6ccd8c9921b03870261b13d5b6c8ba2 (patch) | |
| tree | 8f55a79e8953b1822f549d8ad8c486404be076b1 | |
| parent | 098873b4f25922cd79850e0a985d30ba4c0f780a (diff) | |
| download | emacs-3478f2f3d6ccd8c9921b03870261b13d5b6c8ba2.tar.gz emacs-3478f2f3d6ccd8c9921b03870261b13d5b6c8ba2.zip | |
Make <up> work in read-char-with-history
* lisp/simple.el (read-char-with-history): Tweak to make
<up>/<down> also traverse the history (bug#10477).
| -rw-r--r-- | lisp/simple.el | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/lisp/simple.el b/lisp/simple.el index 5502cd49aa4..184d4eccdb9 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -5197,10 +5197,10 @@ a character from history." | |||
| 5197 | (t | 5197 | (t |
| 5198 | (error "Invalid history: %s" history))) | 5198 | (error "Invalid history: %s" history))) |
| 5199 | (while (not result) | 5199 | (while (not result) |
| 5200 | (setq result (read-char prompt inherit-input-method seconds)) | 5200 | (setq result (read-event prompt inherit-input-method seconds)) |
| 5201 | ;; Go back in history. | 5201 | ;; Go back in history. |
| 5202 | (cond | 5202 | (cond |
| 5203 | ((eq result ?\M-p) | 5203 | ((memq result '(?\M-p up)) |
| 5204 | (if (>= index (length (symbol-value histvar))) | 5204 | (if (>= index (length (symbol-value histvar))) |
| 5205 | (progn | 5205 | (progn |
| 5206 | (message "Beginning of history; no preceding item") | 5206 | (message "Beginning of history; no preceding item") |
| @@ -5211,7 +5211,7 @@ a character from history." | |||
| 5211 | (elt (symbol-value histvar) (1- index))))) | 5211 | (elt (symbol-value histvar) (1- index))))) |
| 5212 | (setq result nil)) | 5212 | (setq result nil)) |
| 5213 | ;; Go forward in history. | 5213 | ;; Go forward in history. |
| 5214 | ((eq result ?\M-n) | 5214 | ((memq result '(?\M-n down)) |
| 5215 | (if (zerop index) | 5215 | (if (zerop index) |
| 5216 | (progn | 5216 | (progn |
| 5217 | (message "End of history; no next item") | 5217 | (message "End of history; no next item") |
| @@ -5225,9 +5225,13 @@ a character from history." | |||
| 5225 | (setq result nil)) | 5225 | (setq result nil)) |
| 5226 | ;; The user hits RET to either select a history item or to | 5226 | ;; The user hits RET to either select a history item or to |
| 5227 | ;; return RET. | 5227 | ;; return RET. |
| 5228 | ((eq result ?\r) | 5228 | ((eq result 'return) |
| 5229 | (unless (zerop index) | 5229 | (if (zerop index) |
| 5230 | (setq result (elt (symbol-value histvar) (1- index))))))) | 5230 | (setq result ?\r) |
| 5231 | (setq result (elt (symbol-value histvar) (1- index))))) | ||
| 5232 | ;; The user has entered some non-character event. | ||
| 5233 | ((not (characterp result)) | ||
| 5234 | (user-error "Non-character input event")))) | ||
| 5231 | ;; Record the chosen key. | 5235 | ;; Record the chosen key. |
| 5232 | (set histvar (cons result (symbol-value histvar))) | 5236 | (set histvar (cons result (symbol-value histvar))) |
| 5233 | result)) | 5237 | result)) |