From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.bugs Subject: bug#25111: (Inaccurate documentation of inhibit-modification-hooks) Date: Sat, 25 May 2019 08:39:39 -0400 Message-ID: <87y32u908k.fsf@gmail.com> References: <8360myl7ay.fsf@gnu.org> <87wpfbpual.fsf@russet.org.uk> <83eg1iiffm.fsf@gnu.org> <87pol1kon4.fsf@russet.org.uk> <83bmwlggix.fsf@gnu.org> <878trmxgjh.fsf@russet.org.uk> <83lgvlcet1.fsf@gnu.org> <20190519203119.GA5309@ACM> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="269124"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) Cc: 25111@debbugs.gnu.org, Phillip Lord To: Alan Mackenzie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat May 25 14:40:23 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hUVyI-0017se-Bh for geb-bug-gnu-emacs@m.gmane.org; Sat, 25 May 2019 14:40:22 +0200 Original-Received: from localhost ([127.0.0.1]:40676 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hUVyH-0008PS-BL for geb-bug-gnu-emacs@m.gmane.org; Sat, 25 May 2019 08:40:21 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:38456) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hUVy4-0008Ce-9R for bug-gnu-emacs@gnu.org; Sat, 25 May 2019 08:40:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hUVy1-0003I5-F0 for bug-gnu-emacs@gnu.org; Sat, 25 May 2019 08:40:08 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:34806) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hUVy0-0003Fa-C1 for bug-gnu-emacs@gnu.org; Sat, 25 May 2019 08:40:05 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hUVy0-000310-77 for bug-gnu-emacs@gnu.org; Sat, 25 May 2019 08:40:04 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 25 May 2019 12:40:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 25111 X-GNU-PR-Package: emacs Original-Received: via spool by 25111-submit@debbugs.gnu.org id=B25111.155878799511539 (code B ref 25111); Sat, 25 May 2019 12:40:04 +0000 Original-Received: (at 25111) by debbugs.gnu.org; 25 May 2019 12:39:55 +0000 Original-Received: from localhost ([127.0.0.1]:48345 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hUVxq-000302-PF for submit@debbugs.gnu.org; Sat, 25 May 2019 08:39:55 -0400 Original-Received: from mail-it1-f174.google.com ([209.85.166.174]:54402) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hUVxo-0002zl-KI for 25111@debbugs.gnu.org; Sat, 25 May 2019 08:39:53 -0400 Original-Received: by mail-it1-f174.google.com with SMTP id h20so20158106itk.4 for <25111@debbugs.gnu.org>; Sat, 25 May 2019 05:39:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=uf5XYfF8WiCY0eU8xQG8im59dlRrinCL9MBYhMtztvA=; b=il2nmYyktVWBB44D9xDVG3e/VjyxpIgc5HwC710CBS9eOcggj0J8Rj7gLXIZif6t7f hdf0NMK8VlF+E03AwszBEUwmV+QUHlCzj+6RY9ril472B7YiKTgIOdUD4oSkonU1kRTn xtuvXpklvVnCcXUrdfnuoxt9Jt/7/4FPAPDrhxdVqJVh6TP8DHPO4b3FnaZrqxkG5Ygq 3ubgc+iOaQb+lfqo1CCVYtR1Pd1TwB8sPCeQXElaZZeMMEqSQpf/IoTfTiB8O251WrSK YGlOJHjR3w3PPisNjx4tsvTbKMQmr/qMYQMFzM3/lJlvS29IbPVx/DGPhFmcCKEe2vL6 m7LA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=uf5XYfF8WiCY0eU8xQG8im59dlRrinCL9MBYhMtztvA=; b=ESAXQKxakhuIG76z3o2ZV4A4iD0TV+5OTcVOxi8Fqn1Tfl1MkAdDWbzV6J6TAj15YW VqR01C4tBpL3q/OoVujyEjF3RhnFV8M4n7R4MuZZ90Nrq6zKQgTeYCGUKJ83OnvCcRBI gL1j+P2ABXqUXyX6mm+cUi8CMumQn4/0BLBijAzug4yRHXteBYYIxf3WBK1l0FIj0VBs 7UEiBRC1zPftAC+/SNKcudF0/i37FHM4YCj5V9YVYQmmdfGd3e/DRCgLCbVKt4CaeQHY gkFauq/mCr47FMJT30qGIDgTVDOoCPUKtd1jXCTxry6O2Bcayaq/GAn9MW14sijr/bYk 8WGw== X-Gm-Message-State: APjAAAUjjfhlFgDthcMfufsKkvXk8voC0tagy1cw6/HyNHhiQ/suoO/3 shc8emhAtkUqOWRDdcdiIGL3+YOF X-Google-Smtp-Source: APXvYqwFXASWn8Fyj0SwcicJ7FBlWQZQV4UlSWaZa13d2ulXAtpYEY++50QUfxpasxvi4PPODsFaSg== X-Received: by 2002:a24:4cd2:: with SMTP id a201mr23721349itb.26.1558787986949; Sat, 25 May 2019 05:39:46 -0700 (PDT) Original-Received: from minid (cbl-45-2-119-34.yyz.frontiernetworks.ca. [45.2.119.34]) by smtp.gmail.com with ESMTPSA id k7sm1760569ioh.36.2019.05.25.05.39.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 25 May 2019 05:39:45 -0700 (PDT) In-Reply-To: <20190519203119.GA5309@ACM> (Alan Mackenzie's message of "Sun, 19 May 2019 20:31:19 +0000") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:159750 Archived-At: --=-=-= Content-Type: text/plain Alan Mackenzie writes: > @@ -1743,9 +1743,17 @@ Overlay Properties > However, doing this can sometimes confuse the internal > +mechanism that calls all these hooks, leading, for example, to calling > +them recursively, which is usually unwanted. > @@ -3621,9 +3621,14 @@ Special Properties > +When Emacs calls these functions, @code{inhibit-modification-hooks} is > +set to @code{nil}. As Phillip mentioned in the OP, Emacs in fact binds it to t. > If the functions modify the buffer, you should > +consider binding this variable to non-@code{nil}, to avoid confusing > +the internal mechanism that calls these hooks. @xref{Change Hooks}. I find this "confusing the internal mechanism" thing unhelpful, how about this instead: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Clarify-elisp-ref-for-inhibit-modification-hooks-Bug.patch Content-Description: patch >From 568e640f962cd9a59d695351ded11c4a8e781f06 Mon Sep 17 00:00:00 2001 From: Alan Mackenzie Date: Sun, 19 May 2019 20:31:19 +0000 Subject: [PATCH] Clarify elisp ref for inhibit-modification-hooks (Bug#25111) * doc/lispref/display.texi (Overlay Properties): * doc/lispref/text.texi (Special Properties) (Change Hooks): Explain that inhibit-modification-hooks is bound to t while executing change hooks, and suggest binding to nil with suitable precautions when modifying buffer from a change hook. Co-authored-by: Noam Postavsky --- doc/lispref/display.texi | 9 ++++++--- doc/lispref/text.texi | 12 ++++++++---- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi index b07999432c..f7140f444e 100644 --- a/doc/lispref/display.texi +++ b/doc/lispref/display.texi @@ -1708,9 +1708,12 @@ Overlay Properties length is the number of characters deleted, and the post-change beginning and end are equal.) -If these functions modify the buffer, they should bind -@code{inhibit-modification-hooks} to @code{t} around doing so, to -avoid confusing the internal mechanism that calls these hooks. +When these functions are called, @code{inhibit-modification-hooks} is +bound to non-@code{nil}. If the functions modify the buffer, you +might want to bind @code{inhibit-modification-hooks} to nil, so as to +cause the change hooks to run for these modifications. However, doing +this may call your own change hook recursively, so be sure to prepare +for that. @xref{Change Hooks}. Text properties also support the @code{modification-hooks} property, but the details are somewhat different (@pxref{Special Properties}). diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi index f3d222b708..5954161fcf 100644 --- a/doc/lispref/text.texi +++ b/doc/lispref/text.texi @@ -3514,9 +3514,10 @@ Special Properties hook will only be run when removing some characters, replacing them with others, or changing their text-properties. -If these functions modify the buffer, they should bind -@code{inhibit-modification-hooks} to @code{t} around doing so, to -avoid confusing the internal mechanism that calls these hooks. +When Emacs calls these functions, @code{inhibit-modification-hooks} is +set to non-@code{nil}. If the functions modify the buffer, you should +consider binding this variable to @code{nil}, but in that case you +must be prepared for recursive calls. @xref{Change Hooks}. Overlays also support the @code{modification-hooks} property, but the details are somewhat different (@pxref{Overlay Properties}). @@ -5093,5 +5094,8 @@ Change Hooks a modification hook does not cause other modification hooks to be run. If you do want modification hooks to be run in a particular piece of code that is itself run from a modification hook, then rebind locally -@code{inhibit-modification-hooks} to @code{nil}. +@code{inhibit-modification-hooks} to @code{nil}. However, doing this +may cause recursive calls to the modification hooks, so be sure to +prepare for that (for example, by binding some variable which tells +your hook to do nothing). @end defvar -- 2.11.0 --=-=-=--