GNU logs - #69733, boring messages


Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#69733: [PATCH] Flyspell (flyspell-word): do not force 'save-excursion' on timers
Resent-From: Daniel Pettersson <daniel@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Mon, 11 Mar 2024 14:39:01 +0000
Resent-Message-ID: <handler.69733.B.171016791712755 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: report 69733
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: patch
To: 69733 <at> debbugs.gnu.org
X-Debbugs-Original-To: bug-gnu-emacs@HIDDEN
Received: via spool by submit <at> debbugs.gnu.org id=B.171016791712755
          (code B ref -1); Mon, 11 Mar 2024 14:39:01 +0000
Received: (at submit) by debbugs.gnu.org; 11 Mar 2024 14:38:37 +0000
Received: from localhost ([127.0.0.1]:40962 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rjgnV-0003Jf-3T
	for submit <at> debbugs.gnu.org; Mon, 11 Mar 2024 10:38:37 -0400
Received: from lists.gnu.org ([209.51.188.17]:43344)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <daniel.dpettersson.net@HIDDEN>)
 id 1rjgnT-0003JX-MD
 for submit <at> debbugs.gnu.org; Mon, 11 Mar 2024 10:38:36 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <daniel.dpettersson.net@HIDDEN>)
 id 1rjgmv-0001fE-DH
 for bug-gnu-emacs@HIDDEN; Mon, 11 Mar 2024 10:38:01 -0400
Received: from mail-lf1-f54.google.com ([209.85.167.54])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <daniel.dpettersson.net@HIDDEN>)
 id 1rjgmt-0002UM-MR
 for bug-gnu-emacs@HIDDEN; Mon, 11 Mar 2024 10:38:01 -0400
Received: by mail-lf1-f54.google.com with SMTP id
 2adb3069b0e04-51344bebe2fso2963502e87.2
 for <bug-gnu-emacs@HIDDEN>; Mon, 11 Mar 2024 07:37:58 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1710167877; x=1710772677;
 h=mime-version:message-id:date:subject:to:from:x-gm-message-state
 :from:to:cc:subject:date:message-id:reply-to;
 bh=TfAu5gTQjUhEkpodiX0TY3i+zY1u8HdvFH3miQYl43Q=;
 b=iiwqZUuEf8I0UDPjjjfb5ZXUZIrbPuDqMYklrnrnfcASofYwLobeWhmjp4K6aIceaB
 WyPnIWgbcd7+AofZA/2oN9K49sPqBpStwsQMi4qYppS+QTCzZSV3XNWj4YCHywjUHGwl
 XK5GijgWfffOibHDijvtfhfV57cB7UiZcl5f0AmoR6Q7mK9p+eYV1pmq5XYfAsopbNh4
 /CWBlndx9PNgrsR37lAad7sQcfl5lrNNo6KTcGWGCivFyfoj27XrkQG3oNRxAwjMrjHW
 0ieUqJqaiCdiG+XiTXVmLZ5NR0vLJfhhbih0s/a2xMq9tnAI0XVlE1OtxMrVjIkgFMiW
 TOHg==
X-Gm-Message-State: AOJu0Yy7kVeyfPJy75WNJdtbjF1uG/0x19mY53vJ49frz4Q6yioqQjNe
 xH3my4WSfEsgHhRY6HESo0fAV4K3IvWPFUThSfH6ps+JwvwYjrCVYW9C6RwQ
X-Google-Smtp-Source: AGHT+IGoq36xCMD0muOluDs83jCemwp49INwzrjVLjzmPaSV9UvGjK6gGsrWlpXmkn4lgTiy+3DTzA==
X-Received: by 2002:a05:6512:32c7:b0:513:b001:61e4 with SMTP id
 f7-20020a05651232c700b00513b00161e4mr1352648lfg.66.1710167876460; 
 Mon, 11 Mar 2024 07:37:56 -0700 (PDT)
