From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#61874: 30.0.50; Flyspell only changes Date: Tue, 28 Feb 2023 19:53:06 +0200 Organization: LINKOV.NET Message-ID: <867cw1n0cd.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5431"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) To: 61874@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Feb 28 19:01:32 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pX4I8-0001Jf-7f for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 28 Feb 2023 19:01:32 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pX4I2-0000DG-7n; Tue, 28 Feb 2023 13:01:26 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pX4Hf-0008QN-J9 for bug-gnu-emacs@gnu.org; Tue, 28 Feb 2023 13:01:08 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pX4He-0005Zg-CA for bug-gnu-emacs@gnu.org; Tue, 28 Feb 2023 13:01:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pX4He-0007TH-7f for bug-gnu-emacs@gnu.org; Tue, 28 Feb 2023 13:01:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 28 Feb 2023 18:01:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 61874 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.167760726028702 (code B ref -1); Tue, 28 Feb 2023 18:01:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 28 Feb 2023 18:01:00 +0000 Original-Received: from localhost ([127.0.0.1]:51967 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pX4Hb-0007Sr-Nq for submit@debbugs.gnu.org; Tue, 28 Feb 2023 13:01:00 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:37000) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pX4Ha-0007Sk-7k for submit@debbugs.gnu.org; Tue, 28 Feb 2023 13:00:58 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pX4HZ-0008KD-Hw for bug-gnu-emacs@gnu.org; Tue, 28 Feb 2023 13:00:57 -0500 Original-Received: from relay4-d.mail.gandi.net ([217.70.183.196]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pX4HX-0005Z2-7r for bug-gnu-emacs@gnu.org; Tue, 28 Feb 2023 13:00:57 -0500 Original-Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id 4B4D5E0011 for ; Tue, 28 Feb 2023 18:00:50 +0000 (UTC) Received-SPF: pass client-ip=217.70.183.196; envelope-from=juri@linkov.net; helo=relay4-d.mail.gandi.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:257002 Archived-At: --=-=-= Content-Type: text/plain 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. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=flyspell-check-changes.patch 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 ... */ ;;*---------------------------------------------------------------------*/ --=-=-=--