aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2019-10-30 02:00:02 +0200
committerJuri Linkov2019-10-30 02:00:02 +0200
commitba7755bfb78884fd57e2506bcaebb51b5ff1ba1b (patch)
tree4962f18bf0cb8f407a45d3289373c1a239fac47e
parent682eae776efa9d57842345de67becf5c56cafc91 (diff)
downloademacs-ba7755bfb78884fd57e2506bcaebb51b5ff1ba1b.tar.gz
emacs-ba7755bfb78884fd57e2506bcaebb51b5ff1ba1b.zip
Rename read-char-with-history to read-char-from-minibuffer (bug#10477)
* lisp/simple.el (read-char-from-minibuffer-history): Rename from read-char-with-history--history. (read-char-from-minibuffer-map): Rename from read-char-with-history--map. (read-char-from-minibuffer): Rename from read-char-with-history. (read-char-from-minibuffer-self-insert): New command. (zap-to-char): Use read-char-from-minibuffer.
-rw-r--r--lisp/simple.el40
1 files changed, 21 insertions, 19 deletions
diff --git a/lisp/simple.el b/lisp/simple.el
index 5b84c3ea574..29e195bca6c 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -5166,36 +5166,38 @@ and KILLP is t if a prefix arg was specified."
5166 ;; Avoid warning about delete-backward-char 5166 ;; Avoid warning about delete-backward-char
5167 (with-no-warnings (delete-backward-char n killp)))) 5167 (with-no-warnings (delete-backward-char n killp))))
5168 5168
5169(defvar read-char-with-history--history nil 5169(defvar read-char-from-minibuffer-history nil
5170 "The default history for the `read-char-with-history' function.") 5170 "The default history for the `read-char-from-minibuffer' function.")
5171 5171
5172(defvar read-char-with-history--map 5172(defvar read-char-from-minibuffer-map
5173 (let ((map (make-sparse-keymap))) 5173 (let ((map (make-sparse-keymap)))
5174 (set-keymap-parent map minibuffer-local-map) 5174 (set-keymap-parent map minibuffer-local-map)
5175 (define-key map [remap self-insert-command] 5175 (define-key map [remap self-insert-command]
5176 (lambda () 5176 'read-char-from-minibuffer-self-insert)
5177 (interactive)
5178 (delete-minibuffer-contents)
5179 (insert (event-basic-type last-command-event))
5180 (exit-minibuffer)))
5181 map) 5177 map)
5182 "Keymap for the `read-char-with-history' function.") 5178 "Keymap for the `read-char-from-minibuffer' function.")
5183
5184(defun read-char-with-history (prompt)
5185 "Like `read-char', but allows navigating in a history.
5186HISTORY is like HIST in `read-from-minibuffer'.
5187 5179
5188The navigation commands are `M-p' and `M-n', with `RET' to select 5180(defun read-char-from-minibuffer-self-insert ()
5189a character from history." 5181 "Insert the character you type in the minibuffer."
5182 (interactive)
5183 (delete-minibuffer-contents)
5184 (insert (event-basic-type last-command-event))
5185 (exit-minibuffer))
5186
5187(defun read-char-from-minibuffer (prompt)
5188 "Read a character from the minibuffer, prompting with string PROMPT.
5189Like `read-char', but allows navigating in a history. The navigation
5190commands are `M-p' and `M-n', with `RET' to select a character from
5191history."
5190 (let ((result 5192 (let ((result
5191 (read-from-minibuffer prompt nil 5193 (read-from-minibuffer prompt nil
5192 read-char-with-history--map nil 5194 read-char-from-minibuffer-map nil
5193 'read-char-with-history--history))) 5195 'read-char-from-minibuffer-history)))
5194 (if (> (length result) 0) 5196 (if (> (length result) 0)
5195 ;; We have a string (with one character), so return the first one. 5197 ;; We have a string (with one character), so return the first one.
5196 (elt result 0) 5198 (elt result 0)
5197 ;; The default value is RET. 5199 ;; The default value is RET.
5198 (push "\r" read-char-with-history--history) 5200 (push "\r" read-char-from-minibuffer-history)
5199 ?\r))) 5201 ?\r)))
5200 5202
5201(defun zap-to-char (arg char) 5203(defun zap-to-char (arg char)
@@ -5203,7 +5205,7 @@ a character from history."
5203Case is ignored if `case-fold-search' is non-nil in the current buffer. 5205Case is ignored if `case-fold-search' is non-nil in the current buffer.
5204Goes backward if ARG is negative; error if CHAR not found." 5206Goes backward if ARG is negative; error if CHAR not found."
5205 (interactive (list (prefix-numeric-value current-prefix-arg) 5207 (interactive (list (prefix-numeric-value current-prefix-arg)
5206 (read-char-with-history "Zap to char: "))) 5208 (read-char-from-minibuffer "Zap to char: ")))
5207 ;; Avoid "obsolete" warnings for translation-table-for-input. 5209 ;; Avoid "obsolete" warnings for translation-table-for-input.
5208 (with-no-warnings 5210 (with-no-warnings
5209 (if (char-table-p translation-table-for-input) 5211 (if (char-table-p translation-table-for-input)