GNU bug report logs - #60058
29.0.60; overlay-lists does not conform to its docstring

Previous Next

Package: emacs;

Reported by: Kai Ma <justksqsf <at> gmail.com>

Date: Wed, 14 Dec 2022 05:23:02 UTC

Severity: normal

Found in version 29.0.60

Done: Eli Zaretskii <eliz <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 60058 in the body.
You can then email your comments to 60058 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 bug-gnu-emacs <at> gnu.org:
bug#60058; Package emacs. (Wed, 14 Dec 2022 05:23:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Kai Ma <justksqsf <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 14 Dec 2022 05:23:02 GMT) Full text and rfc822 format available.

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

From: Kai Ma <justksqsf <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 29.0.60; overlay-lists does not conform to its docstring
Date: Wed, 14 Dec 2022 13:22:07 +0800
The docstring of overlay-lists states that the return value is a cons
pair, and the CDR is not always nil.  However, the code does not do what
it claims to do.

    DEFUN ("overlay-lists", Foverlay_lists, Soverlay_lists, 0, 0, 0,
           doc: /* Return a pair of lists giving all the overlays of the current buffer.
    The car has all the overlays before the overlay center;
    the cdr has all the overlays after the overlay center.
    Recentering overlays moves overlays between these lists.
    The lists you get are copies, so that changing them has no effect.
    However, the overlays you get are the real objects that the buffer uses. */)
      (void)
    {
      Lisp_Object overlays = Qnil;
      struct itree_node *node;
    
      ITREE_FOREACH (node, current_buffer->overlays, BEG, Z, DESCENDING)
        overlays = Fcons (node->data, overlays);
    
      return Fcons (overlays, Qnil);
    }

This change in behavior has led to at least one breakage in the wild:
symbol-overlay cannot count overlays correctly.

I think there is a problem either in the code or in the docstring.

	Kai




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60058; Package emacs. (Wed, 14 Dec 2022 12:24:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Kai Ma <justksqsf <at> gmail.com>, Lars Ingebrigtsen <larsi <at> gnus.org>,
 Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 60058 <at> debbugs.gnu.org
Subject: Re: bug#60058: 29.0.60;
 overlay-lists does not conform to its docstring
Date: Wed, 14 Dec 2022 14:23:31 +0200
> From: Kai Ma <justksqsf <at> gmail.com>
> Date: Wed, 14 Dec 2022 13:22:07 +0800
> 
> The docstring of overlay-lists states that the return value is a cons
> pair, and the CDR is not always nil.  However, the code does not do what
> it claims to do.
> 
>     DEFUN ("overlay-lists", Foverlay_lists, Soverlay_lists, 0, 0, 0,
>            doc: /* Return a pair of lists giving all the overlays of the current buffer.
>     The car has all the overlays before the overlay center;
>     the cdr has all the overlays after the overlay center.
>     Recentering overlays moves overlays between these lists.
>     The lists you get are copies, so that changing them has no effect.
>     However, the overlays you get are the real objects that the buffer uses. */)
>       (void)
>     {
>       Lisp_Object overlays = Qnil;
>       struct itree_node *node;
>     
>       ITREE_FOREACH (node, current_buffer->overlays, BEG, Z, DESCENDING)
>         overlays = Fcons (node->data, overlays);
>     
>       return Fcons (overlays, Qnil);
>     }
> 
> This change in behavior has led to at least one breakage in the wild:
> symbol-overlay cannot count overlays correctly.
> 
> I think there is a problem either in the code or in the docstring.

The problem is not in overlay-lists, IMO, the problem (if there is
one) is in overlay-recenter: it is a no-op in Emacs 29 and later.

I think we have two alternatives:

  . reimplement overlay-recenter for the new overlay representation
  . document that overlay-recenter is a no-op, as an incompatible Lisp
    change, and recommend that Lisp program simply stop relying on its
    effect in Emacs >= 29: after all, the sole purpose of that
    function was to speed up overlay access, and now this is not needed

I tend to do the latter.  Lars, Stefan, any ideas or comments?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60058; Package emacs. (Wed, 14 Dec 2022 14:22:01 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 60058 <at> debbugs.gnu.org, Kai Ma <justksqsf <at> gmail.com>,
 Lars Ingebrigtsen <larsi <at> gnus.org>
Subject: Re: bug#60058: 29.0.60; overlay-lists does not conform to its
 docstring
Date: Wed, 14 Dec 2022 09:21:44 -0500
> The problem is not in overlay-lists, IMO, the problem (if there is
> one) is in overlay-recenter: it is a no-op in Emacs 29 and later.

The use of `overlay-recenter` together with `overlay-lists` took me
by surprise.  So yes, I think we should document that `overlay-recenter`
is a no-op.  We should also mark it obsolete.

The code for `symbol-overlay-get-list` should likely use
`overlays-in` instead.


        Stefan





Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Wed, 14 Dec 2022 18:20:01 GMT) Full text and rfc822 format available.

Notification sent to Kai Ma <justksqsf <at> gmail.com>:
bug acknowledged by developer. (Wed, 14 Dec 2022 18:20:01 GMT) Full text and rfc822 format available.

Message #16 received at 60058-done <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: justksqsf <at> gmail.com, 60058-done <at> debbugs.gnu.org, larsi <at> gnus.org
Subject: Re: bug#60058: 29.0.60; overlay-lists does not conform to its
 docstring
Date: Wed, 14 Dec 2022 20:19:39 +0200
> From: Stefan Monnier <monnier <at> iro.umontreal.ca>
> Cc: Kai Ma <justksqsf <at> gmail.com>,  Lars Ingebrigtsen <larsi <at> gnus.org>,
>   60058 <at> debbugs.gnu.org
> Date: Wed, 14 Dec 2022 09:21:44 -0500
> 
> > The problem is not in overlay-lists, IMO, the problem (if there is
> > one) is in overlay-recenter: it is a no-op in Emacs 29 and later.
> 
> The use of `overlay-recenter` together with `overlay-lists` took me
> by surprise.  So yes, I think we should document that `overlay-recenter`
> is a no-op.  We should also mark it obsolete.

I didn't mark it obsolete yet.  Having Emacs 29.1 annoy programs that
call a function that is a no-op, and adding that so close to the
release, sounds like not the best idea.  Maybe we should consider
obsoleting it in Emacs 30.

Otherwise, I did update the documentation to be consistent with the
new implementation of the overlays (see also bug#59996), and I'm
therefore closing this bug report.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 12 Jan 2023 12:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 241 days ago.

Previous Next


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