unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Kevin Rodgers <kevin.d.rodgers@gmail.com>
Subject: Re: momentary-string-display
Date: Thu, 04 Jan 2007 08:31:04 -0700	[thread overview]
Message-ID: <enj6jm$gio$1@sea.gmane.org> (raw)
In-Reply-To: <E1H2IOP-0002Yu-AF@fencepost.gnu.org>

Richard Stallman wrote:
>     As I meant to say, the same heuristic can be used by replacing the
>     reference to insert-end with (+ pos (length string)) -- as long as
>     the new call to overlay-put causes a redisplay that updates window-end
>     just as the original call to insert does.
> 
> I just made a change in window-end which I think will make it handle
> that case correctly.
> 
> So let's have your patch and install it.

2007-01-04  Kevin Rodgers  <kevin.d.rodgers@gmail.com>

	* 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.


*** subr.el~	Mon Dec 11 09:37:43 2006
--- subr.el	Thu Jan  4 08:16:31 2007
***************
*** 1884,1889 ****
--- 1884,1894 ----
     (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.
***************
*** 1894,1915 ****
   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)
       (unwind-protect
   	(progn
! 	  (save-excursion
! 	    (goto-char pos)
! 	    ;; 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.
--- 1899,1911 ----
   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 ((momentary-overlay (make-overlay pos pos nil t)))
       (unwind-protect
   	(progn
! 	  (overlay-put momentary-overlay 'before-string
! 		       (propertize string 'face 'momentary))
   	    ;; 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.
***************
*** 1937,1947 ****
   	      (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))))

   \f
   ;;;; Overlay operations
--- 1933,1941 ----
   	      (or (eq char exit-char)
   		  (eq char (event-convert-list exit-char))
   		  (setq unread-command-events (list char))))))
!       (when (overlayp momentary-overlay)
! 	(delete-overlay momentary-overlay)))))
!

   \f
   ;;;; Overlay operations

-- 
Kevin Rodgers
Denver, Colorado, USA

  reply	other threads:[~2007-01-04 15:31 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-27  1:18 momentary-string-display Juanma Barranquero
2006-12-27 21:16 ` momentary-string-display Richard Stallman
2006-12-27 23:53   ` momentary-string-display Juanma Barranquero
2006-12-29 15:44     ` momentary-string-display Richard Stallman
2007-01-02 23:58       ` momentary-string-display Juanma Barranquero
2006-12-29  4:47   ` momentary-string-display Kevin Rodgers
2006-12-29 22:58     ` momentary-string-display Richard Stallman
2007-01-03  8:53       ` momentary-string-display Kevin Rodgers
2007-01-04  1:41         ` momentary-string-display Stephen Leake
2007-01-04  2:31         ` momentary-string-display Richard Stallman
2007-01-04 15:31           ` Kevin Rodgers [this message]
2007-01-04 22:34             ` momentary-string-display Richard Stallman
2007-01-04 23:18               ` momentary-string-display Juanma Barranquero
2007-01-05 19:09                 ` momentary-string-display Richard Stallman
2007-01-05  7:05               ` momentary-string-display Stephen Leake
2007-01-06  2:54                 ` momentary-string-display Richard Stallman
2007-01-06  7:36                   ` momentary-string-display Stephen Leake
2007-01-07  3:47                     ` momentary-string-display Richard Stallman
2007-01-07 14:41                       ` momentary-string-display Stephen Leake
2007-01-02 22:54   ` momentary-string-display Tak Ota
2007-01-03 21:11     ` momentary-string-display Richard Stallman
2007-01-03 21:36       ` momentary-string-display Tak Ota

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='enj6jm$gio$1@sea.gmane.org' \
    --to=kevin.d.rodgers@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).