From 12092fb374d3958b6e3a240a18bedbb75f9b1280 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Tue, 27 Apr 2004 13:07:16 +0000 Subject: [PATCH] (momentary-string-display): Support EXIT-CHAR that is either a character representation of an event or an event description list. --- lisp/ChangeLog | 6 ++++++ lisp/subr.el | 28 ++++++++++++++++++++++------ 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index af93ebf9dd2..5c01151c270 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2004-04-27 Matthew Mundell + + * subr.el (momentary-string-display): Support EXIT-CHAR that is + either a character representation of an event or an event + description list. + 2004-04-27 Daniel M Coffman (tiny change) * arc-mode.el (archive-maybe-copy): If ARCHIVE includes leading diff --git a/lisp/subr.el b/lisp/subr.el index 57f725fb44c..516b0fc781a 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -1457,9 +1457,11 @@ menu bar menus and the frame title." (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 @@ If MESSAGE is nil, instructions to type EXIT-CHAR are displayed there." (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))) -- 2.39.5