Subject: bug#45622: (flyspell-buffer) does not enable spelling highlighting

From: Eli Zaretskii <[email-masked]>
Date: Mon, 04 Jan 2021 16:54:09 +0200

> From: Christopher Dimech <[email-masked]>
> Cc: [email-masked]
> Date: Sun, 3 Jan 2021 17:58:16 +0100
> 
> The problem occurs with the following code.  If you comment out
> (flyspell-prog-mode) the wavy underline gets activated.  But not
> if you include  (flyspell-prog-mode).
> 
> (defvar flyspell-buffer-state nil)
> (defun flyspell-buffer-gungadin ()
>   "Corrects vocabulary by inspecting the spelling of text in a buffer."
>   (interactive)
> 
>   (pcase flyspell-buffer-state
>     (1 (message "%s" "Flyspell: Buffer")
>        (flyspell-buffer)
>        (setq flyspell-buffer-state 2))
> 
>     (2 (message "%s" "Flyspell: Off")
>        (flyspell-mode 0)
>        (setq flyspell-buffer-state 0))
> 
>     (_ (message "%s" "Flyspell: prog-mode")
>        (flyspell-prog-mode)
>        (setq flyspell-buffer-state 1))) )
> 
> (global-set-key (kbd "H-9") 'flyspell-buffer-gungadin)

I cannot reproduce with this, either.  Some steps are still missing,
though, so maybe there's something else you do to trigger the problem.

Here's what I did:

  . emacs -Q

  . Intentionally edit the comment at the top of *scratch* to make 2
    spelling mistakes in it.
  . Insert and evaluate the code you posted
  . Move point to beginning of buffer
  . Press the key you bind to this command once -- this activates the
    flyspell-prog-mode
  . Press the key the second time -- this runs flyspell-buffer and
    highlights the 2 typos I made