Received: from Daniels-Air (c-72cde455.027-357-6d6c6d4.bbcust.telenor.se.
 [85.228.205.114]) by smtp.gmail.com with ESMTPSA id
 i13-20020a056512340d00b005129e5d7f11sm1113157lfr.125.2024.03.11.07.37.55
 for <bug-gnu-emacs@HIDDEN>
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Mon, 11 Mar 2024 07:37:55 -0700 (PDT)
From: Daniel Pettersson <daniel@HIDDEN>
Date: Mon, 11 Mar 2024 15:37:55 +0100
Message-ID: <m2sf0wzvek.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
Received-SPF: pass client-ip=209.85.167.54;
 envelope-from=daniel.dpettersson.net@HIDDEN; helo=mail-lf1-f54.google.com
X-Spam_score_int: -16
X-Spam_score: -1.7
X-Spam_bar: -
X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9,
 FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001,
 HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001,
 RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
 T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.1 (-)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.1 (--)

--=-=-=
Content-Type: text/plain

Tags: patch


As I understand the manual there is nothing that states that one should
assume that you cant move the point in buffer with timers.  This is of
course impossible to guarantee as any code can be calling
accept-process-output.  But it seams like an good idea to have code that
is triggered by post-command-hook to not impose such conditions. 

This might seam like an mole whacking activity, and it most definitely
is.

In GNU Emacs 30.0.50 (build 1, aarch64-apple-darwin23.1.0, NS
 appkit-2487.20 Version 14.1.1 (Build 23B81)) of 2023-12-20 built on
 Daniels-Air
Repository revision: 281be72422f42fcc84d43f50723a3e91b7d03cbc
Repository branch: master
Windowing system distributor 'Apple', version 10.3.2487
System Description:  macOS 14.1.1


--=-=-=
Content-Type: text/patch
Content-Disposition: attachment;
 filename=0001-Flyspell-flyspell-word-do-not-force-save-excursion-o.patch

From 56bdf4df8048b4053719e33d08753a2eb088dc57 Mon Sep 17 00:00:00 2001
From: Daniel Pettersson <daniel@HIDDEN>
Date: Mon, 11 Mar 2024 15:01:32 +0100
Subject: [PATCH] Flyspell (flyspell-word): do not force 'save-excursion' on
 timers

* lisp/textmode/flyspell.el (flyspell-word): Do not force
save-excursion on timers.  This especially needed here as
flyspell-word is fired from an post command hook.
---
 lisp/textmodes/flyspell.el | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el
index de59294e9f0..5dfe0f17aef 100644
--- a/lisp/textmodes/flyspell.el
+++ b/lisp/textmodes/flyspell.el
@@ -1150,7 +1150,9 @@ flyspell-word
 		  (set-process-query-on-exit-flag ispell-process nil)
                   ;; Wait until ispell has processed word.
                   (while (progn
-                           (accept-process-output ispell-process)
+                           ;; don't force save-excursion to timers.
+                           ;; only accept output from ispell-process.
+                           (accept-process-output ispell-process nil nil t)
                            (not (string= "" (car ispell-filter)))))
                   ;; (ispell-send-string "!\n")
                   ;; back to terse mode.
-- 
2.39.3 (Apple Git-145)


--=-=-=--




Message sent:


Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-Mailer: MIME-tools 5.505 (Entity 5.505)
Content-Type: text/plain; charset=utf-8
X-Loop: help-debbugs@HIDDEN
From: help-debbugs@HIDDEN (GNU bug Tracking System)
To: Daniel Pettersson <daniel@HIDDEN>
Subject: bug#69733: Acknowledgement ([PATCH] Flyspell (flyspell-word): do
 not force 'save-excursion' on timers)
Message-ID: <handler.69733.B.171016791712755.ack <at> debbugs.gnu.org>
References: <m2sf0wzvek.fsf@HIDDEN>
X-Gnu-PR-Message: ack 69733
X-Gnu-PR-Package: emacs
X-Gnu-PR-Keywords: patch
Reply-To: 69733 <at> debbugs.gnu.org
Date: Mon, 11 Mar 2024 14:39:01 +0000

