comparison lisp/subr.el @ 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 aba8cece2157
children 4c64ee838f41
comparison
equal deleted inserted replaced
55186:db55cb793cc7 55187:1bc853c54243
1455 (if all (save-excursion (set-buffer (other-buffer)))) 1455 (if all (save-excursion (set-buffer (other-buffer))))
1456 (set-buffer-modified-p (buffer-modified-p))) 1456 (set-buffer-modified-p (buffer-modified-p)))
1457 1457
1458 (defun momentary-string-display (string pos &optional exit-char message) 1458 (defun momentary-string-display (string pos &optional exit-char message)
1459 "Momentarily display STRING in the buffer at POS. 1459 "Momentarily display STRING in the buffer at POS.
1460 Display remains until next character is typed. 1460 Display remains until next event is input.
1461 If the char is EXIT-CHAR (optional third arg, default is SPC) it is swallowed; 1461 Optional third arg EXIT-CHAR can be a character, event or event
1462 otherwise it is then available as input (as a command if nothing else). 1462 description list. EXIT-CHAR defaults to SPC. If the input is
1463 EXIT-CHAR it is swallowed; otherwise it is then available as
1464 input (as a command if nothing else).
1463 Display MESSAGE (optional fourth arg) in the echo area. 1465 Display MESSAGE (optional fourth arg) in the echo area.
1464 If MESSAGE is nil, instructions to type EXIT-CHAR are displayed there." 1466 If MESSAGE is nil, instructions to type EXIT-CHAR are displayed there."
1465 (or exit-char (setq exit-char ?\ )) 1467 (or exit-char (setq exit-char ?\ ))
1466 (let ((inhibit-read-only t) 1468 (let ((inhibit-read-only t)
1467 ;; Don't modify the undo list at all. 1469 ;; Don't modify the undo list at all.
1487 (progn 1489 (progn
1488 (goto-char pos) 1490 (goto-char pos)
1489 (recenter 0)))) 1491 (recenter 0))))
1490 (message (or message "Type %s to continue editing.") 1492 (message (or message "Type %s to continue editing.")
1491 (single-key-description exit-char)) 1493 (single-key-description exit-char))
1492 (let ((char (read-event))) 1494 (let (char)
1493 (or (eq char exit-char) 1495 (if (integerp exit-char)
1494 (setq unread-command-events (list char))))) 1496 (condition-case nil
1497 (progn
1498 (setq char (read-char))
1499 (or (eq char exit-char)
1500 (setq unread-command-events (list char))))
1501 (error
1502 ;; `exit-char' is a character, hence it differs
1503 ;; from char, which is an event.
1504 (setq unread-command-events (list char))))
1505 ;; `exit-char' can be an event, or an event description
1506 ;; list.
1507 (setq char (read-event))
1508 (or (eq char exit-char)
1509 (eq char (event-convert-list exit-char))
1510 (setq unread-command-events (list char))))))
1495 (if insert-end 1511 (if insert-end
1496 (save-excursion 1512 (save-excursion
1497 (delete-region pos insert-end))) 1513 (delete-region pos insert-end)))
1498 (setq buffer-file-name name) 1514 (setq buffer-file-name name)
1499 (set-buffer-modified-p modified)))) 1515 (set-buffer-modified-p modified))))