From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#18285: 24.3.92; A combination of `display' on text and `invisible' and `before/after-string' leads to the before/after string being displayed twice Date: Mon, 18 Aug 2014 18:07:15 +0300 Message-ID: <83k365defw.fsf@gnu.org> References: <86d2bypwx1.fsf@yandex.ru> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1408374506 20632 80.91.229.3 (18 Aug 2014 15:08:26 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 18 Aug 2014 15:08:26 +0000 (UTC) Cc: 18285@debbugs.gnu.org To: Dmitry Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Aug 18 17:08:20 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XJOXk-0005eM-Fy for geb-bug-gnu-emacs@m.gmane.org; Mon, 18 Aug 2014 17:08:20 +0200 Original-Received: from localhost ([::1]:44242 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XJOXj-0004vR-TB for geb-bug-gnu-emacs@m.gmane.org; Mon, 18 Aug 2014 11:08:19 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44698) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XJOXY-0004ic-3l for bug-gnu-emacs@gnu.org; Mon, 18 Aug 2014 11:08:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XJOXS-0001ea-P8 for bug-gnu-emacs@gnu.org; Mon, 18 Aug 2014 11:08:08 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:39397) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XJOXS-0001eW-Mf for bug-gnu-emacs@gnu.org; Mon, 18 Aug 2014 11:08:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1XJOXS-0003qI-12 for bug-gnu-emacs@gnu.org; Mon, 18 Aug 2014 11:08:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 18 Aug 2014 15:08:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 18285 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 18285-submit@debbugs.gnu.org id=B18285.140837445514736 (code B ref 18285); Mon, 18 Aug 2014 15:08:01 +0000 Original-Received: (at 18285) by debbugs.gnu.org; 18 Aug 2014 15:07:35 +0000 Original-Received: from localhost ([127.0.0.1]:46340 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XJOX0-0003pa-Ck for submit@debbugs.gnu.org; Mon, 18 Aug 2014 11:07:34 -0400 Original-Received: from mtaout22.012.net.il ([80.179.55.172]:55965) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XJOWw-0003pK-Sl for 18285@debbugs.gnu.org; Mon, 18 Aug 2014 11:07:32 -0400 Original-Received: from conversion-daemon.a-mtaout22.012.net.il by a-mtaout22.012.net.il (HyperSendmail v2007.08) id <0NAI00700CO9GB00@a-mtaout22.012.net.il> for 18285@debbugs.gnu.org; Mon, 18 Aug 2014 18:07:24 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout22.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0NAI006HHCOBKUA0@a-mtaout22.012.net.il>; Mon, 18 Aug 2014 18:07:24 +0300 (IDT) In-reply-to: <86d2bypwx1.fsf@yandex.ru> X-012-Sender: halo1@inter.net.il X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:92512 Archived-At: > From: Dmitry > Date: Mon, 18 Aug 2014 02:35:06 +0400 > > (let ((pt (point))) > (insert (propertize "a" 'display "bbb")) > (let ((o (make-overlay pt (point)))) > (overlay-put o 'invisible t) > (overlay-put o 'after-string "foo\nbar"))) > > The result looks like this: > > foo > barbbbfoo > bar Believe it or not, but this is how the code was written 14 years ago, although perhaps this particular consequence wasn't intended. But it follows logically from how the display engine works. The fundamental issue here is that the 'invisible' property makes all the character positions between the start and the end of the overlay indistinguishable. Therefore, the display engine considers the 'before-string' and 'after-string' of an overlay that spans invisible text to be applicable to both the start and the end of the overlay, something it wouldn't do if the 'invisible' property were not present. So what happens is this: . we find the 'display' property and arrange for it to be displayed . before displaying the 'display' property string, we check for overlay strings, and find the 'after-string' whose overlay starts at the same position; since its overlay has the 'invisible' property, we consider the 'after-string' in effect for the start of the overlay, and display that string . we display the 'display' string . we are going to continue display of the buffer starting at the position where the 'display' property ends . we check for overlays at that position, and again find the same 'after-string' because its overlay _ends_ at that buffer position, so we display that string again So you are actually shooting yourself in the foot by using the 'invisible' property here. Doing that is redundant here, because the 'display' property already makes the text it "covers" invisible. I think it's not worth to try to fix this (by complicating the heck out of the display engine) on the account of this use case. If you have other similar use cases, where simply refraining from using 'invisible' won't help, please show them. > It's the same if I use `before-string' instead of `after-string', but > not `display'. > > If I don't set the `invisible' property, it's just > > bbbfoo > bar My crystal ball says you get bbbfoo bar only with 'after-string'. With 'before-string', you should get foo barbbb instead. IOW, without the 'invisible' property getting in the way, the 'before-string' is displayed before the display property, and the 'after-string' is displayed after it. Btw, there was a discussion of a similar issue starting at http://lists.gnu.org/archive/html/emacs-devel/2011-04/msg00674.html It was inconclusive.