From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Daniel Pettersson Newsgroups: gmane.emacs.bugs Subject: bug#69733: [PATCH] Flyspell (flyspell-word): do not force 'save-excursion' on timers Date: Fri, 15 Mar 2024 12:29:46 +0100 Message-ID: References: <86ttlbtwmt.fsf@gnu.org> <86ttl99k31.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="39328"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 69733@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Mar 15 12:30:52 2024 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 1rl5m0-000A5Z-De for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 15 Mar 2024 12:30:52 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rl5lj-0000Sc-MQ; Fri, 15 Mar 2024 07:30:36 -0400 Original-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 ) id 1rl5lf-0000RA-BJ for bug-gnu-emacs@gnu.org; Fri, 15 Mar 2024 07:30:32 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rl5la-0001hp-KN for bug-gnu-emacs@gnu.org; Fri, 15 Mar 2024 07:30:26 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rl5mA-0000iH-Co for bug-gnu-emacs@gnu.org; Fri, 15 Mar 2024 07:31:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Daniel Pettersson Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 15 Mar 2024 11:31:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69733 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 69733-submit@debbugs.gnu.org id=B69733.171050223230946 (code B ref 69733); Fri, 15 Mar 2024 11:31:02 +0000 Original-Received: (at 69733) by debbugs.gnu.org; 15 Mar 2024 11:30:32 +0000 Original-Received: from localhost ([127.0.0.1]:52143 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rl5lf-000821-VR for submit@debbugs.gnu.org; Fri, 15 Mar 2024 07:30:32 -0400 Original-Received: from mail-lf1-f43.google.com ([209.85.167.43]:46213) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rl5le-0007ir-Ee for 69733@debbugs.gnu.org; Fri, 15 Mar 2024 07:30:31 -0400 Original-Received: by mail-lf1-f43.google.com with SMTP id 2adb3069b0e04-512e39226efso1910824e87.0 for <69733@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) Original-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) In-Reply-To: <86ttl99k31.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 14 Mar 2024 12:36:02 +0200") 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:281663 Archived-At: Eli Zaretskii 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