GNU bug report logs - #13863
24.2; Cursor position after after-string on overlay at point-max

Previous Next

Package: emacs;

Reported by: Magnar Sveen <magnars <at> gmail.com>

Date: Sun, 3 Mar 2013 19:21:01 UTC

Severity: normal

Found in version 24.2

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


Message #8 received at 13863 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Magnar Sveen <magnars <at> gmail.com>
Cc: 13863 <at> debbugs.gnu.org
Subject: Re: bug#13863: 24.2;
	Cursor position after after-string on overlay at point-max
Date: Sun, 03 Mar 2013 23:20:13 +0200
> From: Magnar Sveen <magnars <at> gmail.com>
> Date: Sun, 03 Mar 2013 20:19:33 +0100
> 
> - Write some text into a buffer
> - Create this overlay:
> 
>     (let ((o (make-overlay (point-max) (point-max) nil t t))
>           (s "There's\na multiline\nstring here"))
>       (set-text-properties 0 (length s)
>        `(face (:foreground ,(format "#%02x%02x%02x" 90 90 90))) s)
>       (overlay-put o 'priority 100)
>       (overlay-put o 'after-string s))
> 
>     ;; the text-properties aren't important, it's just there to
>     ;; separate the overlay visually.
>       
> - Go to point-max.
> - Type something.
> 
> Notice that the point of insertion is not reflected by the position of
> the cursor.
> 
> Basically, the cursor is positioned after the after-string of an overlay
> at point-max, even if it does not accurately reflect where text is
> inserted. If the after-string is large enough, you could be inserting
> text outside the screen and not know about it.

Emacs always behaved like that with after-string display.

> I am trying to use this so that I can display some extra information
> after contents of the buffer. However, it gets mighty annoying when the
> cursor is placed after all the second-order information I am displaying
> there.
> 
> Maybe the placement of the cursor should depend on the the value of
> rear-advance?

Try this (note the marked line I added):

    (let ((o (make-overlay (point-max) (point-max) nil t t))
          (s "There's\na multiline\nstring here"))
      (set-text-properties 0 (length s)
       `(face (:foreground ,(format "#%02x%02x%02x" 90 90 90))) s)
      (put-text-property 0 1 'cursor t s)  ;;; <<<<<<<<<<<<<<<<<<<<<<
      (overlay-put o 'priority 100)
      (overlay-put o 'after-string s))

IOW, when Emacs is too dumb to put the cursor where you want, you can
guide it with the 'cursor' text property.




This bug report was last modified 12 years and 143 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.