GNU bug report logs - #13648
24.3.50; remove-overlays bugs

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Severity: minor; Reported by: Stephen Berman <stephen.berman@HIDDEN>; dated Thu, 7 Feb 2013 15:12:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 13648 <at> debbugs.gnu.org:


Received: (at 13648) by debbugs.gnu.org; 8 Feb 2013 14:51:01 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Feb 08 09:51:01 2013
Received: from localhost ([127.0.0.1]:43179 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1U3pI1-0008Go-Jv
	for submit <at> debbugs.gnu.org; Fri, 08 Feb 2013 09:51:01 -0500
Received: from mout.gmx.net ([212.227.15.18]:54619)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <stephen.berman@HIDDEN>) id 1U3pHw-0008Ga-7T
	for 13648 <at> debbugs.gnu.org; Fri, 08 Feb 2013 09:50:56 -0500
Received: from mailout-de.gmx.net ([10.1.76.10]) by mrigmx.server.lan
	(mrigmx002) with ESMTP (Nemesis) id 0MUBZ6-1UUsb71VGE-00Qzib for
	<13648 <at> debbugs.gnu.org>; Fri, 08 Feb 2013 15:50:47 +0100
Received: (qmail invoked by alias); 08 Feb 2013 14:50:47 -0000
Received: from i59F55F9C.versanet.de (EHLO rosalinde.fritz.box) [89.245.95.156]
	by mail.gmx.net (mp010) with SMTP; 08 Feb 2013 15:50:47 +0100
X-Authenticated: #20778731
X-Provags-ID: V01U2FsdGVkX19mFOYfkihmJAqR+NZSfk44Ol2geb7AO82iFyMQoL
	92fk+YdOji3r6T
From: Stephen Berman <stephen.berman@HIDDEN>
To: Stefan Monnier <monnier@HIDDEN>
Subject: Re: bug#13648: 24.3.50; remove-overlays bugs
References: <8738x8b1pa.fsf@HIDDEN>
	<jwvhalocckh.fsf-monnier+emacs@HIDDEN>
	<87y5f09bpk.fsf@HIDDEN>
	<jwvpq0bbmyt.fsf-monnier+emacs@HIDDEN>
Date: Fri, 08 Feb 2013 15:50:45 +0100
In-Reply-To: <jwvpq0bbmyt.fsf-monnier+emacs@HIDDEN> (Stefan Monnier's message
	of "Thu, 07 Feb 2013 20:45:32 -0500")
Message-ID: <87r4kqvoze.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Y-GMX-Trusted: 0
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 13648
Cc: 13648 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.13
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -1.9 (-)

On Thu, 07 Feb 2013 20:45:32 -0500 Stefan Monnier <monnier@HIDDEN> wrote:

