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 20:06:41 +0800 Message-ID: <8735o1r31q.fsf@localhost> References: <87mtmalrs1.fsf@localhost> <837dde200c.fsf@gnu.org> <87k0helmig.fsf@localhost> <831r3m1tpk.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="39121"; 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 13:06:33 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 1mlVKC-0009v8-Bk for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 12 Nov 2021 13:06:32 +0100 Original-Received: from localhost ([::1]:59068 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mlVKA-0000aW-H2 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 12 Nov 2021 07:06:30 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:48696) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mlVJj-0000Z3-2j for bug-gnu-emacs@gnu.org; Fri, 12 Nov 2021 07:06:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:60328) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mlVJi-0005M9-Qy for bug-gnu-emacs@gnu.org; Fri, 12 Nov 2021 07:06:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mlVJi-00044k-Lh for bug-gnu-emacs@gnu.org; Fri, 12 Nov 2021 07:06:02 -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 12:06:02 +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.163671872415595 (code B ref 51766); Fri, 12 Nov 2021 12:06:02 +0000 Original-Received: (at 51766) by debbugs.gnu.org; 12 Nov 2021 12:05:24 +0000 Original-Received: from localhost ([127.0.0.1]:43636 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mlVJ6-00043T-Dl for submit@debbugs.gnu.org; Fri, 12 Nov 2021 07:05:24 -0500 Original-Received: from mail-pf1-f173.google.com ([209.85.210.173]:40641) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mlVJ2-00043C-Ve for 51766@debbugs.gnu.org; Fri, 12 Nov 2021 07:05:22 -0500 Original-Received: by mail-pf1-f173.google.com with SMTP id z6so8329989pfe.7 for <51766@debbugs.gnu.org>; Fri, 12 Nov 2021 04:05:20 -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=EPTKoQkcZG0yRXYwdkH9d8zasDGrAms7HxA9q2yMGO4=; b=kXXArPvUPqap/H4QEtTbXhUNqhTEE0kpqkSpklxYYu9D75G7Wlb+Bth9YBbdHx6nGX MvxgS8aRNXwTiex7T40INEBBP6pinS0uttTbNWrnj1ZpujENFdiepuNXUBplpsJAL2is lJFEjdioFYGG3NqqQrV9HXuh0X1F98i8RBG2tC2D3ae7xCz5wjxlh21SBgEdlTo2s++o wD5OM/oAN7BKe3xSUQ/3J4jj5vaf2h8Jdtq9LxJoPPZ/gJ1CEAAePAla3f0Axl5vVqeS +XcsYWQa8/Kyg1PISyIVQithSMz5SKxQGegxs2PAwJP+oQiG8A6Cuva2xv8AH2tweGFe HyNA== 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=EPTKoQkcZG0yRXYwdkH9d8zasDGrAms7HxA9q2yMGO4=; b=5fYijQEMsvorphpHlfvzTncRlO74Tx6xE/uUJghXL9rkPcUNZs2aWs+6BwFdbfuIto ja6Oq885jhueHSquYJCtsMb292z5N+SsasK1hvwpJchFBmWYKLw4iR4tCD9pxxhHgPp7 54Cad2GNfAZl4quUM5bqWOClFlQ+LtkZMbKqqLXAuOT9f3Ka0RLrb0Ak8dnogifdSgL7 p2BSdCB72Fw2REjA9RcMK7okfU05oxlQESOtywy/igUYJtHZxSRb+cLWHgbkvkyR3vDZ eADSjbPLrwrgxla8b61lWAF4GB+OoNIygSDlzXybgxcgT7UROzEQsEJKljpQjXQG1MDb Ym6w== X-Gm-Message-State: AOAM532nm6J0egpQsakhM43V8QHJ77UXphAC89JwX12npsYfSM0cj3Yp nODWIjrG4CH1BwuyAYLJxuQ= X-Google-Smtp-Source: ABdhPJxf01ZkCdNusVyjf2pFq2dD8csBe5jw0KC5CoqMWH72cF+UorwDg+qmObuSK3p3GlZhelcDyg== X-Received: by 2002:aa7:818d:0:b0:49f:e7d4:bb55 with SMTP id g13-20020aa7818d000000b0049fe7d4bb55mr13585969pfi.60.1636718714899; Fri, 12 Nov 2021 04:05:14 -0800 (PST) Original-Received: from localhost ([103.125.234.210]) by smtp.gmail.com with ESMTPSA id o4sm10740556pjq.23.2021.11.12.04.05.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Nov 2021 04:05:14 -0800 (PST) In-Reply-To: <831r3m1tpk.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:219763 Archived-At: Eli Zaretskii writes: > That's exactly what happens: quail.el deletes the inserted character > and then reinserts it (for reasons unrelated to this issue). So the > count of the changes is not equal to the number of characters actually > inserted. I see no problem here, since the documentation never > promises that the difference between the values returned by successive > calls to buffer-chars-modified-tick will be exactly equal to the > number of inserted or deleted characters. I agree that Emacs does not break any promises here. Though it is unfortunate. Feel free to close this bug report. > So if Org relies on such an equality, it's a bug in Org (but I didn't > look at the relevant Org code, and don't have a clear idea of how > exactly it uses the above function for whatever it is caching). Let me explain a little (hoping that you might have some idea about alternative solutions without using buffer-chars-modified-tick). Org has a caching mechanism (org-element-cache) that keeps parsed buffer representation in memory and updates it on the fly as the buffer changes. To make the mechanism work, Org must keep track of all the changes in buffer and update the affected Org elements in memory. Naturally, this is done using before/after-change-functions. However, some third-party code carelessly uses inhibit-modification-hooks and some edits may be missed by element cache. If we just ignore the possibility of such edits, cache can be broken badly. So, there is currently a control code that detects if buffer has been changed outside the Org's change functions. The control code uses buffer-chars-modified-tick. The behaviour of quail.el makes the control code useless - buffer-chars-modified-tick can no longer be reliably used to detect unfavourable "stealthy" changes. AFAIK, the only alternative way to detect the changes is buffer-hash/secure-hash. But calculating hash is very too slow when I try to put it into before/after-change-functions. I do not know any fast (as fast as buffer-chars-modified-tick) way to detect buffer changes. > quail.el inhibit buffer modifications in places, since otherwise you'd > have too many of them. It wants to pretend that just one character > was inserted. I understand the idea behind suppressing the modification hooks by quail. Though it would be helpful if before-change-functions were called before inserting+deleting a character by quail is done. Best, Ihor