all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: "Clément Pit--Claudel" <clement.pitclaudel@live.com>
Cc: 25592@debbugs.gnu.org
Subject: bug#25592: Feature request: sorting overlays
Date: Sat, 04 Feb 2017 10:13:08 +0200	[thread overview]
Message-ID: <83r33etluz.fsf@gnu.org> (raw)
In-Reply-To: <1d90ade3-b0a4-f07a-d424-b052a68fd4a7@live.com> (message from Clément Pit--Claudel on Fri, 3 Feb 2017 16:51:24 -0500)

> Cc: 25592@debbugs.gnu.org
> From: Clément Pit--Claudel <clement.pitclaudel@live.com>
> Date: Fri, 3 Feb 2017 16:51:24 -0500
> 
> >> No: I'm iterating over all overlays, and applying them one by one.
> > 
> > Why not do it as I suggest?  Then your problems with sorting will be
> > solved as a nice side-effect.
> 
> I'm worried about the cost and the additional implementation complexity.  My current algorithm is very simple: iterate over overlays, applying their properties to the ranges they cover.  In contrast, scanning over overlays introduces additional complexity (I need to keep track of which overlays I have already applied and move around the buffer), and additional costs (next-overlay-change seems to do quite a bit of work).

Why would you need to keep track of overlays, if you always process
each one just once?

As for costs, next-overlay-change (or one of its variants) is used by
the display engine in its inner loops (see
compute_display_string_pos), so it should be fast enough for your
needs, I think.

> None of this is a show stopper (in fact, I don't even know for sure that the slowdown would be significant, and I do know that I don't expect to have that many overlays anyway :), but it'd be nice to be able to use the "simpler" solution.

But the "simpler" solution has a problem, whereby the order of the
overlays might depend on buffer position for which you evaluate the
order, because overlays could begin at the same position, but end at
different ones, or vice versa.  IOW, the overlaps between portions of
the buffer text "covered" by different overlays could be partial.  How
do you handle this situation in your algorithm?  The correct solution
would require having different values of the corresponding text
property for different locations, according to the highest-priority
overlay at each location.  Am I missing something?

> >>> How did you implement in Lisp the "last resort" of comparison, which
> >>> compares addresses of the C structs?
> >>
> >> I didn't :)
> > 
> > So it isn't really a solution ;-)
> 
> It's not a full reimplementation, but it's enough of a solution for me :) The docs say “If SORTED is non-‘nil’, the list is in decreasing order of priority”, and that's what my implementation does.

Then there will be use cases where your solution will give a wrong
value to the text property that replaces the overlays.





  reply	other threads:[~2017-02-04  8:13 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-31 20:32 bug#25592: Feature request: sorting overlays Clément Pit--Claudel
2017-02-01 13:01 ` Eli Zaretskii
2017-02-02 19:41   ` Clément Pit--Claudel
2017-02-02 20:43     ` Eli Zaretskii
2017-02-03 15:19       ` Clément Pit--Claudel
2017-02-03 21:17         ` Eli Zaretskii
2017-02-03 21:51           ` Clément Pit--Claudel
2017-02-04  8:13             ` Eli Zaretskii [this message]
2017-02-05 16:21               ` Clément Pit--Claudel
2017-02-05 18:28                 ` Eli Zaretskii
2017-02-05 19:10                   ` Clément Pit--Claudel
2017-02-05 19:43                     ` Eli Zaretskii
2017-02-05 19:51                       ` Clément Pit--Claudel
2017-02-07 17:13                         ` Eli Zaretskii
2017-02-07 19:17                           ` Clément Pit--Claudel
2017-02-07 19:56                             ` Eli Zaretskii
2017-02-07 20:07                               ` Clément Pit--Claudel
2017-02-08 17:22                                 ` Eli Zaretskii
2017-02-09 19:50                                   ` Clément Pit--Claudel
2017-02-03 23:28       ` Johan Bockgård
2017-02-04  8:29         ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83r33etluz.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=25592@debbugs.gnu.org \
    --cc=clement.pitclaudel@live.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.