>> Damn, I get tripped up by that a lot.  And the fact that the empty
>> string is an exception doesn't help to keep the difference in mind.
>> Still, it is rather cumbersome to include appropriate let-bindings or
>> calls to overlay-get for each string value in each use of
>> remove-overlays, as opposed to adding a single equal-check to that.
>
> Generally the best solution is very different: add another property to
> every overlay.  E.g. smerge adds the property `smerge' with values like
> `conflict' or `refine', so you can then (remove-overlays beg end
> 'smerge 'refine) without caring about particular values of
> `after-string' or any other property.

Thanks, that sounds like a good strategy; I'll try it.

Steve Berman




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#13648; Package emacs. Full text available.

Message received at 13648 <at> debbugs.gnu.org:


Received: (at 13648) by debbugs.gnu.org; 8 Feb 2013 01:45:36 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Feb 07 20:45:36 2013
Received: from localhost ([127.0.0.1]:42692 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1U3d20-0000aH-8O
	for submit <at> debbugs.gnu.org; Thu, 07 Feb 2013 20:45:36 -0500
Received: from ironport2-out.teksavvy.com ([206.248.154.182]:20077)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <monnier@HIDDEN>) id 1U3d1y-0000a9-07
	for 13648 <at> debbugs.gnu.org; Thu, 07 Feb 2013 20:45:35 -0500
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result: Av8EABK/CFFFpZnt/2dsb2JhbABEuzWDWRdzgh4BAQQBViMFCws0EhQYDSQuh3AGwS2RCgOIYZwZgV6DFQ
X-IPAS-Result: Av8EABK/CFFFpZnt/2dsb2JhbABEuzWDWRdzgh4BAQQBViMFCws0EhQYDSQuh3AGwS2RCgOIYZwZgV6DFQ
X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; 
   d="scan'208";a="736381"
Received: from 69-165-153-237.dsl.teksavvy.com (HELO pastel.home)
	([69.165.153.237])
	by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA;
	07 Feb 2013 20:45:32 -0500
Received: by pastel.home (Postfix, from userid 20848)
	id 75D7D59042; Thu,  7 Feb 2013 20:45:32 -0500 (EST)
From: Stefan Monnier <monnier@HIDDEN>
To: Stephen Berman <stephen.berman@HIDDEN>
Subject: Re: bug#13648: 24.3.50; remove-overlays bugs
Message-ID: <jwvpq0bbmyt.fsf-monnier+emacs@HIDDEN>
References: <8738x8b1pa.fsf@HIDDEN>
	<jwvhalocckh.fsf-monnier+emacs@HIDDEN>
	<87y5f09bpk.fsf@HIDDEN>
Date: Thu, 07 Feb 2013 20:45:32 -0500
In-Reply-To: <87y5f09bpk.fsf@HIDDEN> (Stephen Berman's message of
	"Thu, 07 Feb 2013 20:16:07 +0100")
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 13648
Cc: 13648 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.13
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -1.9 (-)

> Damn, I get tripped up by that a lot.  And the fact that the empty
> string is an exception doesn't help to keep the difference in mind.
> Still, it is rather cumbersome to include appropriate let-bindings or
> calls to overlay-get for each string value in each use of
> remove-overlays, as opposed to adding a single equal-check to that.

Generally the best solution is very different: add another property to
every overlay.  E.g. smerge adds the property `smerge' with values like
`conflict' or `refine', so you can then (remove-overlays beg end
'smerge 'refine) without caring about particular values of
`after-string' or any other property.


        Stefan




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#13648; Package emacs. Full text available.

Message received at 13648 <at> debbugs.gnu.org:


Received: (at 13648) by debbugs.gnu.org; 7 Feb 2013 19:16:14 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Feb 07 14:16:14 2013
Received: from localhost ([127.0.0.1]:42316 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1U3WxB-0000jh-T6
	for submit <at> debbugs.gnu.org; Thu, 07 Feb 2013 14:16:14 -0500
Received: from mout.gmx.net ([212.227.15.18]:52891)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <stephen.berman@HIDDEN>) id 1U3Wx9-0000jY-2f
	for 13648 <at> debbugs.gnu.org; Thu, 07 Feb 2013 14:16:12 -0500
Received: from mailout-de.gmx.net ([10.1.76.17]) by mrigmx.server.lan
	(mrigmx002) with ESMTP (Nemesis) id 0MGDc1-1U89NN3npn-00FG7c for
	<13648 <at> debbugs.gnu.org>; Thu, 07 Feb 2013 20:16:10 +0100
Received: (qmail invoked by alias); 07 Feb 2013 19:16:10 -0000
Received: from i59F57850.versanet.de (EHLO rosalinde.fritz.box) [89.245.120.80]
	by mail.gmx.net (mp017) with SMTP; 07 Feb 2013 20:16:10 +0100
X-Authenticated: #20778731
X-Provags-ID: V01U2FsdGVkX1/d+KoxIffdbKT3Y6kgt5TnYnkdY6Udj4YZfdKoRP
	k7oDpTrwbJ7VXC
From: Stephen Berman <stephen.berman@HIDDEN>
To: Stefan Monnier <monnier@HIDDEN>
Subject: Re: bug#13648: 24.3.50; remove-overlays bugs
References: <8738x8b1pa.fsf@HIDDEN>
	<jwvhalocckh.fsf-monnier+emacs@HIDDEN>
Date: Thu, 07 Feb 2013 20:16:07 +0100
In-Reply-To: <jwvhalocckh.fsf-monnier+emacs@HIDDEN> (Stefan Monnier's message
	of "Thu, 07 Feb 2013 11:42:46 -0500")
Message-ID: <87y5f09bpk.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Y-GMX-Trusted: 0
X-Spam-Score: 0.8 (/)
X-Debbugs-Envelope-To: 13648
Cc: 13648 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.13
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -1.9 (-)

On Thu, 07 Feb 2013 11:42:46 -0500 Stefan Monnier <monnier@HIDDEN> wrote:

>> The reason for the first problem is that remove-overlays tests the
>> overlay value with eq, which fails for all strings [...]
>
> No, it won't fail on all strings.  You just need to pass it the same
> string you added to the overlay, rather than a copy of it.
> I.e. this is not a bug.

Damn, I get tripped up by that a lot.  And the fact that the empty
string is an exception doesn't help to keep the difference in mind.
Still, it is rather cumbersome to include appropriate let-bindings or
calls to overlay-get for each string value in each use of
remove-overlays, as opposed to adding a single equal-check to that.

>> invocation of remove-overlays is legitimate), the logic of the code is
>> that the NAME and VAL arguments are either both nil or both non-nil,
>
> Indeed.
>
>> which conflicts with the semantics of the &optional keyword.
>
> Right.  We should document it in the docstring.
>
>> This means that the last call of remove-overlays in the above sexp
>> would clear any after-string overlays, regardless of their value.
>
> Normally we don't distinguish "an property FOO of value nil" and "no
> property FOO".  So I think what would make sense is to say that if VAL
> is nil, then we remove any overlay whose NAME property is non-nil
> (i.e. the exact inverse from what we currently do).
>
> This said, the reason why I have not implemented this case of NAME being
> specified while VAL is left unspecified is because I haven't come up
> with a need for it.  So I'd be interested to hear the backstory of
> why/where you need it.

To be honest, I'm not sure I do need it.  I have code that inserts
before-string overlays with different values, some fixed and some
dynamically generated, and when these overlays need to be cleared, it
would be easier to just refer to the before-string property.  But the
way I use the overlays, it actually suffices to leave out both the
property and the value, i.e. just remove all overlays in the region.  At
first I thought that's not safe enough, because there could be other
other overlays at the same locations but with different properties, but
in fact I haven't needed that yet.  But I guess the main thing that
confused me was the conflict with the semantics of &optional, and since
it seems easy enough to avoid, I think it would be better than just
documenting the conflict.

Steve Berman




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#13648; Package emacs. Full text available.

Message received at 13648 <at> debbugs.gnu.org:


Received: (at 13648) by debbugs.gnu.org; 7 Feb 2013 16:44:13 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Feb 07 11:44:13 2013
Received: from localhost ([127.0.0.1]:42235 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1U3Ua4-0002xN-8a
	for submit <at> debbugs.gnu.org; Thu, 07 Feb 2013 11:44:13 -0500
Received: from chene.dit.umontreal.ca ([132.204.246.20]:58126)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <monnier@HIDDEN>) id 1U3Ua2-0002xG-15
	for 13648 <at> debbugs.gnu.org; Thu, 07 Feb 2013 11:44:11 -0500
Received: from faina.iro.umontreal.ca (lechon.iro.umontreal.ca
	[132.204.27.242])
	by chene.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id r17GglL0008932; 
	Thu, 7 Feb 2013 11:42:47 -0500
Received: by faina.iro.umontreal.ca (Postfix, from userid 20848)
	id DD941B4030; Thu,  7 Feb 2013 11:42:46 -0500 (EST)
From: Stefan Monnier <monnier@HIDDEN>
To: Stephen Berman <stephen.berman@HIDDEN>
Subject: Re: bug#13648: 24.3.50; remove-overlays bugs
Message-ID: <jwvhalocckh.fsf-monnier+emacs@HIDDEN>
References: <8738x8b1pa.fsf@HIDDEN>
Date: Thu, 07 Feb 2013 11:42:46 -0500
In-Reply-To: <8738x8b1pa.fsf@HIDDEN> (Stephen Berman's message of
	"Thu, 07 Feb 2013 16:09:21 +0100")
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-NAI-Spam-Flag: NO
X-NAI-Spam-Threshold: 5
X-NAI-Spam-Score: 0
X-NAI-Spam-Rules: 1 Rules triggered
	RV4485=0
X-NAI-Spam-Version: 2.2.0.9309 : core <4485> : streams <902226> : uri <1339299>
X-Spam-Score: -1.6 (-)
X-Debbugs-Envelope-To: 13648
Cc: 13648 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.13
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -3.5 (---)

> The reason for the first problem is that remove-overlays tests the
> overlay value with eq, which fails for all strings [...]

No, it won't fail on all strings.  You just need to pass it the same
string you added to the overlay, rather than a copy of it.
I.e. this is not a bug.

> invocation of remove-overlays is legitimate), the logic of the code is
> that the NAME and VAL arguments are either both nil or both non-nil,

Indeed.

> which conflicts with the semantics of the &optional keyword.

Right.  We should document it in the docstring.

> This means that the last call of remove-overlays in the above sexp
> would clear any after-string overlays, regardless of their value.

Normally we don't distinguish "an property FOO of value nil" and "no
property FOO".  So I think what would make sense is to say that if VAL
is nil, then we remove any overlay whose NAME property is non-nil
(i.e. the exact inverse from what we currently do).

This said, the reason why I have not implemented this case of NAME being
specified while VAL is left unspecified is because I haven't come up
with a need for it.  So I'd be interested to hear the backstory of
why/where you need it.


        Stefan




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#13648; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 7 Feb 2013 15:11:19 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Feb 07 10:11:19 2013
Received: from localhost ([127.0.0.1]:42166 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1U3T8A-0008La-Ix
	for submit <at> debbugs.gnu.org; Thu, 07 Feb 2013 10:11:19 -0500
Received: from eggs.gnu.org ([208.118.235.92]:46863)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <stephen.berman@HIDDEN>) id 1U3T86-0008LK-Kp
	for submit <at> debbugs.gnu.org; Thu, 07 Feb 2013 10:11:16 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <stephen.berman@HIDDEN>) id 1U3T6g-0002gX-Mw
	for submit <at> debbugs.gnu.org; Thu, 07 Feb 2013 10:09:52 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,
	RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD autolearn=unavailable version=3.3.2
Received: from lists.gnu.org ([208.118.235.17]:47890)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <stephen.berman@HIDDEN>) id 1U3T6g-0002gS-Ja
	for submit <at> debbugs.gnu.org; Thu, 07 Feb 2013 10:09:46 -0500
Received: from eggs.gnu.org ([208.118.235.92]:58134)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <stephen.berman@HIDDEN>) id 1U3T6Y-0004kP-GW
	for bug-gnu-emacs@HIDDEN; Thu, 07 Feb 2013 10:09:46 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <stephen.berman@HIDDEN>) id 1U3T6Q-0002b3-6d
	for bug-gnu-emacs@HIDDEN; Thu, 07 Feb 2013 10:09:38 -0500
Received: from mout.gmx.net ([212.227.17.20]:55620)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <stephen.berman@HIDDEN>) id 1U3T6P-0002aN-PC
	for bug-gnu-emacs@HIDDEN; Thu, 07 Feb 2013 10:09:30 -0500
Received: from mailout-de.gmx.net ([10.1.76.32]) by mrigmx.server.lan
	(mrigmx002) with ESMTP (Nemesis) id 0Lefrs-1Ujjw236BK-00qVqM for
	<bug-gnu-emacs@HIDDEN>; Thu, 07 Feb 2013 16:09:24 +0100
Received: (qmail invoked by alias); 07 Feb 2013 15:09:23 -0000
Received: from i59F57850.versanet.de (EHLO rosalinde.fritz.box) [89.245.120.80]
	by mail.gmx.net (mp032) with SMTP; 07 Feb 2013 16:09:23 +0100
X-Authenticated: #20778731
X-Provags-ID: V01U2FsdGVkX19ANI9hHi5AhGG6/6xy+9JNQtiI2nbPRK4qL94tkX
	OvuW6OqUyBCU9v
From: Stephen Berman <stephen.berman@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 24.3.50; remove-overlays bugs
Date: Thu, 07 Feb 2013 16:09:21 +0100
Message-ID: <8738x8b1pa.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-Y-GMX-Trusted: 0
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 208.118.235.17
X-Spam-Score: -6.9 (------)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.13
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -6.9 (------)

--=-=-=
Content-Type: text/plain

0. emacs -Q
1. Evaluate the following sexp:

   (progn
     (switch-to-buffer (get-buffer-create "*test*"))
     (insert "one two three")
     (setq ov1 (make-overlay 1 4))
     (setq ov2 (make-overlay 5 9))
     (setq ov3 (make-overlay 9 14))
     (sit-for 1)
     (overlay-put ov1 'display "two")
     (overlay-put ov2 'display "")
     (overlay-put ov3 'after-string " four")
     (sit-for 1)
     (remove-overlays nil nil 'display "two")
     (remove-overlays nil nil 'display "")
     (sit-for 1)
     (remove-overlays nil nil 'after-string))

In buffer *test* you see the following:

1. First:

one two three

2. Then after one second:

two three four

3. Then after another second:

two two three four

4. Finally, after one more second:

one two three four


I think the last two displays demonstrate buggy behavior.  In the third,
remove-overlays has failed to clear the display string "two" but has
cleared the empty string.  In the fourth, the remove-overlays call
specified the after-string property, yet what has been cleared is the
display overlay "two" but not the after-string overlay "four".  

The reason for the first problem is that remove-overlays tests the
overlay value with eq, which fails for all strings except the empty
string.  Hence, both the display overlay "two" and the after-string
overlay "four" are not cleared by the second and third calls of
remove-overlays, respectively.

But the third call does remove "two" because overlay-get tries to get
the value of the overlay's after-string property, but it only has a
display property, so overlay-get returns nil, and since the fourth
argument of remove-overlays is also nil here, they are eq, so the
overlay is cleared.  The general problem here, I believe, is that,
although all the arguments of remove-overlays are optional (so the last
invocation of remove-overlays is legitimate), the logic of the code is
that the NAME and VAL arguments are either both nil or both non-nil,
which conflicts with the semantics of the &optional keyword.

I think the easiest and best fix is to make the NAME and VAL arguments
conform to the &optional semantics by allowing independent values.  This
means that the last call of remove-overlays in the above sexp would
clear any after-string overlays, regardless of their value.  I think
this would be useful, and it is backward compatible, because all uses of
remove-overlays in Emacs have either both or neither of the NAME and VAL
arguments (and any third-party code that only has the NAME argument is
either buggy, like the above sexp, or works by chance).  The patch below
implements this, and also fixes the first problem by testing with equal
if the eq test fails.


2013-02-07  Stephen Berman  <stephen.berman@HIDDEN>

	* subr.el (remove-overlays): Handle string and list values of
	overlay properties.  If the property argument is non-nil and the
	value argument is nil, clear all overlays with that property
	regardless of their values.  (Bug#XXXXX)


--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline
Content-Description: remove-overlays patch

=== modified file 'lisp/subr.el'
*** lisp/subr.el	2013-02-03 16:13:36 +0000
--- lisp/subr.el	2013-02-07 14:45:09 +0000
***************
*** 2579,2585 ****
  (defun remove-overlays (&optional beg end name val)
    "Clear BEG and END of overlays whose property NAME has value VAL.
  Overlays might be moved and/or split.
! BEG and END default respectively to the beginning and end of buffer."
    ;; This speeds up the loops over overlays.
    (unless beg (setq beg (point-min)))
    (unless end (setq end (point-max)))
--- 2579,2589 ----
  (defun remove-overlays (&optional beg end name val)
    "Clear BEG and END of overlays whose property NAME has value VAL.
  Overlays might be moved and/or split.
! 
! BEG and END default respectively to the beginning and end of
! buffer.  If VAL is nil and NAME is non-nil, clear all NAME
! overlays regardless of their values.  If both NAME and VAL are
! nil, clear all overlays from BEG to END."
    ;; This speeds up the loops over overlays.
    (unless beg (setq beg (point-min)))
    (unless end (setq end (point-max)))
***************
*** 2588,2607 ****
        (setq beg (prog1 end (setq end beg))))
    (save-excursion
      (dolist (o (overlays-in beg end))
!       (when (eq (overlay-get o name) val)
! 	;; Either push this overlay outside beg...end
! 	;; or split it to exclude beg...end
! 	;; or delete it entirely (if it is contained in beg...end).
! 	(if (< (overlay-start o) beg)
  	    (if (> (overlay-end o) end)
! 		(progn
! 		  (move-overlay (copy-overlay o)
! 				(overlay-start o) beg)
! 		  (move-overlay o end (overlay-end o)))
! 	      (move-overlay o (overlay-start o) beg))
! 	  (if (> (overlay-end o) end)
! 	      (move-overlay o end (overlay-end o))
! 	    (delete-overlay o)))))))
  
  ;;;; Miscellanea.
  
--- 2592,2614 ----
        (setq beg (prog1 end (setq end beg))))
    (save-excursion
      (dolist (o (overlays-in beg end))
!       (let ((v (overlay-get o name)))
! 	;; An overlay property value can be not just a symbol,
! 	;; but also a string or a list.
! 	(when (if val (or (eq v val) (equal v val)) name)
! 	  ;; Either push this overlay outside beg...end
! 	  ;; or split it to exclude beg...end
! 	  ;; or delete it entirely (if it is contained in beg...end).
! 	  (if (< (overlay-start o) beg)
! 	      (if (> (overlay-end o) end)
! 		  (progn
! 		    (move-overlay (copy-overlay o)
! 				  (overlay-start o) beg)
! 		    (move-overlay o end (overlay-end o)))
! 		(move-overlay o (overlay-start o) beg))
  	    (if (> (overlay-end o) end)
! 		(move-overlay o end (overlay-end o))
! 	      (delete-overlay o))))))))
  
  ;;;; Miscellanea.
  


--=-=-=
Content-Type: text/plain



In GNU Emacs 24.3.50.6 (x86_64-suse-linux-gnu, GTK+ Version 3.4.4)
 of 2013-02-07 on rosalinde
Bzr revision: 111689 michael.albinus@HIDDEN
Windowing system distributor `The X.Org Foundation', version 11.0.11203000
System Description:	openSUSE 12.2 (x86_64)

Configured using:
 `configure --without-toolkit-scroll-bars CFLAGS=-g3 -O0 --no-create
 --no-recursion'

Important settings:
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=local
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

--=-=-=--




Acknowledgement sent to Stephen Berman <stephen.berman@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#13648; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Fri, 31 Oct 2014 17:00:04 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.