GNU bug report logs - #8657
24.0.50; Emacs code that seems to use `*-single-char-property-change' incorrectly

Previous Next

Package: emacs;

Reported by: "Drew Adams" <drew.adams <at> oracle.com>

Date: Wed, 11 May 2011 20:56:02 UTC

Severity: minor

Tags: notabug

Found in version 24.0.50

Done: Chong Yidong <cyd <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 8657 in the body.
You can then email your comments to 8657 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8657; Package emacs. (Wed, 11 May 2011 20:56:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to "Drew Adams" <drew.adams <at> oracle.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 11 May 2011 20:56:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: "Drew Adams" <drew.adams <at> oracle.com>
To: <bug-gnu-emacs <at> gnu.org>
Subject: 24.0.50; Emacs code that seems to use `*-single-char-property-change'
	incorrectly
Date: Wed, 11 May 2011 13:54:57 -0700
`(next|previous)-single-char-property-change' behaves differently in a
couple of ways from `(next|previous)-single-property-change', besides
the difference of overlay vs text properties.
 
In particular, IIUC, the return value can never be nil.
Yet I see code such as this:
 
gnus-summary-show-thread:
(or (next-single-char-property-change end 'invisible) (point-max))
 
comint-next-prompt:
(setq pos (next-single-char-property-change pos 'field))
(cond (or (null pos)...
 
Isn't this incorrect?

In GNU Emacs 24.0.50.1 (i386-mingw-nt5.1.2600)
 of 2011-05-10 on 3249CTO
Windowing system distributor `Microsoft Corp.', version 5.1.2600
configured using `configure --with-gcc (4.5) --no-opt --cflags
-Ic:/build/include'
 





Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8657; Package emacs. (Thu, 12 May 2011 03:06:02 GMT) Full text and rfc822 format available.

Message #8 received at 8657 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: "Drew Adams" <drew.adams <at> oracle.com>
Cc: 8657 <at> debbugs.gnu.org
Subject: Re: bug#8657: 24.0.50;
	Emacs code that seems to use `*-single-char-property-change'
	incorrectly
Date: Thu, 12 May 2011 00:05:46 -0300
> In particular, IIUC, the return value can never be nil.
> Yet I see code such as this:
 
> gnus-summary-show-thread:
> (or (next-single-char-property-change end 'invisible) (point-max))
 
> comint-next-prompt:
> (setq pos (next-single-char-property-change pos 'field))
> (cond (or (null pos)...
 
> Isn't this incorrect?

The behavior might have changed at some point in time, explaining the
above code.


        Stefan




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8657; Package emacs. (Thu, 12 May 2011 04:45:03 GMT) Full text and rfc822 format available.

Message #11 received at 8657 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 8657 <at> debbugs.gnu.org, drew.adams <at> oracle.com
Subject: Re: bug#8657: 24.0.50;
	Emacs code that seems to use `*-single-char-property-change'
	incorrectly
Date: Thu, 12 May 2011 00:44:33 -0400
> From: Stefan Monnier <monnier <at> iro.umontreal.ca>
> Date: Thu, 12 May 2011 00:05:46 -0300
> Cc: 8657 <at> debbugs.gnu.org
> 
> > In particular, IIUC, the return value can never be nil.
> > Yet I see code such as this:
>  
> > gnus-summary-show-thread:
> > (or (next-single-char-property-change end 'invisible) (point-max))
>  
> > comint-next-prompt:
> > (setq pos (next-single-char-property-change pos 'field))
> > (cond (or (null pos)...
>  
> > Isn't this incorrect?
> 
> The behavior might have changed at some point in time, explaining the
> above code.

Or maybe the author was confusing next-single-char-property-change
with next-single-property-change.

In any case, those tests are redundant, because
next-single-char-property-change already returns point-max when it
finds no change in properties.




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8657; Package emacs. (Thu, 12 May 2011 13:45:02 GMT) Full text and rfc822 format available.

Message #14 received at 8657 <at> debbugs.gnu.org (full text, mbox):

From: "Drew Adams" <drew.adams <at> oracle.com>
To: "'Eli Zaretskii'" <eliz <at> gnu.org>,
	"'Stefan Monnier'" <monnier <at> iro.umontreal.ca>
Cc: 8657 <at> debbugs.gnu.org
Subject: RE: bug#8657: 24.0.50; Emacs code that seems to use
	`*-single-char-property-change'incorrectly
Date: Thu, 12 May 2011 06:44:22 -0700
> Or maybe the author was confusing next-single-char-property-change
> with next-single-property-change.
> 
> In any case, those tests are redundant, because
> next-single-char-property-change already returns point-max when it
> finds no change in properties.

Yes, what Eli says is what I was suggesting; that's my guess too.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#8657; Package emacs. (Mon, 06 Feb 2012 14:02:01 GMT) Full text and rfc822 format available.

Message #17 received at 8657 <at> debbugs.gnu.org (full text, mbox):

From: Chong Yidong <cyd <at> gnu.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 8657 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>,
	drew.adams <at> oracle.com
Subject: Re: bug#8657: 24.0.50;
	Emacs code that seems to use `*-single-char-property-change'
	incorrectly
Date: Mon, 06 Feb 2012 22:00:21 +0800
Eli Zaretskii <eliz <at> gnu.org> writes:

>> The behavior might have changed at some point in time, explaining the
>> above code.
>
> Or maybe the author was confusing next-single-char-property-change
> with next-single-property-change.
>
> In any case, those tests are redundant, because
> next-single-char-property-change already returns point-max when it
> finds no change in properties.

I went ahead and fixed them accordingly.




bug closed, send any further explanations to 8657 <at> debbugs.gnu.org and "Drew Adams" <drew.adams <at> oracle.com> Request was from Chong Yidong <cyd <at> gnu.org> to control <at> debbugs.gnu.org. (Mon, 06 Feb 2012 14:02:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#8657; Package emacs. (Mon, 06 Feb 2012 22:58:02 GMT) Full text and rfc822 format available.

Message #22 received at 8657 <at> debbugs.gnu.org (full text, mbox):

From: Katsumi Yamaoka <yamaoka <at> jpl.org>
To: Chong Yidong <cyd <at> gnu.org>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 8657 <at> debbugs.gnu.org
Subject: Re: bug#8657: 24.0.50;
	Emacs code that seems to use `*-single-char-property-change'
	incorrectly
Date: Tue, 07 Feb 2012 07:56:54 +0900
Chong Yidong wrote:
> Eli Zaretskii <eliz <at> gnu.org> writes:
>>> The behavior might have changed at some point in time, explaining the
>>> above code.
>>
>> Or maybe the author was confusing next-single-char-property-change
>> with next-single-property-change.
>>
>> In any case, those tests are redundant, because
>> next-single-char-property-change already returns point-max when it
>> finds no change in properties.

> I went ahead and fixed them accordingly.

But in XEmacs next-single-char-property-change will return nil
if no property change is found.  So I've modified the gnus-sum.el
code into:

  (if (featurep 'xemacs)
      (or (next-single-char-property-change end 'invisible)
          (point-max))
    (next-single-char-property-change end 'invisible))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#8657; Package emacs. (Tue, 07 Feb 2012 05:59:01 GMT) Full text and rfc822 format available.

Message #25 received at 8657 <at> debbugs.gnu.org (full text, mbox):

From: Chong Yidong <cyd <at> gnu.org>
To: Katsumi Yamaoka <yamaoka <at> jpl.org>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 8657 <at> debbugs.gnu.org
Subject: Re: bug#8657: 24.0.50;
	Emacs code that seems to use `*-single-char-property-change'
	incorrectly
Date: Tue, 07 Feb 2012 13:57:45 +0800
Katsumi Yamaoka <yamaoka <at> jpl.org> writes:

> But in XEmacs next-single-char-property-change will return nil
> if no property change is found.

Ah OK, thanks for checking.

> So I've modified the gnus-sum.el code into:
>
>   (if (featurep 'xemacs)
>       (or (next-single-char-property-change end 'invisible)
>           (point-max))
>     (next-single-char-property-change end 'invisible))

I suggest just restoring the old code, and adding a comment about why
the `or' is there.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#8657; Package emacs. (Tue, 07 Feb 2012 06:35:02 GMT) Full text and rfc822 format available.

Message #28 received at 8657 <at> debbugs.gnu.org (full text, mbox):

From: Katsumi Yamaoka <yamaoka <at> jpl.org>
To: Chong Yidong <cyd <at> gnu.org>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 8657 <at> debbugs.gnu.org
Subject: Re: bug#8657: 24.0.50;
	Emacs code that seems to use `*-single-char-property-change'
	incorrectly
Date: Tue, 07 Feb 2012 15:34:01 +0900
Chong Yidong wrote:
> Katsumi Yamaoka <yamaoka <at> jpl.org> writes:

>> But in XEmacs next-single-char-property-change will return nil
>> if no property change is found.

> Ah OK, thanks for checking.

>> So I've modified the gnus-sum.el code into:
>>
>>   (if (featurep 'xemacs)
>>       (or (next-single-char-property-change end 'invisible)
>>           (point-max))
>>     (next-single-char-property-change end 'invisible))

> I suggest just restoring the old code, and adding a comment about why
> the `or' is there.

Ok.  Done.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 06 Mar 2012 12:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 12 years and 59 days ago.

Previous Next


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