From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Joakim Jalap Newsgroups: gmane.emacs.devel Subject: A question about overlay-modification Date: Thu, 24 Nov 2016 13:42:24 +0100 Message-ID: <87inrdgibz.fsf@fastmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1479991362 31397 195.159.176.226 (24 Nov 2016 12:42:42 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 24 Nov 2016 12:42:42 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (berkeley-unix) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Nov 24 13:42:36 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c9tMJ-00070n-DH for ged-emacs-devel@m.gmane.org; Thu, 24 Nov 2016 13:42:35 +0100 Original-Received: from localhost ([::1]:39518 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c9tMN-00069p-1o for ged-emacs-devel@m.gmane.org; Thu, 24 Nov 2016 07:42:39 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34076) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c9tMF-00067Y-E1 for emacs-devel@gnu.org; Thu, 24 Nov 2016 07:42:32 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c9tMC-0006mz-BX for emacs-devel@gnu.org; Thu, 24 Nov 2016 07:42:31 -0500 Original-Received: from out5-smtp.messagingengine.com ([66.111.4.29]:58908) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c9tMC-0006mH-5F for emacs-devel@gnu.org; Thu, 24 Nov 2016 07:42:28 -0500 Original-Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id F3F61207EE for ; Thu, 24 Nov 2016 07:42:25 -0500 (EST) Original-Received: from frontend2 ([10.202.2.161]) by compute4.internal (MEProxy); Thu, 24 Nov 2016 07:42:25 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.com; h= content-type:date:from:message-id:mime-version:subject:to :x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=z9j ntfj7TS6xEy8Se8Mi0lagEBQ=; b=CLJlEOxc8XGJvjFx70Vm2nQ6Na2Koo00BsG +VjmIvMyMtnP46rWl3RJsLiq/9Mc0+CQ+R/3qZjn7dgLXFiyZQ6Wyr74lLF3Om6Q tfb54BiGfa0I5xSmYoBt5j3m51BptG2fACX3f2JoPgLwa5QKCrcKx22iyhTrfftt yQtqfcqI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:message-id :mime-version:subject:to:x-me-sender:x-me-sender:x-sasl-enc :x-sasl-enc; s=smtpout; bh=z9jntfj7TS6xEy8Se8Mi0lagEBQ=; b=ABMJi sXI0QUz1TD3OyyuZyj2KvGaoQurEI9M5qbPsIrjzmhboG8D4BYo4Q3mbfKJ1Obb9 idPk4J995LunjNmoBp6XS1TjvAqKCif9DQLLPWVzaJAaNK1PYIxPAAuivlONLVdL Wv75DWfOe5DPGGdRW7o6Us4YlbpNCI/tsuqiIw= X-ME-Sender: X-Sasl-enc: xRuGcbuPrt2GrC0x87To5IO72MB7WqoRCjbyrvVAEAEo 1479991345 Original-Received: from genserv (unknown [5.150.202.248]) by mail.messagingengine.com (Postfix) with ESMTPA id 6C4C024CD3 for ; Thu, 24 Nov 2016 07:42:25 -0500 (EST) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.111.4.29 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:209576 Archived-At: 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