Function: viper-read-string-with-history
viper-read-string-with-history is a byte-compiled function defined in
viper-cmd.el.gz.
Signature
(viper-read-string-with-history PROMPT &optional INITIAL HISTORY-VAR DEFAULT KEYMAP INIT-MESSAGE)
Source Code
;; Defined in /usr/src/emacs/lisp/emulation/viper-cmd.el.gz
;;; Reading string with history
(defun viper-read-string-with-history (prompt &optional initial
history-var default keymap
init-message)
;; Read string, prompting with PROMPT and inserting the INITIAL
;; value. Uses HISTORY-VAR. DEFAULT is the default value to accept if the
;; input is an empty string.
;; Default value is displayed until the user types something in the
;; minibuffer.
;; KEYMAP is used, if given, instead of minibuffer-local-map.
;; INIT-MESSAGE is the message temporarily displayed after entering the
;; minibuffer.
(let ((viper-initial initial)
(viper--init-message init-message)
(minibuffer-setup-hook
;; stolen from add-hook
(let ((old
(if (boundp 'minibuffer-setup-hook)
minibuffer-setup-hook
nil)))
(cons
#'viper-minibuffer-standard-hook
(if (or (not (listp old)) (eq (car old) 'lambda))
(list old) old))))
(val "")
(padding "")
temp-msg)
(setq keymap (or keymap minibuffer-local-map)
initial (or initial "")
viper-initial initial
temp-msg (if default
(format "(default %s) " default)
""))
(setq viper-incomplete-ex-cmd nil)
(setq val (read-from-minibuffer prompt
(concat temp-msg initial val padding)
keymap nil history-var))
(setq minibuffer-setup-hook nil
padding (viper-array-to-string (this-command-keys))
temp-msg "")
;; the following tries to be smart about what to put in history
(if (not (string= val (car (symbol-value history-var))))
(push val (symbol-value history-var)))
(if (or (string= (nth 0 (symbol-value history-var))
(nth 1 (symbol-value history-var)))
(string= (nth 0 (symbol-value history-var)) ""))
(pop (symbol-value history-var)))
;; If the user enters nothing but the prev cmd wasn't viper-ex,
;; viper-command-argument, or `! shell-command', this probably means
;; that the user typed something then erased. Return "" in this case, not
;; the default---the default is too confusing in this case.
(cond ((and (string= val "")
(not (string= prompt "!")) ; was a `! shell-command'
(not (memq last-command
'(viper-ex
viper-command-argument
t)
)))
"")
((string= val "") (or default ""))
(t val))
))