From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel 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 Message-ID: <83o805s6ms.fsf@gnu.org> References: <87h75xcv3j.fsf@disroot.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36131"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Akib Azmain Turja Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue May 10 18:19:43 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1noSaN-0009Dq-JS for ged-emacs-devel@m.gmane-mx.org; Tue, 10 May 2022 18:19:43 +0200 Original-Received: from localhost ([::1]:36218 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1noSaL-0003MI-Ng for ged-emacs-devel@m.gmane-mx.org; Tue, 10 May 2022 12:19:42 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59760) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1noSZa-0002cp-Bb for emacs-devel@gnu.org; Tue, 10 May 2022 12:18:54 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:48310) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1noSZa-0008OE-2V; Tue, 10 May 2022 12:18:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=lXBh5+FUbJl9GXxIbocNF6YyQk1ZXCDOpPB/IiZmtmo=; b=QWxllqkrvHhY HvS9euXXpig9EiwDRLyz4URJx8PUwyScco5/HSsowachABcYhfLBy8mlSqz2lVrV9j2zsRd2YEjYx PV+aN/t+32v7C4VCduREtfVKJ6d9dmDYHmc2aPsGM6ejOc44FZXQe+jy2iwMztqVAH3pu00giqgVP gjDr6W2bDoflpb0XVE/W/RKa0XoG9qSCdqR162IBLtHOTx9SnkLiehKUikqh2sbyDA/zvoFEOEHXA 9CZEKm66Mj6P19baubYn5KvKtcgYzHRkfBkFQqeEQLbBvmHw/g98SVRhfzJDIF0uGaN4gYoAPXuDk HFP64iRLmE9wScYkz7gFfg==; Original-Received: from [87.69.77.57] (port=3071 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1noSZZ-0004cH-IH; Tue, 10 May 2022 12:18:53 -0400 In-Reply-To: <87h75xcv3j.fsf@disroot.org> (message from Akib Azmain Turja on Tue, 10 May 2022 20:37:04 +0600) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:289593 Archived-At: > From: Akib Azmain Turja > 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.