* bug#61874: 30.0.50; Flyspell only changes
@ 2023-02-28 17:53 Juri Linkov
2024-03-14 18:11 ` Juri Linkov
0 siblings, 1 reply; 2+ messages in thread
From: Juri Linkov @ 2023-02-28 17:53 UTC (permalink / raw)
To: 61874
[-- Attachment #1: Type: text/plain, Size: 712 bytes --]
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.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: flyspell-check-changes.patch --]
[-- Type: text/x-diff, Size: 2653 bytes --]
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 ... */
;;*---------------------------------------------------------------------*/
^ permalink raw reply related [flat|nested] 2+ messages in thread
* bug#61874: 30.0.50; Flyspell only changes
2023-02-28 17:53 bug#61874: 30.0.50; Flyspell only changes Juri Linkov
@ 2024-03-14 18:11 ` Juri Linkov
0 siblings, 0 replies; 2+ messages in thread
From: Juri Linkov @ 2024-03-14 18:11 UTC (permalink / raw)
To: 61874
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.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-03-14 18:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-28 17:53 bug#61874: 30.0.50; Flyspell only changes Juri Linkov
2024-03-14 18:11 ` Juri Linkov
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.