unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Akib Azmain Turja <akib@disroot.org>
Cc: emacs-devel@gnu.org
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	[thread overview]
Message-ID: <83o805s6ms.fsf@gnu.org> (raw)
In-Reply-To: <87h75xcv3j.fsf@disroot.org> (message from Akib Azmain Turja on Tue, 10 May 2022 20:37:04 +0600)

> 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	other threads:[~2022-05-10 16:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83o805s6ms.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=akib@disroot.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).