all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#60058: 29.0.60; overlay-lists does not conform to its docstring
@ 2022-12-14  5:22 Kai Ma
  2022-12-14 12:23 ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Kai Ma @ 2022-12-14  5:22 UTC (permalink / raw)
  To: 60058

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





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#60058: 29.0.60; overlay-lists does not conform to its docstring
  2022-12-14  5:22 bug#60058: 29.0.60; overlay-lists does not conform to its docstring Kai Ma
@ 2022-12-14 12:23 ` Eli Zaretskii
  2022-12-14 14:21   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2022-12-14 12:23 UTC (permalink / raw)
  To: Kai Ma, Lars Ingebrigtsen, Stefan Monnier; +Cc: 60058

> From: Kai Ma <justksqsf@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?





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#60058: 29.0.60; overlay-lists does not conform to its docstring
  2022-12-14 12:23 ` Eli Zaretskii
@ 2022-12-14 14:21   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-12-14 18:19     ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-12-14 14:21 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 60058, Kai Ma, Lars Ingebrigtsen

> 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






^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#60058: 29.0.60; overlay-lists does not conform to its docstring
  2022-12-14 14:21   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-12-14 18:19     ` Eli Zaretskii
  0 siblings, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2022-12-14 18:19 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: justksqsf, 60058-done, larsi

> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Cc: Kai Ma <justksqsf@gmail.com>,  Lars Ingebrigtsen <larsi@gnus.org>,
>   60058@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.





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-12-14 18:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-14  5:22 bug#60058: 29.0.60; overlay-lists does not conform to its docstring Kai Ma
2022-12-14 12:23 ` Eli Zaretskii
2022-12-14 14:21   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-14 18:19     ` Eli Zaretskii

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.