unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Replacing spec of display text property uses wrong when set as before-string or after-string property of an overlay
@ 2022-05-10 14:37 Akib Azmain Turja
  2022-05-10 16:18 ` Eli Zaretskii
  0 siblings, 1 reply; 2+ messages in thread
From: Akib Azmain Turja @ 2022-05-10 14:37 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 872 bytes --]


Here is an example code:

------------
(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?

-- 
Akib Azmain Turja

This message is signed by me with my GnuPG key.  It's fingerprint is:

    7001 8CE5 819F 17A3 BBA6  66AF E74F 0EFA 922A E7F5

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Replacing spec of display text property uses wrong when set as before-string or after-string property of an overlay
  2022-05-10 14:37 Replacing spec of display text property uses wrong when set as before-string or after-string property of an overlay Akib Azmain Turja
@ 2022-05-10 16:18 ` Eli Zaretskii
  0 siblings, 0 replies; 2+ messages in thread
From: Eli Zaretskii @ 2022-05-10 16:18 UTC (permalink / raw)
  To: Akib Azmain Turja; +Cc: emacs-devel

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



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-05-10 16:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-10 14:37 Replacing spec of display text property uses wrong when set as before-string or after-string property of an overlay Akib Azmain Turja
2022-05-10 16:18 ` Eli Zaretskii

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