From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Pip Cet Newsgroups: gmane.emacs.bugs Subject: bug#36190: 27.0.50; `put-text-property' etc. with buffer argument calls current buffer's `after-change-functions' Date: Thu, 13 Jun 2019 19:42:29 +0000 Message-ID: References: <83h88tzbly.fsf@gnu.org> <835zp9z4oj.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="95579"; mail-complaints-to="usenet@blaine.gmane.org" Cc: 36190@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jun 13 21:53: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.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hbVmj-000Og8-CT for geb-bug-gnu-emacs@m.gmane.org; Thu, 13 Jun 2019 21:53:21 +0200 Original-Received: from localhost ([::1]:45274 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbVmh-0000kU-Sh for geb-bug-gnu-emacs@m.gmane.org; Thu, 13 Jun 2019 15:53:19 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53176) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbViH-0005d0-US for bug-gnu-emacs@gnu.org; Thu, 13 Jun 2019 15:48:47 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbVdi-0007Y9-QO for bug-gnu-emacs@gnu.org; Thu, 13 Jun 2019 15:44:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:50865) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hbVdi-0007Y1-Km for bug-gnu-emacs@gnu.org; Thu, 13 Jun 2019 15:44:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hbVdi-0005dl-HS for bug-gnu-emacs@gnu.org; Thu, 13 Jun 2019 15:44:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Pip Cet Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 13 Jun 2019 19:44:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36190 X-GNU-PR-Package: emacs Original-Received: via spool by 36190-submit@debbugs.gnu.org id=B36190.156045499221602 (code B ref 36190); Thu, 13 Jun 2019 19:44:02 +0000 Original-Received: (at 36190) by debbugs.gnu.org; 13 Jun 2019 19:43:12 +0000 Original-Received: from localhost ([127.0.0.1]:36174 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hbVcu-0005cM-0h for submit@debbugs.gnu.org; Thu, 13 Jun 2019 15:43:12 -0400 Original-Received: from mail-ot1-f49.google.com ([209.85.210.49]:39591) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hbVcs-0005c9-Rj for 36190@debbugs.gnu.org; Thu, 13 Jun 2019 15:43:11 -0400 Original-Received: by mail-ot1-f49.google.com with SMTP id r21so338671otq.6 for <36190@debbugs.gnu.org>; Thu, 13 Jun 2019 12:43:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=lZY9okjy43UBDDEusg/SMV+N6pXnqyEQJLikgPMYqnw=; b=YZeohk6oucR5eiTg2AJzHkHIHmTisECU9f37CD9dt/PMn4sbO1t10klwPFGsYHGEde UntJ473JoHdlt22rLK6hbxF4mcCJc8kFhl1ei5zJtR29PEPgr1LdRtm5JuuJNaec7C6u PK6P6yepR2YilkEj+iUgStkN30+1bfAIqsbwhQ5S1oWGnoRMWrIAKDAK4Ns0n4oiG//F Y+PDlmeEKSkZ9bLP/ZAaKwMNhZXN4WjSbfoQiRr5AZcD2gWcTdHSSOpWav7IlabJC6R/ ogooTzQed7MFQodGfRPTqlayOujBwsiVc84Kih9tfFJp2O91j/RKaDPnwUuVYebZWd3a gq8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=lZY9okjy43UBDDEusg/SMV+N6pXnqyEQJLikgPMYqnw=; b=oR1ycQkzoUnuhWEnkgDBfKQM7V79GDR80f/2ve9Cnuw+5sHiJxVxmlZwxal60etw0v 1dXeiO7JEO7midM3CBPGhlDddxo0c4Oggsc1RvLdUv//w4gXqg2zlUGcjhgjpcN//6V9 CZTu2S82mxhy5JiV1aPY3lKS62X0DeJJTvhV786rKrjW7uz32FssY+EtC3QJSIh8Kwbn /B++9xk3fpO46AuoshIa0CqpRzoFEIQp7RNXVN2x11BOTeYVwNn76pGEG63iC4umD1XO NxickLrS1QYE6fONPjq+omF8n9qeZra0dQzUZeQFB+pzKzj4XBklC0mf5uovJ0f0CFt9 xIpg== X-Gm-Message-State: APjAAAV9Vq+BqC/b8G1GYtgVc4J2r6gukkB8j25NGh2pbvyHg5y52vX7 M3Zbz1ajL6dNJurJZi7QV1wp7tgadZphwMOSweE= X-Google-Smtp-Source: APXvYqw6ydLwsLvZJZ2GT6Ysyjkgz8MJlh9fSKHZH0OwBf/aZOECTSvwJk5FxpXsUyquxClqrxHWilz9pkhwHZQQXVU= X-Received: by 2002:a9d:5e95:: with SMTP id f21mr14656758otl.287.1560454985178; Thu, 13 Jun 2019 12:43:05 -0700 (PDT) In-Reply-To: <835zp9z4oj.fsf@gnu.org> 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:160520 Archived-At: On Thu, Jun 13, 2019 at 7:06 PM Eli Zaretskii wrote: > > > From: Pip Cet > > Date: Thu, 13 Jun 2019 18:48:23 +0000 > > Cc: 36190@debbugs.gnu.org > > > > > > As far as I can tell, this makes `put-text-property' with a buffer > > > > argument pretty useless. > > > > > > Only if you have a buffer-local value of after-change-functions. > > > > I'm not sure what you're saying. > > I'm saying that the buffer argument to put-text-property is pretty > useless only if you consider after-change-functions. The primary > purpose of put-text-property is to modify text properties, not to call > after-change-functions. For that primary purpose, the buffer argument > is not useless. Thanks for clarifying. I suppose you could say that it's after-change-functions (local, global, plus overlay modification hooks) that have become useless, or will be called spuriously and with potentially nonsensical arguments. For example, this would break: (push (lambda (beg end len) (message "%S" (buffer-substring beg end))) after-change-functions) > > That seems pretty wrong to me. In which cases do you think we're > > seeing the right behavior? > > Where did I say that this behavior was right? You said "only if", so I assumed you were asserting the contrapositive. > > Here's a first patch, which adds a "buffer" argument to > > signal_after_change, to be explicit about where the change happens. It > > should be pretty cheap in the case where we don't switch buffers. > > Not sure I have a clear idea of how you intend to use that additional > argument. Are you suggesting that we switch to that buffer? Yes: @@ -2183,6 +2184,9 @@ signal_after_change (ptrdiff_t charpos, ptrdiff_t lendel, ptrdiff_t lenins) if (inhibit_modification_hooks) return; + record_unwind_current_buffer (); + set_buffer_internal (buffer); + /* If we are deferring calls to the after-change functions and there are no before-change functions, just record the args that we were going to use. */ > If so, > how is that different from not using the buffer argument at all, and > instead wrapping the call to put-text-property with > with-current-buffer? I don't think they're usefully different, but put-text-property doesn't appear to check the buffer is still live. > Also, passing current_buffer sounds redundant to me anyway, because in > that case signal_after_change will not need to do anything that it > doesn't already do. I would pass NULL instead. May I ask why? I think passing current_buffer is the clearest signal we can send to someone reusing the code that they might have to change this if they're dealing with more than one buffer. As a practical matter, it's hard to change the text property functions to use NULL when passed a nil argument, so we'd have functions using current_buffer and others using NULL, and that seems needlessly inconsistent.