GNU bug report logs - #74437
30.0.92; completion-preview-idle-delay is delayed by flyspell

Previous Next

Package: emacs;

Reported by: Tomasz Hołubowicz <mail <at> alternateved.com>

Date: Tue, 19 Nov 2024 15:05:01 UTC

Severity: normal

Found in version 30.0.92

Full log


Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Eshel Yaron <me <at> eshelyaron.com>
To: Tomasz Hołubowicz via "Bug reports for GNU Emacs, the
 Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
Cc: 74437 <at> debbugs.gnu.org,
 Tomasz Hołubowicz <mail <at> alternateved.com>
Subject: Re: bug#74437: 30.0.92; completion-preview-idle-delay is delayed by
 flyspell
Date: Tue, 19 Nov 2024 17:13:16 +0100
Hi there,

Tomasz Hołubowicz writes:

> Hello,
>
> This is my configuration for completion-preview:
>
> (use-package completion-preview
>   :hook (after-init . global-completion-preview-mode)
>   :bind (:map completion-preview-active-mode-map
>               ("M-n" . completion-preview-next-candidate)
>               ("M-p" . completion-preview-prev-candidate))
>   :custom (completion-preview-idle-delay 0.2)
>   :config
>   ;; Org mode has a custom `self-insert-command'
>   (push 'org-self-insert-command completion-preview-commands)
>
>   ;; Hide `completion-preview' overlay when invoking `completion-in-region'
>   (with-eval-after-load 'consult
>     (advice-add 'consult-completion-in-region :before (lambda (&rest _) (completion-preview-hide)))))

Side note: it is better to use (completion-preview-active-mode -1)
instead of (completion-preview-hide) to dismiss the preview, since
disabling the minor mode performs additional cleanup.  Perhaps I should
mention that in the documentation somewhere... :)

> When I enter org-mode file and flyspell-mode is toggled on then the
> completion-preview-idle-delay is much longer in reality that 0.2s. After
> I disable flyspell-mode, then the delay is truly 0.2s. It
> seems that completion-preview is being delayed by flyspell checking
> currently written word. It makes sense if we consider 'idle' literally,
> but I'm not sure if this is desired.

Thank you for this report.  I can reproduce the extended delay here.
(In the future, please provide a minimal recipe to reproduce the issue
starting from emacs -Q, if possible.)

The root cause is a peculiarity of flyspell-mode: it calls sit-for and
blocks Emacs for 3 whole seconds (by default, see flyspell-delay) after
certain commands, including after (org-)self-insert-command.  This also
blocks the idle timer that Completion Preview mode uses, unfortunately.

A quick search shows that this behavior of flyspell affects other
features as well.  For example, IIUC, auto completion in Corfu switched
to using run-at-time instead of run-with-idle-timer due to this issue.

I think flyspell should be modified to use a timer instead of sit-for,
so as to avoid blocking idle timers.  I can come up with such a patch,
but it's not quite trivial, so I wonder what others think about this
issue and how it should be addressed.

As a stopgap, you can try setting flyspell-delay to 0.


Best,

Eshel




This bug report was last modified 286 days ago.

Previous Next


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