From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kevin Rodgers Newsgroups: gmane.emacs.devel Subject: Re: momentary-string-display Date: Thu, 28 Dec 2006 21:47:15 -0700 Message-ID: References: NNTP-Posting-Host: dough.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1167367671 15428 80.91.229.10 (29 Dec 2006 04:47:51 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 29 Dec 2006 04:47:51 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Dec 29 05:47:49 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by dough.gmane.org with esmtp (Exim 4.50) id 1H09el-0001zv-1O for ged-emacs-devel@m.gmane.org; Fri, 29 Dec 2006 05:47:47 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1H09ek-0005pF-Jv for ged-emacs-devel@m.gmane.org; Thu, 28 Dec 2006 23:47:46 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1H09eX-0005ma-Om for emacs-devel@gnu.org; Thu, 28 Dec 2006 23:47:33 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1H09eX-0005ly-3r for emacs-devel@gnu.org; Thu, 28 Dec 2006 23:47:33 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1H09eW-0005ld-Rf for emacs-devel@gnu.org; Thu, 28 Dec 2006 23:47:32 -0500 Original-Received: from [80.91.229.2] (helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1H09eV-0000wE-Ue for emacs-devel@gnu.org; Thu, 28 Dec 2006 23:47:32 -0500 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1H09eK-0004W6-MP for emacs-devel@gnu.org; Fri, 29 Dec 2006 05:47:20 +0100 Original-Received: from c-24-9-156-178.hsd1.co.comcast.net ([24.9.156.178]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 29 Dec 2006 05:47:20 +0100 Original-Received: from kevin.d.rodgers by c-24-9-156-178.hsd1.co.comcast.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 29 Dec 2006 05:47:20 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-To: emacs-devel@gnu.org Original-Lines: 102 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: c-24-9-156-178.hsd1.co.comcast.net User-Agent: Thunderbird 1.5.0.9 (Macintosh/20061207) In-Reply-To: X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:64408 Archived-At: Richard Stallman wrote: > It would be clean to make momentary-string-display use overlays > and not change the buffer text at all. Would you like to try > writing that? But let's not delay the release for it. I'd like to try. Note that I removed all the code that tries to compensate for the text being inserted in such a way that its end or start is not displayed in the selected window (under the assumption that the display engine will DTRT with the overlay); but it should be possible to restore that code, replacing the reference to message-end with (+ pos (length string)). I also added a small feature: a new face, used to display the text. *** subr.el~ Thu Dec 11 09:37:00 2006 --- subr.el Thu Dec 28 21:26:33 2006 *************** *** 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,1923 **** 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. ! (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) --- 1899,1909 ---- 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)) (message (or message "Type %s to continue editing.") (single-key-description exit-char)) (let (char) *************** *** 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)))) ;;;; Overlay operations --- 1923,1930 ---- (or (eq char exit-char) (eq char (event-convert-list exit-char)) (setq unread-command-events (list char)))))) ! (when (overlay-get momentary-overlay 'before-string) ! (delete-overlay momentary-overlay))))) ;;;; Overlay operations -- Kevin Rodgers Denver, Colorado, USA