bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#13863: 24.2; Cursor position after after-string on overlay at point-


From: Eli Zaretskii
Subject: 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 <address@hidden>
> 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.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]