# HG changeset patch # User Eli Zaretskii # Date 1083071158 0 # Node ID 1bc853c5424355fda798644a90795af23319bec9 # Parent db55cb793cc7205eae40b25810174ec7a51bb6cd (momentary-string-display): Support EXIT-CHAR that is either a character representation of an event or an event description list. diff -r db55cb793cc7 -r 1bc853c54243 lisp/subr.el --- a/lisp/subr.el Tue Apr 27 12:57:55 2004 +0000 +++ b/lisp/subr.el Tue Apr 27 13:05:58 2004 +0000 @@ -1457,9 +1457,11 @@ (defun momentary-string-display (string pos &optional exit-char message) "Momentarily display STRING in the buffer at POS. -Display remains until next character is typed. -If the char is EXIT-CHAR (optional third arg, default is SPC) it is swallowed; -otherwise it is then available as input (as a command if nothing else). +Display remains until next event is input. +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 ?\ )) @@ -1489,9 +1491,23 @@ (recenter 0)))) (message (or message "Type %s to continue editing.") (single-key-description exit-char)) - (let ((char (read-event))) - (or (eq char exit-char) - (setq unread-command-events (list char))))) + (let (char) + (if (integerp exit-char) + (condition-case nil + (progn + (setq char (read-char)) + (or (eq char exit-char) + (setq unread-command-events (list char)))) + (error + ;; `exit-char' is a character, hence it differs + ;; from char, which is an event. + (setq unread-command-events (list char)))) + ;; `exit-char' can be an event, or an event description + ;; list. + (setq char (read-event)) + (or (eq char exit-char) + (eq char (event-convert-list exit-char)) + (setq unread-command-events (list char)))))) (if insert-end (save-excursion (delete-region pos insert-end)))