Thank you for filing a new bug report with debbugs.gnu.org.

This is an automatically generated reply to let you know your message
has been received.

Your message is being forwarded to the package maintainers and other
interested parties for their attention; they will reply in due course.

Your message has been sent to the package maintainer(s):
 bug-gnu-emacs@HIDDEN

If you wish to submit further information on this problem, please
send it to 69733 <at> debbugs.gnu.org.

Please do not send mail to help-debbugs@HIDDEN unless you wish
to report a problem with the Bug-tracking system.

--=20
69733: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D69733
GNU Bug Tracking System
Contact help-debbugs@HIDDEN with problems


Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#69733: [PATCH] Flyspell (flyspell-word): do not force 'save-excursion' on timers
Resent-From: Eli Zaretskii <eliz@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Tue, 12 Mar 2024 13:21:01 +0000
Resent-Message-ID: <handler.69733.B69733.171024965621854 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 69733
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: patch
To: Daniel Pettersson <daniel@HIDDEN>
Cc: 69733 <at> debbugs.gnu.org
Received: via spool by 69733-submit <at> debbugs.gnu.org id=B69733.171024965621854
          (code B ref 69733); Tue, 12 Mar 2024 13:21:01 +0000
Received: (at 69733) by debbugs.gnu.org; 12 Mar 2024 13:20:56 +0000
Received: from localhost ([127.0.0.1]:42054 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rk23r-0005gQ-L2
	for submit <at> debbugs.gnu.org; Tue, 12 Mar 2024 09:20:55 -0400
Received: from eggs.gnu.org ([209.51.188.92]:38364)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1rk23p-0005gD-Gv
 for 69733 <at> debbugs.gnu.org; Tue, 12 Mar 2024 09:20:54 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1rk23B-0007pD-E3; Tue, 12 Mar 2024 09:20:13 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=WEn0d+ijC0WyWcJ00w8Xlq0e6Xjm/6zBVKMgOuxDv7M=; b=SpfcsIZQzsQy
 xPtyOk2AKkUFuxhT9urJ+qGiecOG2yO2vF1C9FUpytG9kqnSlBNhKzvP33q4DfRfnzzInzRRsKN6h
 z+hzyh1VLxn4MujlyBvE0WyQxS6xuDnSndkmF/bQ03jvX4nnICPGhquD8fhVS2Fd2m2D5FagRKONi
 U3kcy6l7MKX4hREYPtfMBKS1uZDBF/GTdxCF1eSroSFvc9X3pSE4R9xEUS06yFXh+6Q1a7UR0KZd+
 Ki9uej6vojR11bLV7gT9y7f5yYj7+weF/m8pboLDvFu6zx1b9dR1+dNDoV+xUdjUCBm6SxTGy56EB
 rWgz3iAHw1WoB3VZH1GlTg==;
Date: Tue, 12 Mar 2024 15:20:10 +0200
Message-Id: <86ttlbtwmt.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
In-Reply-To: <m2sf0wzvek.fsf@HIDDEN> (message from Daniel Pettersson
 on Mon, 11 Mar 2024 15:37:55 +0100)
References: <m2sf0wzvek.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Daniel Pettersson <daniel@HIDDEN>
> Date: Mon, 11 Mar 2024 15:37:55 +0100
> 
> As I understand the manual there is nothing that states that one should
> assume that you cant move the point in buffer with timers.  This is of
> course impossible to guarantee as any code can be calling
> accept-process-output.  But it seams like an good idea to have code that
> is triggered by post-command-hook to not impose such conditions. 

Thanks, but I don't think I understand the relation between what you
say above (and in the comments in your patch below) and the code
change you propose:

>                    (while (progn
> -                           (accept-process-output ispell-process)
> +                           ;; don't force save-excursion to timers.
> +                           ;; only accept output from ispell-process.
> +                           (accept-process-output ispell-process nil nil t)

Where's save-excursion and point moving to which you allude here?

More importantly, why is it a good idea to stop running timers during
this accept-process-output call and ignore output from other
subprocesses?




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#69733: [PATCH] Flyspell (flyspell-word): do not force 'save-excursion' on timers
Resent-From: Daniel Pettersson <daniel@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Tue, 12 Mar 2024 14:30:02 +0000
Resent-Message-ID: <handler.69733.B69733.17102537478082 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 69733
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: patch
To: Eli Zaretskii <eliz@HIDDEN>
Cc: 69733 <at> debbugs.gnu.org
Received: via spool by 69733-submit <at> debbugs.gnu.org id=B69733.17102537478082
          (code B ref 69733); Tue, 12 Mar 2024 14:30:02 +0000
Received: (at 69733) by debbugs.gnu.org; 12 Mar 2024 14:29:07 +0000
Received: from localhost ([127.0.0.1]:43320 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rk37q-00026I-Sn
	for submit <at> debbugs.gnu.org; Tue, 12 Mar 2024 10:29:07 -0400
Received: from mail-lf1-f45.google.com ([209.85.167.45]:43462)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <daniel.dpettersson.net@HIDDEN>)
 id 1rk37o-00025j-Qm
 for 69733 <at> debbugs.gnu.org; Tue, 12 Mar 2024 10:29:06 -0400
Received: by mail-lf1-f45.google.com with SMTP id
 2adb3069b0e04-51325c38d10so4893e87.1
 for <69733 <at> debbugs.gnu.org>; Tue, 12 Mar 2024 07:28:30 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1710253704; x=1710858504;
 h=mime-version:user-agent:message-id:date:references:in-reply-to
 :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date
 :message-id:reply-to;
 bh=ha36D9xm+R/pdSGDTPS43vOZeulZPdTUBuN02n1Rr1s=;
 b=wEcY7nJsPaLXCTVFtYvoOgiOHctI7I301Kw8J3ecHt4GgkA+WL9gXaSC+Ml+nxCzri
 pNJcVyradFNvqMLLBcf8J8PCPqgI6ROhASterZutQIYXdCW2q1Td6+uVkWWNBs0TEEgA
 oWSkxk106WSyDalRli4+j3ZlFkA1ZDW+v3u8DZk93+m57Sv4dWBzU/oPz7NoFWCqj9g7
 qg9osTVP94Yu7EL/lzBtOXmbQCd4aENvhdVCyFOwa6j1cY7vSqHxtQ1Q/r3n9sJrR27E
 SoGia+M4NOKFmvd5Cv8Tnz+5eMm6tt6g9x8vjwVYjGjqf32jNXaExWvBSRb2YWVQsZAK
 GXJA==
X-Gm-Message-State: AOJu0Yy6gWCCVyuEI8+dIXhAArGHRNZfKB3nKGKUQK+FaoYxq0dGnU8b
 37GgmuSm7mOtWWHQXhPFyEO2SdFQAksr2fsLrO4IKvZv174TlJNo/50h+VDW
X-Google-Smtp-Source: AGHT+IH4uzMxwxdC83rl/VtNxCcdYyEvmnw4W2D80RWon3EhCbj5zdnbZ45HNNjkhLw1ivg172d0/w==
X-Received: by 2002:ac2:5b47:0:b0:513:d1:770d with SMTP id
 i7-20020ac25b47000000b0051300d1770dmr3711545lfp.7.1710253703929; 
 Tue, 12 Mar 2024 07:28:23 -0700 (PDT)
Received: from Daniels-Air (c-72cde455.027-357-6d6c6d4.bbcust.telenor.se.
 [85.228.205.114]) by smtp.gmail.com with ESMTPSA id
 c1-20020a197601000000b00513c142f6a7sm238464lff.132.2024.03.12.07.28.23
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Tue, 12 Mar 2024 07:28:23 -0700 (PDT)
From: Daniel Pettersson <daniel@HIDDEN>
In-Reply-To: <86ttlbtwmt.fsf@HIDDEN> (Eli Zaretskii's message of "Tue, 12 Mar
 2024 15:20:10 +0200")
References: <m2sf0wzvek.fsf@HIDDEN> <86ttlbtwmt.fsf@HIDDEN>
Date: Tue, 12 Mar 2024 15:28:22 +0100
Message-ID: <m2zfv34j95.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.2 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.8 (/)

Eli Zaretskii <eliz@HIDDEN> writes:

> Thanks, but I don't think I understand the relation between what you
> say above (and in the comments in your patch below) and the code
> change you propose:

flyspell-word wraps it's body inside an `save-excursion'.

(defun flyspell-word (&optional following known-misspelling)
...
  (save-excursion
...
>>                    (while (progn
>> -                           (accept-process-output ispell-process)
>> +                           ;; don't force save-excursion to timers.
>> +                           ;; only accept output from ispell-process.
>> +                           (accept-process-output ispell-process nil nil t)

> Where's save-excursion and point moving to which you allude here?

See above and for point moving I think that the stack trace at the
bottom of the email highlights my point.

> More importantly, why is it a good idea to stop running timers during
> this accept-process-output call and ignore output from other
> subprocesses?

I don't think that is the optimal solution.  But this does not ignore
output right, it just delays timers and filter functions.  If flyspell
is active in an comit buffer it might also screw up the point if process
outputs stuff during `accept-process-output'.

The best solution would be to run `accept-process-output' outside of the
body of save-excursion, but that would require a bit more mangling,
which might be worth the effort.

Let's create an simple example to illustrate the issue with current
implementation.  This is a highly construed example but there is always
the chance that flyspell has unexpected interactions with all buffers
that filter functions and timer functions modify the point of.

(defun timer-goto-point-min ()
  (goto-char (point-min)))

(defun some-command ()
  (interactive)
  ;; flyspell needs point to have been and at word.
  (goto-char (point-min))
  (re-search-forward "word.")
  ;; Goto top of buffer with timer
  (run-with-timer 0 0 'timer-goto-point-min))

(trace-function #'timer-goto-point-min)
(trace-function 'flyspell-word)
(trace-function 'accept-process-output)

;; Prepare buffer
(with-current-buffer (get-buffer-create "buffer")
  (save-excursion
    (insert "Some sentence with words."))
  (flyspell-mode))

;; Open buffer M-x some-command expects point to be at the start of
;; buffer 

;; 1 -> (flyspell-word)                    -- start of save-excursion
;; | 2 -> (accept-process-output #<process ispell>)
;; | | 3 -> (timer-goto-point-min)         -- moves point
;; | | 3 <- timer-goto-point-min: 1
;; | 2 <- accept-process-output: t
;; 1 <- flyspell-word: nil                 -- end of save-excursion
;;                                            resets the point


/Daniel




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#69733: [PATCH] Flyspell (flyspell-word): do not force 'save-excursion' on timers
Resent-From: Eli Zaretskii <eliz@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Thu, 14 Mar 2024 10:37:01 +0000
Resent-Message-ID: <handler.69733.B69733.171041261414211 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 69733
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: patch
To: Daniel Pettersson <daniel@HIDDEN>
Cc: 69733 <at> debbugs.gnu.org
Received: via spool by 69733-submit <at> debbugs.gnu.org id=B69733.171041261414211
          (code B ref 69733); Thu, 14 Mar 2024 10:37:01 +0000
Received: (at 69733) by debbugs.gnu.org; 14 Mar 2024 10:36:54 +0000
Received: from localhost ([127.0.0.1]:48411 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rkiSE-0003h6-6H
	for submit <at> debbugs.gnu.org; Thu, 14 Mar 2024 06:36:54 -0400
Received: from eggs.gnu.org ([209.51.188.92]:46326)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1rkiSB-0003gr-F8
 for 69733 <at> debbugs.gnu.org; Thu, 14 Mar 2024 06:36:52 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1rkiRW-0004CB-5N; Thu, 14 Mar 2024 06:36:10 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=ZzGHzXLKjgb+dBGUWqHxoJJxVggkS9Bb3EBlRwnMoeU=; b=AHv9xreyl1kM
 c2eMycvizZpXdu7dGZZQ4HdJ9BV6jTmnQmLk9h0GFcwHzbOrPzS9DO4oSAxovvweeIBJP7It91WCs
 urhH+LM3okpQLBjMPEPuS6ZNn+uRU+33spWjpLoV3VYhG+UmQ3lY0zTsoQhEVlPLAwm2DrVzc+ChG
 fEIUaZRrM4LLPP0S+kp9YJvHfZO4vmHzwD778WQ18N5Q5Mtas0cw9ATzJWoICfS9/qslJPMCCxAxB
 yIIt3q+wj2DHnRXHAIjJL6NgOwq03lgKBvBslwn1AR+PQZDvNqd7Jj9whAHry889pQWALiMIc4HD6
 nnIUdbo6T6tvCYfDJ+NIXw==;
Date: Thu, 14 Mar 2024 12:36:02 +0200
Message-Id: <86ttl99k31.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
In-Reply-To: <m2zfv34j95.fsf@HIDDEN> (message from Daniel Pettersson
 on Tue, 12 Mar 2024 15:28:22 +0100)
References: <m2sf0wzvek.fsf@HIDDEN> <86ttlbtwmt.fsf@HIDDEN>
 <m2zfv34j95.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Daniel Pettersson <daniel@HIDDEN>
> Cc: 69733 <at> debbugs.gnu.org
> Date: Tue, 12 Mar 2024 15:28:22 +0100
> 
> Eli Zaretskii <eliz@HIDDEN> writes:
> 
> > Thanks, but I don't think I understand the relation between what you
> > say above (and in the comments in your patch below) and the code
> > change you propose:
> 
> flyspell-word wraps it's body inside an `save-excursion'.
> 
> (defun flyspell-word (&optional following known-misspelling)
> ...
>   (save-excursion
> ...
> >>                    (while (progn
> >> -                           (accept-process-output ispell-process)
> >> +                           ;; don't force save-excursion to timers.
> >> +                           ;; only accept output from ispell-process.
> >> +                           (accept-process-output ispell-process nil nil t)
> 
> > Where's save-excursion and point moving to which you allude here?
> 
> See above and for point moving I think that the stack trace at the
> bottom of the email highlights my point.
> 
> > More importantly, why is it a good idea to stop running timers during
> > this accept-process-output call and ignore output from other
> > subprocesses?
> 
> I don't think that is the optimal solution.  But this does not ignore
> output right, it just delays timers and filter functions.  If flyspell
> is active in an comit buffer it might also screw up the point if process
> outputs stuff during `accept-process-output'.
> 
> The best solution would be to run `accept-process-output' outside of the
> body of save-excursion, but that would require a bit more mangling,
> which might be worth the effort.
> 
> Let's create an simple example to illustrate the issue with current
> implementation.  This is a highly construed example but there is always
> the chance that flyspell has unexpected interactions with all buffers
> that filter functions and timer functions modify the point of.
> 
> (defun timer-goto-point-min ()
>   (goto-char (point-min)))
> 
> (defun some-command ()
>   (interactive)
>   ;; flyspell needs point to have been and at word.
>   (goto-char (point-min))
>   (re-search-forward "word.")
>   ;; Goto top of buffer with timer
>   (run-with-timer 0 0 'timer-goto-point-min))
> 
> (trace-function #'timer-goto-point-min)
> (trace-function 'flyspell-word)
> (trace-function 'accept-process-output)
> 
> ;; Prepare buffer
> (with-current-buffer (get-buffer-create "buffer")
>   (save-excursion
>     (insert "Some sentence with words."))
>   (flyspell-mode))
> 
> ;; Open buffer M-x some-command expects point to be at the start of
> ;; buffer 
> 
> ;; 1 -> (flyspell-word)                    -- start of save-excursion
> ;; | 2 -> (accept-process-output #<process ispell>)
> ;; | | 3 -> (timer-goto-point-min)         -- moves point
> ;; | | 3 <- timer-goto-point-min: 1
> ;; | 2 <- accept-process-output: t
> ;; 1 <- flyspell-word: nil                 -- end of save-excursion
> ;;                                            resets the point

Thanks, but I'm still confused regarding what you are trying to fix
and why you are trying to fix it with the patch you proposed.

First, AFAIU, save-excursion is there because flyspell-get-word might
move point.  So this is justified.

Next, you seem to be saying that it is for some reason bad to run
timers under save-excursion, but you haven't explained why.  IMO, if a
timer that runs during post-command-hook moves point, that can have
negative effect on UX.  Also, code that runs from a timer cannot
possibly rely on Emacs leaving point where the timer moves it.

Are there any examples of timers that run like this which _must_ be
able to move point and make sure point stays where the timer moved it?




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#69733: [PATCH] Flyspell (flyspell-word): do not force 'save-excursion' on timers
Resent-From: Daniel Pettersson <daniel@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 15 Mar 2024 11:31:02 +0000
Resent-Message-ID: <handler.69733.B69733.171050223230946 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 69733
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: patch
To: Eli Zaretskii <eliz@HIDDEN>
Cc: 69733 <at> debbugs.gnu.org
Received: via spool by 69733-submit <at> debbugs.gnu.org id=B69733.171050223230946
          (code B ref 69733); Fri, 15 Mar 2024 11:31:02 +0000
Received: (at 69733) by debbugs.gnu.org; 15 Mar 2024 11:30:32 +0000
Received: from localhost ([127.0.0.1]:52143 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rl5lf-000821-VR
	for submit <at> debbugs.gnu.org; Fri, 15 Mar 2024 07:30:32 -0400
Received: from mail-lf1-f43.google.com ([209.85.167.43]:46213)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <daniel.dpettersson.net@HIDDEN>)
 id 1rl5le-0007ir-Ee
 for 69733 <at> debbugs.gnu.org; Fri, 15 Mar 2024 07:30:31 -0400
Received: by mail-lf1-f43.google.com with SMTP id
 2adb3069b0e04-512e39226efso1910824e87.0
 for <69733 <at> debbugs.gnu.org>; Fri, 15 Mar 2024 04:29:54 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1710502188; x=1711106988;
 h=mime-version:user-agent:message-id:date:references:in-reply-to
 :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date
 :message-id:reply-to;
 bh=nxATrIh/EacaUEeAabtqOyyFHqQ7g+bwCu90QEvdKtI=;
 b=rqpj0Nhj9x2gkr3ipUVqMEiWXm7YZV2/ZLPFPROZPP+WJ39SVFzym5IpDGdfUtDxvt
 vQ6+4JWgmtZM22ijpCHw7bfJW0VnBve82uCVla31relQQRAtMv/wBqbOsw7JYnOcMn/N
 7W5fmGSY4QLqpc4T7hR1RUQSF8B9uj4WORUOte0vxvHplJkvuo4CDLagztveAafwMRAj
 Kdt+LdkKsi67o6vora1RqUUMvjyzI8DNEIYGl3F8/V6cvycR4M8H/zdBaIrx2oCzSwMd
 nGXKi4Slx9/Stn+dy92b3UUQJH98KW7XwsOW0UxoSTV/SU2M3SmrgI/R3qjSe1Q8TXt3
 yeWQ==
X-Gm-Message-State: AOJu0YzhEt7YDGczGzWEsBUmxzJ2YVuoQ58WDayMwHu78WtObb/ydJay
 cWzOxVCC9LcRCQHC4M97Nmfo/zn3be5F+FOa5pAHnqVEC5u+G/uF6CxNslXS
X-Google-Smtp-Source: AGHT+IELvt2GhWs3GtpGvejgsfb4eEx9EAa6YwVP7rzo6tXvax0IUpYa1mzaJbIj9S+hM4gDAxG3HQ==
X-Received: by 2002:ac2:5b44:0:b0:513:d1cd:b90c with SMTP id
 i4-20020ac25b44000000b00513d1cdb90cmr2972026lfp.30.1710502187690; 
 Fri, 15 Mar 2024 04:29:47 -0700 (PDT)
Received: from Daniels-Air (c-72cde455.027-357-6d6c6d4.bbcust.telenor.se.
 [85.228.205.114]) by smtp.gmail.com with ESMTPSA id
 q5-20020ac25145000000b00512e594e235sm616686lfd.242.2024.03.15.04.29.46
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Fri, 15 Mar 2024 04:29:47 -0700 (PDT)
From: Daniel Pettersson <daniel@HIDDEN>
In-Reply-To: <86ttl99k31.fsf@HIDDEN> (Eli Zaretskii's message of "Thu, 14 Mar
 2024 12:36:02 +0200")
References: <m2sf0wzvek.fsf@HIDDEN> <86ttlbtwmt.fsf@HIDDEN>
 <m2zfv34j95.fsf@HIDDEN> <86ttl99k31.fsf@HIDDEN>
Date: Fri, 15 Mar 2024 12:29:46 +0100
Message-ID: <m24jd7wx5h.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.2 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.8 (/)

Eli Zaretskii <eliz@HIDDEN> writes:

> Thanks, but I'm still confused regarding what you are trying to fix
> and why you are trying to fix it with the patch you proposed.

Lets just preface with that for accept-process-output non idle timers
and process filters are the same thing, right?  So any filter or timer
might run inside of accept-process-output if JUST-THIS-ONE is nil.

The issue was noticed with the elpa package dape, with
flyspell-prog-mode.  But I was able to reproduce it in gdb-mi.el
(gud-next) as well.  The common denominator here is moving the point
from filter/timer functions, in both cases source buffers. 

It's definitely a bit more rare for this to happen for gdb-mi.el as it
moves it's point to the beginning of the line where it's highly unlikely
for there to be a word which flyspell-prog-mode sends of to
ispell-process to spell (and waits with accept-process-output),
additionally it depends on the speed of gdb and the ispell program. If
ispell stdouts before gdb, flyspell-word finishes before gud-filter is
evaled. 

> First, AFAIU, save-excursion is there because flyspell-get-word might
> move point.  So this is justified.

No doubt that the save-excursion is justified but it surly does not need
to wrap everything, one could be a bit more exact (wrap those parts)
that actually move the point.

> Next, you seem to be saying that it is for some reason bad to run
> timers under save-excursion, but you haven't explained why.

This has the chance to break both gdb-mi.el, dape and all other packages
that moves a point from filter and timer functions. I say chance here
because it all depends the timing of the process output and If the
buffer that the point is moved in is checked by flyspell think I gave my
explanation to what could break above. 

> Also, code that runs from a timer cannot
> possibly rely on Emacs leaving point where the timer moves it.

I have a feeling that there are a lot of other code, except dape and gud
that do.  As this is not only timers but any code that is called from an
process filter.

> Are there any examples of timers that run like this which _must_ be
> able to move point and make sure point stays where the timer moved it?

See above.

After some thinking I it might be impossible to impose anything on the
caller of accept-process-output.  And the bug is in dape and gdb-mi.el
that gud should call gud-display-line inside of an idle timer to ensure
that the point is moved, if I understand how idle timers are called
which might be false.

Maybe it would be a good idea if "(elisp) Timers" would mention these
things.  Would that be an good idea?  I could be up for writing something
up,  even if don't consider myself to be that good at writing
documentation.

/Daniel





Last modified: Fri, 15 Mar 2024 11:45:01 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.