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: Tue, 12 Mar 2024 15:28:22 +0100 Message-ID: References: <86ttlbtwmt.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="39544"; 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 Tue Mar 12 15:29:44 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 1rk38R-000A0j-JM for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 12 Mar 2024 15:29:44 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rk38D-0007Yo-Ib; Tue, 12 Mar 2024 10:29:29 -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 1rk38C-0007Tq-AE for bug-gnu-emacs@gnu.org; Tue, 12 Mar 2024 10:29:28 -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 1rk38C-0005eE-06 for bug-gnu-emacs@gnu.org; Tue, 12 Mar 2024 10:29:28 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rk38k-00028L-FS for bug-gnu-emacs@gnu.org; Tue, 12 Mar 2024 10:30: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: Tue, 12 Mar 2024 14:30: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.17102537478082 (code B ref 69733); Tue, 12 Mar 2024 14:30:02 +0000 Original-Received: (at 69733) by debbugs.gnu.org; 12 Mar 2024 14:29:07 +0000 Original-Received: from localhost ([127.0.0.1]:43320 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rk37q-00026I-Sn for submit@debbugs.gnu.org; Tue, 12 Mar 2024 10:29:07 -0400 Original-Received: from mail-lf1-f45.google.com ([209.85.167.45]:43462) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rk37o-00025j-Qm for 69733@debbugs.gnu.org; Tue, 12 Mar 2024 10:29:06 -0400 Original-Received: by mail-lf1-f45.google.com with SMTP id 2adb3069b0e04-51325c38d10so4893e87.1 for <69733@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) Original-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) In-Reply-To: <86ttlbtwmt.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 12 Mar 2024 15:20:10 +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:281517 Archived-At: Eli Zaretskii 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 #) ;; | | 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