From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ihor Radchenko Newsgroups: gmane.emacs.bugs Subject: bug#51766: 29.0.50; Return value of buffer-chars-modified-tick changes when buffer text is not yet changed before inserting a character for non-latin input methods Date: Fri, 12 Nov 2021 21:39:54 +0800 Message-ID: <87wnldpk5x.fsf@localhost> References: <87mtmalrs1.fsf@localhost> <837dde200c.fsf@gnu.org> <87k0helmig.fsf@localhost> <831r3m1tpk.fsf@gnu.org> <8735o1r31q.fsf@localhost> <834k8hzi10.fsf@gnu.org> <87zgq9pmb6.fsf@localhost> <831r3lzfk4.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19235"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 51766@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Nov 12 14:39:14 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mlWlr-0004sK-N7 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 12 Nov 2021 14:39:11 +0100 Original-Received: from localhost ([::1]:54542 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mlWlq-0005h4-2E for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 12 Nov 2021 08:39:10 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:38348) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mlWli-0005X5-EX for bug-gnu-emacs@gnu.org; Fri, 12 Nov 2021 08:39:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:60423) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mlWli-0002Go-33 for bug-gnu-emacs@gnu.org; Fri, 12 Nov 2021 08:39:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mlWlh-0000BL-VT for bug-gnu-emacs@gnu.org; Fri, 12 Nov 2021 08:39:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Ihor Radchenko Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 12 Nov 2021 13:39:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51766 X-GNU-PR-Package: emacs Original-Received: via spool by 51766-submit@debbugs.gnu.org id=B51766.1636724318666 (code B ref 51766); Fri, 12 Nov 2021 13:39:01 +0000 Original-Received: (at 51766) by debbugs.gnu.org; 12 Nov 2021 13:38:38 +0000 Original-Received: from localhost ([127.0.0.1]:43736 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mlWlK-0000Ae-Fw for submit@debbugs.gnu.org; Fri, 12 Nov 2021 08:38:38 -0500 Original-Received: from mail-pj1-f41.google.com ([209.85.216.41]:43607) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mlWlG-0000AO-Ke for 51766@debbugs.gnu.org; Fri, 12 Nov 2021 08:38:36 -0500 Original-Received: by mail-pj1-f41.google.com with SMTP id nh10-20020a17090b364a00b001a69adad5ebso7628376pjb.2 for <51766@debbugs.gnu.org>; Fri, 12 Nov 2021 05:38:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=umJu5FDJ8nHJ5OwO9s7tBV+wo2LZ4I0hepzLH3F0ziY=; b=qKo5KT3UeR3SKaZgpc/9U01epP+IB6gQts5nMA7aWJv1JcfADIUi1/wRu5p910s+7A JjclTarJKx4tlWJVrw/4KkGjRZq/PcDQ79CjOZG+FEtwoO2mqiNn2FdD1dhZfSfGXXW1 70Y3PnBfaJ7w9QhQZlcb+9uReeWBPFZ1ToXkFUmZGy0m9UY4lalvo4T+Q25jJzrRrrF9 WfI4RWP/7kjXudEo3R8p00/xXCeyCIXH8+1HMpfc8NVnA9UnpkhjCdDa10CKz8uqU9z7 4oef0eBZ4WDLUN4Gid2ENNhiX/QEpLJgbyvm0ujjDhwWBCYeVDDViEKbdt/BJGsgKIPx uOyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=umJu5FDJ8nHJ5OwO9s7tBV+wo2LZ4I0hepzLH3F0ziY=; b=2nvTxBF2AQznOfjeFCYZf2z6XxAM2VwnL2h6hqX4k/F653zWM8bJTYygup1lCLCNnj A2l6ExCv9LxOEY+ZjhJK+pjG4cbO3LjWzMe8DHO2osdVUHXRpO0bTaDDS2PQQhn9qzX9 VomNlttgnpLhUfzMAneTWbbZYBdTE/OUzUxyXChzsU7+eWm1KvsfWUfg7P+4YAq2jWDp faKdkPmWm6oCOg+7IvDl+q/rdXIBhsB4xd+Iwtwkm7kf84XQyNhEpQ8uS8jl/2d/COfJ bfPgERFzhhvOjfxf+olHt6N6/JI9LffCsZKxs9+38ImMjrTuQmxfUNmMsLyWdIqaIsk7 epJg== X-Gm-Message-State: AOAM532AYEwY5/KmDKLhQ5FTHuK2TODLMmMP5cm1C8gajmKI+VRaTBgW AoP/R4KLpiCyjAS1xHhOqyCIRDXObqzebQ== X-Google-Smtp-Source: ABdhPJxVAmUI9ts9tcCPHzB/5z+EWxgSWefKp/HagAbYufl0y7CoEBrabC+XPU9ox9ObJVuLMAO4mQ== X-Received: by 2002:a17:90b:4d09:: with SMTP id mw9mr17928459pjb.238.1636724308569; Fri, 12 Nov 2021 05:38:28 -0800 (PST) Original-Received: from localhost ([103.125.234.210]) by smtp.gmail.com with ESMTPSA id o134sm6437366pfg.1.2021.11.12.05.38.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Nov 2021 05:38:27 -0800 (PST) In-Reply-To: <831r3lzfk4.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:219773 Archived-At: Eli Zaretskii writes: >> quail changes the buffer after org-element--after-change-function call, >> but before org-element--before-change-function. So, all Org can see is >> that something has been changed in buffer, but there is no way to tell >> what it was. Org cannot distinguish between harmless buffer edits by >> quail (they do not change buffer text) and other kinds of "silent" >> changes. > > OK, but why does this invalidate what Org does? All it means, AFAIU, > is that in some cases Org will do unnecessary processing. Those cases > are probably not too frequent. Normally, buffer changes under inhibit-modification-hooks are not frequent indeed. But not with quail + non-latin input methods. Every single self-insert-command triggers such change. > IOW, why invalidating the cache unnecessarily is such a big deal? It is critical for Org to know which part of buffer was changed (i.e. beg, end, length that are normally passed as arguments of after-change-functions). org-element-cache can contain >100k elements for especially large buffers. Manually checking which elements are changed without knowing the changed region is inefficient. Clearing the cache is not too much of a big deal, but causes slowdown when user runs a query on Org buffers (i.e. in agenda or sparse trees) - the buffer has to be re-parsed. When every edit triggers cache invalidation (that's what happens when user uses non-latin input method), the slowdown is pretty much guaranteed. Moreover, too frequent cache resets increase the load on Emacs' garbage collector (cache size is typically a multiple of buffer size). Overloading garbage collector leads to overall Emacs slowdown. >> The hooks are called, but after quail already triggered >> buffer-chars-modified-tick increase. If quail called >> before-change-functions before buffer-chars-modified-tick increases, it >> would be useful for my scenario. Though I am not sure how feasible it >> is. Just an idea. > > Would it help if Org looked at both buffer-modified-tick and > buffer-chars-modified-tick? When buffer-chars-modified-tick is changed, buffer-modified-tick is also changed. AFAIU, buffer-chars-modified-tick registers a subset of buffer modifications that actually change buffer text. buffer-modified-tick also registers text property changes. So, I do not see how buffer-modified-tick can help. Best, Ihor