From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii 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: Thu, 11 Nov 2021 17:19:15 +0200 Message-ID: <837dde200c.fsf@gnu.org> References: <87mtmalrs1.fsf@localhost> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8922"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 51766@debbugs.gnu.org To: Ihor Radchenko Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Nov 11 16:20:15 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 1mlBs6-00028t-Ob for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 11 Nov 2021 16:20:14 +0100 Original-Received: from localhost ([::1]:45222 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mlBs5-0004Vq-LZ for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 11 Nov 2021 10:20:13 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:37386) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mlBrv-0004Sn-Kd for bug-gnu-emacs@gnu.org; Thu, 11 Nov 2021 10:20:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58672) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mlBrv-000261-A5 for bug-gnu-emacs@gnu.org; Thu, 11 Nov 2021 10:20:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mlBrv-0007DJ-5P for bug-gnu-emacs@gnu.org; Thu, 11 Nov 2021 10:20:03 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 11 Nov 2021 15:20:03 +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.163664396727644 (code B ref 51766); Thu, 11 Nov 2021 15:20:03 +0000 Original-Received: (at 51766) by debbugs.gnu.org; 11 Nov 2021 15:19:27 +0000 Original-Received: from localhost ([127.0.0.1]:41982 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mlBrL-0007Bo-3X for submit@debbugs.gnu.org; Thu, 11 Nov 2021 10:19:27 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:36456) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mlBrI-0007BX-RV for 51766@debbugs.gnu.org; Thu, 11 Nov 2021 10:19:25 -0500 Original-Received: from [2001:470:142:3::e] (port=57702 helo=fencepost.gnu.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mlBrD-0001z9-Kh; Thu, 11 Nov 2021 10:19:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=KXvToLKclzBRN4gH0loa4NFOnGf2FokivTt62LlloK8=; b=XaXKQt6DLx2NhqNY55JQ /mhjBIwR0xCLT5EtSZnjUC0gmFO7Xq9sstL5HholvcvmdILChXCBGlpIrrh/XyAt+tPQFrfsm/dse 0J/VpGdiaRC/cUv+cGMs0vosWZj8mMhQ3UTPlWBzE0UJ6xeOCcqWJmnSb3BLgObhIlMu7T0swypjG vvg3BVw49HtOY8QhVRIFNj/KiKF2S4iqgEpryl6WvojY2gK/NDGX4PlHWfnGwiyZbR5P9bIonRcT/ 6UxjPaib6gJwvhzJeHcq0MLCO/fpIa2ruuqwRTWOEgwUtGzTdsfqBnqDBNVNCijD5TuJdd+dbKoKr wQpKNEaFu2vGqg==; Original-Received: from [87.69.77.57] (port=2826 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mlBrA-0000cZ-Uz; Thu, 11 Nov 2021 10:19:17 -0500 In-Reply-To: <87mtmalrs1.fsf@localhost> (message from Ihor Radchenko on Thu, 11 Nov 2021 21:56:46 +0800) 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:219645 Archived-At: > From: Ihor Radchenko > Date: Thu, 11 Nov 2021 21:56:46 +0800 > > According to buffer-chars-modified-tick docstring: > "By comparing the values returned by two individual calls of > buffer-chars-modified-tick, you can tell whether a character change > occurred in that buffer in between these calls" > > However, the return value can change even when no visible change is made > to buffer text. > > Steps to reproduce: > 1. emacs -Q > 2. Evaluate the following code: > > (defun print-tick-before () > (when (eq this-command 'self-insert-command) > (warn "Tick before: %S" (buffer-chars-modified-tick)))) > (defun print-tick-after () > (when (eq this-command 'self-insert-command) > (warn "Tick after: %S" (buffer-chars-modified-tick)))) > (add-hook 'pre-command-hook #'print-tick-before) > (add-hook 'post-command-hook #'print-tick-after) > > 3. Insert a latin symbol ?a twice. The warning buffer will print > something like > > Warning (emacs): Tick before: 1698 Disable showing Disable logging > Warning (emacs): Tick after: 1699 Disable showing Disable logging > Warning (emacs): Tick before: 1699 Disable showing Disable logging > Warning (emacs): Tick after: 1702 Disable showing Disable logging > > Note that second and third line show the same buffer-chars-modified-tick > value. > > 4. Change input method (C-\) to russian-computer or i.e. arabic > 5. Insert a non-latin symbol ?ф twice. The warning buffer will print > something like > > Warning (emacs): Tick before: 1706 Disable showing Disable logging > Warning (emacs): Tick after: 1707 Disable showing Disable logging > Warning (emacs): Tick before: 1711 Disable showing Disable logging > Warning (emacs): Tick after: 1712 Disable showing Disable logging > > Note that second and third line _do not_ show the same > buffer-chars-modified-tick value even though buffer text has not been > changed between the two self-insert commands > > Expected behaviour: return value of buffer-chars-modified-tick does not > change when no changes in buffer text are made. How do you know there was no changes in the buffer? You call your function from pre/post-command-hook, but why is it guaranteed that there was no change in the buffer between post-command-hook and the following pre-command-hook?