changeset 55187:1bc853c54243

(momentary-string-display): Support EXIT-CHAR that is either a character representation of an event or an event description list.
author Eli Zaretskii <eliz@gnu.org>
date Tue, 27 Apr 2004 13:05:58 +0000
parents db55cb793cc7
children d7ad0d2e368a
files lisp/subr.el
diffstat 1 files changed, 22 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- 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)))