emacs-devel
[Top][All Lists]
Advanced

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

Re: Replacing spec of display text property uses wrong when set as befor


From: Eli Zaretskii
Subject: Re: Replacing spec of display text property uses wrong when set as before-string or after-string property of an overlay
Date: Tue, 10 May 2022 19:18:51 +0300

> From: Akib Azmain Turja <akib@disroot.org>
> Date: Tue, 10 May 2022 20:37:04 +0600
> 
> (let ((txt-disp (concat " " (propertize "_" 'display "foobar") " "))
>       (ov (make-overlay (point-min) (point-max))))
>   (overlay-put ov 'before-string
>              (propertize txt-disp 'face
>                          `(:weight bold :foreground "red"
>                                      :background "yellow"))))
> 
> ;; To remove the overlay call `delete-all-overlays`.
> ------------
> 
> After executing the above " foobar " should appear at the beginning of
> buffer with red foreground and yellow background.  But the "foobar" part
> doesn't use any color (i.e uses the face of the real text at the
> beginning of buffer).  This doesn't happen when the text is inserted.
> Is it a bug?

It's a "feature": when Emacs displays a string from a 'display'
property (in this case, "foobar"), it ignores the face properties of
the overlay string which has this 'display' property, and instead uses
the face of the buffer text at that position.

This might surprise you, but Emacs has always behaved this way since
v21.1, so I guess by now it's a de-facto standard behavior.  It is
even documented, see the node "Displaying Faces" in the ELisp manual,
where it talks about before- and after-strings and 'display' strings
without face information.



reply via email to

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