GNU bug report logs - #61874
30.0.50; Flyspell only changes

Previous Next

Package: emacs;

Reported by: Juri Linkov <juri <at> linkov.net>

Date: Tue, 28 Feb 2023 18:01:02 UTC

Severity: wishlist

Tags: patch

Fixed in version 30.0.50

Done: Juri Linkov <juri <at> linkov.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 61874 in the body.
You can then email your comments to 61874 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#61874; Package emacs. (Tue, 28 Feb 2023 18:01:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Juri Linkov <juri <at> linkov.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 28 Feb 2023 18:01:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: bug-gnu-emacs <at> gnu.org
Subject: 30.0.50; Flyspell only changes
Date: Tue, 28 Feb 2023 19:53:06 +0200
[Message part 1 (text/plain, inline)]
Tags: patch

This feature is the opposite of the feature implemented by Augusto in
bug#61814.  The problem is that the default behavior of flyspell-mode
is too erratic.  It checks and highlights random words where the cursor
happens to travel while navigating the buffer.  The feature from Augusto
allows to check all words in the buffer that makes sense when the intention
of the user is to see all misspelled words to correct them.

OTOH, often there is no need to check all misspellings in the existing file,
but only newly entered text.  For such use cases extra highlighting
while moving thru the file causes too much distraction.  So here is
a new option that allow to check only text edited by the user.

[flyspell-check-changes.patch (text/x-diff, inline)]
diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el
index 84c207b8a48..ef11c0ca326 100644
--- a/lisp/textmodes/flyspell.el
+++ b/lisp/textmodes/flyspell.el
@@ -289,6 +289,11 @@ flyspell-auto-correct-binding
   "The key binding for flyspell auto correction."
   :type 'key-sequence)
 
+(defcustom flyspell-check-changes nil
+  "Check only edited text."
+  :type 'boolean
+  :version "30.1")
+
 ;;*---------------------------------------------------------------------*/
 ;;*    Mode specific options                                            */
 ;;*    -------------------------------------------------------------    */
@@ -627,7 +632,9 @@ flyspell-mode-on
   ;; we put the `flyspell-deplacement' property on some commands
   (flyspell-deplacement-commands)
   ;; we bound flyspell action to post-command hook
-  (add-hook 'post-command-hook (function flyspell-post-command-hook) t t)
+  (if flyspell-check-changes
+      (add-hook 'post-command-hook (function flyspell-check-changes) t t)
+    (add-hook 'post-command-hook (function flyspell-post-command-hook) t t))
   ;; we bound flyspell action to pre-command hook
   (add-hook 'pre-command-hook (function flyspell-pre-command-hook) t t)
   ;; we bound flyspell action to after-change hook
@@ -732,6 +739,7 @@ flyspell-pre-command-hook
 (defun flyspell-mode-off ()
   "Turn Flyspell mode off."
   ;; We remove the hooks.
+  (remove-hook 'post-command-hook (function flyspell-check-changes) t)
   (remove-hook 'post-command-hook (function flyspell-post-command-hook) t)
   (remove-hook 'pre-command-hook (function flyspell-pre-command-hook) t)
   (remove-hook 'after-change-functions 'flyspell-after-change-function t)
@@ -1016,6 +1024,20 @@ flyspell-post-command-hook
             (setq flyspell-changes (cdr flyspell-changes))))
         (setq flyspell-previous-command command)))))
 
+(defun flyspell-check-changes ()
+  "The `post-command-hook' used by flyspell to check only edits."
+  (when flyspell-mode
+    (with-local-quit
+      (when (consp flyspell-changes)
+        (let ((start (car (car flyspell-changes)))
+              (stop  (cdr (car flyspell-changes)))
+              (word (save-excursion (flyspell-get-word))))
+          (unless (and word (<= (nth 1 word) start) (>= (nth 2 word) stop))
+            (save-excursion
+              (goto-char start)
+              (flyspell-word))
+            (setq flyspell-changes nil)))))))
+
 ;;*---------------------------------------------------------------------*/
 ;;*    flyspell-notify-misspell ...                                     */
 ;;*---------------------------------------------------------------------*/

Severity set to 'wishlist' from 'normal' Request was from Stefan Kangas <stefankangas <at> gmail.com> to control <at> debbugs.gnu.org. (Mon, 04 Sep 2023 08:54:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#61874; Package emacs. (Thu, 14 Mar 2024 18:14:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: 61874 <at> debbugs.gnu.org
Subject: Re: bug#61874: 30.0.50; Flyspell only changes
Date: Thu, 14 Mar 2024 20:11:42 +0200
close 61874 30.0.50
thanks

> This feature is the opposite of the feature implemented by Augusto in
> bug#61814.  The problem is that the default behavior of flyspell-mode
> is too erratic.  It checks and highlights random words where the cursor
> happens to travel while navigating the buffer.  The feature from Augusto
> allows to check all words in the buffer that makes sense when the intention
> of the user is to see all misspelled words to correct them.
>
> OTOH, often there is no need to check all misspellings in the existing file,
> but only newly entered text.  For such use cases extra highlighting
> while moving thru the file causes too much distraction.  So here is
> a new option that allow to check only text edited by the user.

Now after a long period of testing pushed and closed.




bug marked as fixed in version 30.0.50, send any further explanations to 61874 <at> debbugs.gnu.org and Juri Linkov <juri <at> linkov.net> Request was from Juri Linkov <juri <at> linkov.net> to control <at> debbugs.gnu.org. (Thu, 14 Mar 2024 18:14:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 12 Apr 2024 11:24:30 GMT) Full text and rfc822 format available.

This bug report was last modified 12 days ago.

Previous Next


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