From: Richard M. Stallman Date: Thu, 4 Jan 2007 21:46:11 +0000 (+0000) Subject: (momentary): New face. X-Git-Tag: emacs-pretest-22.0.93~255 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=c8d554e95eee912803b1fff623db1a3f07aeba86;p=emacs.git (momentary): New face. (momentary-string-display): Display the string via a temporary overlay using the new face, instead of inserting it in the buffer. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 6cb365666a4..e4ea386e686 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2007-01-04 Kevin Rodgers + + * subr.el (momentary): New face. + (momentary-string-display): Display the string via a temporary + overlay using the new face, instead of inserting it in the buffer. + 2007-01-04 Andreas Schwab * progmodes/ebrowse.el (ebrowse-global-prefix-key): Fix typo in diff --git a/lisp/subr.el b/lisp/subr.el index c98e14b6334..31d220a8dd3 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -1884,6 +1884,11 @@ menu bar menus and the frame title." (if all (save-excursion (set-buffer (other-buffer)))) (set-buffer-modified-p (buffer-modified-p))) +(defface momentary + '((t (:inherit mode-line))) + "Face for momentarily displaying text in the current buffer." + :group 'display) + (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. @@ -1895,32 +1900,21 @@ 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 ((inhibit-read-only t) - ;; Don't modify the undo list at all. - (buffer-undo-list t) - (modified (buffer-modified-p)) - (name buffer-file-name) - insert-end) + (let ((momentary-overlay (make-overlay pos pos nil t))) + (overlay-put momentary-overlay 'before-string + (propertize string 'face 'momentary)) (unwind-protect (progn - (save-excursion - (goto-char pos) - ;; To avoid trouble with out-of-bounds position - (setq pos (point)) - ;; defeat file locking... don't try this at home, kids! - (setq buffer-file-name nil) - (insert-before-markers string) - (setq insert-end (point)) - ;; If the message end is off screen, recenter now. - (if (< (window-end nil t) insert-end) - (recenter (/ (window-height) 2))) - ;; If that pushed message start off the screen, - ;; scroll to start it at the top of the screen. - (move-to-window-line 0) - (if (> (point) pos) - (progn - (goto-char pos) - (recenter 0)))) + ;; If the message end is off screen, recenter now. + (if (< (window-end nil t) (+ pos (length string))) + (recenter (/ (window-height) 2))) + ;; If that pushed message start off the screen, + ;; scroll to start it at the top of the screen. + (move-to-window-line 0) + (if (> (point) pos) + (progn + (goto-char pos) + (recenter 0))) (message (or message "Type %s to continue editing.") (single-key-description exit-char)) (let (char) @@ -1940,11 +1934,7 @@ If MESSAGE is nil, instructions to type EXIT-CHAR are displayed there." (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))) - (setq buffer-file-name name) - (set-buffer-modified-p modified)))) + (delete-overlay momentary-overlay)))) ;;;; Overlay operations