Function: momentary-string-display
momentary-string-display is a byte-compiled function defined in
subr.el.gz.
Signature
(momentary-string-display STRING POS &optional EXIT-CHAR MESSAGE)
Documentation
Momentarily display STRING in the buffer at POS.
Display remains until next event is input. If POS is a marker, only its position is used; its buffer is ignored. Optional third arg EXIT-CHAR can be a character, event or event description list. EXIT-CHAR defaults to SPC. If the input is EXIT-CHAR it is swallowed; otherwise it is then available as input (as a command if nothing else). Display MESSAGE (optional fourth arg) in the echo area. If MESSAGE is nil, instructions to type EXIT-CHAR are displayed there.
Source Code
;; Defined in /usr/src/emacs/lisp/subr.el.gz
;;;; Display-related functions.
(defun momentary-string-display (string pos &optional exit-char message)
"Momentarily display STRING in the buffer at POS.
Display remains until next event is input.
If POS is a marker, only its position is used; its buffer is ignored.
Optional third arg EXIT-CHAR can be a character, event or event
description list. EXIT-CHAR defaults to SPC. If the input is
EXIT-CHAR it is swallowed; otherwise it is then available as
input (as a command if nothing else).
Display MESSAGE (optional fourth arg) in the echo area.
If MESSAGE is nil, instructions to type EXIT-CHAR are displayed there."
(or exit-char (setq exit-char ?\s))
(let ((ol (make-overlay pos pos))
(str (copy-sequence string)))
(unwind-protect
(progn
(save-excursion
(overlay-put ol 'after-string str)
(goto-char pos)
;; To avoid trouble with out-of-bounds position
(setq pos (point))
;; If the string end is off screen, recenter now.
(if (<= (window-end nil t) pos)
(recenter (/ (window-height) 2))))
(message (or message "Type %s to continue editing.")
(single-key-description exit-char))
(let ((event (read-key)))
;; `exit-char' can be an event, or an event description list.
(or (eq event exit-char)
(eq event (event-convert-list exit-char))
(setq unread-command-events
(append (this-single-command-raw-keys)
unread-command-events)))))
(delete-overlay ol))))