unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Joakim Jalap <joakim.jalap@fastmail.com>
To: emacs-devel@gnu.org
Subject: A question about overlay-modification
Date: Thu, 24 Nov 2016 13:42:24 +0100	[thread overview]
Message-ID: <87inrdgibz.fsf@fastmail.com> (raw)

Hello Emacs devs!

I'm trodding along with my overlays rewrite, and the turn has come to
`report_overlay_modification'. I'm having a bit of a hard time parsing
the docstring and the code. The docstring says the following:

/* Run the modification-hooks of overlays that include
   any part of the text in START to END.
   If this change is an insertion, also
   run the insert-before-hooks of overlay starting at END,
   and the insert-after-hooks of overlay ending at START.

   This is called both before and after the modification.
   AFTER is true when we call after the modification.

   ARG1, ARG2, ARG3 are arguments to pass to the hook functions.
   When AFTER is nonzero, they are the start position,
   the position after the inserted new text,
   and the length of deleted or replaced old text.  */

And the code does the following:

#+begin_src C
  ptrdiff_t startpos, endpos;
  Lisp_Object ostart, oend;

  XSETMISC (overlay, tail);

  ostart = OVERLAY_START (overlay);
  oend = OVERLAY_END (overlay);
  endpos = OVERLAY_POSITION (oend);
  if (XFASTINT (start) > endpos)
    break;
  startpos = OVERLAY_POSITION (ostart);
  if (insertion && (XFASTINT (start) == startpos
		    || XFASTINT (end) == startpos))
    {
      prop = Foverlay_get (overlay, Qinsert_in_front_hooks);
      if (!NILP (prop))
	add_overlay_mod_hooklist (prop, overlay);
    }
  if (insertion && (XFASTINT (start) == endpos
		    || XFASTINT (end) == endpos))
    {
      prop = Foverlay_get (overlay, Qinsert_behind_hooks);
      if (!NILP (prop))
	add_overlay_mod_hooklist (prop, overlay);
    }
#+end_src

To me that looks like the insert-in-front-hooks get run for overlays
which start either at START or END, not only those which start at
END. Likewise (but the other way around) for insert-behind-hooks.

This was introduced in commit 9115729ea3ea049e00e9e72cae09095c593e131a
back in 1995. Before that, it looked more like what I would have
expected.

What am I missing here? When I rewrite it I guess I'll make it match
what's there now since it's been there for more than 20 years, but I'd
just like to understand what's going on.

(As an aside, the doc string mentions insert-before-hooks and
insert-after-hooks, while the code has Qinsert_in_front_hooks and
Qinsert_behind_hooks. Is this intentional or just left overs?)

-- Joakim



             reply	other threads:[~2016-11-24 12:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-24 12:42 Joakim Jalap [this message]
2016-11-24 16:57 ` A question about overlay-modification Eli Zaretskii
2016-11-25  8:39   ` Joakim Jalap
2016-11-25 10:14     ` 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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=87inrdgibz.fsf@fastmail.com \
    --to=joakim.jalap@fastmail.com \
    --cc=emacs-devel@gnu.org \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).