From: Eshel Yaron via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 74437@debbugs.gnu.org, mail@alternateved.com
Subject: bug#74437: 30.0.92; completion-preview-idle-delay is delayed by flyspell
Date: Fri, 22 Nov 2024 08:26:42 +0100 [thread overview]
Message-ID: <m1frnjd8zx.fsf@macbookpro.home> (raw)
In-Reply-To: <86jzcxswbx.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 20 Nov 2024 18:29:06 +0200")
[-- Attachment #1: Type: text/plain, Size: 1361 bytes --]
Eli Zaretskii <eliz@gnu.org> writes:
>> From: Eshel Yaron <me@eshelyaron.com>
>> Cc: 74437@debbugs.gnu.org, mail@alternateved.com
>> Date: Wed, 20 Nov 2024 16:52:49 +0100
>>
>> Eli Zaretskii <eliz@gnu.org> writes:
>>
>> >> From: Eshel Yaron <me@eshelyaron.com>
>> >> Cc: 74437@debbugs.gnu.org, mail@alternateved.com
>> >> Date: Tue, 19 Nov 2024 21:16:56 +0100
>> >
>> >> > Also, what happens if there are other async
>> >> > subprocesses running in parallel, like maybe Grep or compilation or
>> >> > url-retrieve?
>> >>
>> >> They make progress, which seems to work as expected, at least with Grep.
>> >> That is if we use the previous patch, with the one below we pass non-nil
>> >> JUST-THIS-ONE argument to accept-process-output when called from a timer
>> >> so other processes shouldn't see new output during this call. Either
>> >> way works, AFAICT.
>> >
>> > The question is: what do users expect to happen in those cases?
>>
>> I don't know
>
> Neither do I. I didn't say something was wrong with either of these
> implementations, I'm just saying they should be well tested by users
> before we have enough basis to make the decisions whether the idea is
> generally good and whether it should probably become the default in
> some future version.
Sounds good. So here's a full patch that keeps the current
implementation as the default:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-New-option-flyspell-delay-use-timer.patch --]
[-- Type: text/x-patch, Size: 3105 bytes --]
From 0dfa6f8b4aaa825a2587fa36f30bf9f55918ff3d Mon Sep 17 00:00:00 2001
From: Eshel Yaron <me@eshelyaron.com>
Date: Fri, 22 Nov 2024 08:17:25 +0100
Subject: [PATCH] New option 'flyspell-delay-use-timer'
* lisp/textmodes/flyspell.el (flyspell-delay-use-timer):
New user option.
(flyspell--timer): New variable.
(flyspell-check-word-p): Use them.
(flyspell-post-command-hook): Disable timer.
(flyspell-word): Pass non-nil SECONDS argument to
'accept-process-output' to permit quitting. (bug#74437)
---
lisp/textmodes/flyspell.el | 26 ++++++++++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)
diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el
index 09d4e8a8d1a..5fcb83efb57 100644
--- a/lisp/textmodes/flyspell.el
+++ b/lisp/textmodes/flyspell.el
@@ -810,6 +810,18 @@ flyspell-check-changed-word-p
(let ((pos (point)))
(or (>= pos start) (<= pos stop) (= pos (1+ stop))))))))
+(defcustom flyspell-delay-use-timer nil
+ "Whether Flyspell should use a timer for waiting after a delayed command.
+
+If this is non-nil, Flyspell sets up a timer for checking the word at
+point `flyspell-delay' seconds after you invoke a delayed command.
+Otherwise, if this option is nil, Flyspell uses `sit-for' to wait for
+that duration instead."
+ :type 'boolean
+ :version "31.1")
+
+(defvar flyspell--timer nil)
+
;;*---------------------------------------------------------------------*/
;;* flyspell-check-word-p ... */
;;*---------------------------------------------------------------------*/
@@ -844,7 +856,16 @@ flyspell-check-word-p
;; The current command is not delayed, that
;; is that we must check the word now.
(and (not unread-command-events)
- (sit-for flyspell-delay)))
+ (if (not flyspell-delay-use-timer)
+ (sit-for flyspell-delay)
+ (setq flyspell--timer
+ (run-with-idle-timer
+ flyspell-delay nil
+ (lambda (buffer)
+ (when (eq (current-buffer) buffer)
+ (flyspell-word nil nil t)))
+ (current-buffer)))
+ nil)))
(t t)))
(t t))))
@@ -955,6 +976,7 @@ flyspell-debug-signal-changed-checked
(defun flyspell-post-command-hook ()
"The `post-command-hook' used by flyspell to check a word on-the-fly."
(interactive)
+ (when (timerp flyspell--timer) (cl-callf cancel-timer flyspell--timer))
(when flyspell-mode
(with-local-quit
(let ((command this-command)
@@ -1179,7 +1201,7 @@ flyspell-word
(set-process-query-on-exit-flag ispell-process nil)
;; Wait until ispell has processed word.
(while (progn
- (accept-process-output ispell-process)
+ (accept-process-output ispell-process 1)
(not (string= "" (car ispell-filter)))))
;; (ispell-send-string "!\n")
;; back to terse mode.
--
2.46.2
next prev parent reply other threads:[~2024-11-22 7:26 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-19 11:55 bug#74437: 30.0.92; completion-preview-idle-delay is delayed by flyspell Tomasz Hołubowicz via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-19 16:13 ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-19 16:56 ` Tomasz Hołubowicz via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-19 17:19 ` Eli Zaretskii
2024-11-19 18:40 ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-19 19:10 ` Eli Zaretskii
2024-11-19 20:16 ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-20 13:04 ` Eli Zaretskii
2024-11-20 15:52 ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-20 16:29 ` Eli Zaretskii
2024-11-22 7:26 ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2024-11-22 7:41 ` Eli Zaretskii
2024-11-22 8:55 ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m1frnjd8zx.fsf@macbookpro.home \
--to=bug-gnu-emacs@gnu.org \
--cc=74437@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=mail@alternateved.com \
--cc=me@eshelyaron.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).