From 35c1ab1419174f72010c745d963a55b6c183443c Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sun, 6 May 2018 21:20:31 +0300 Subject: [PATCH] Don't remove highlight of misspelled word on pdict save * lisp/textmodes/ispell.el (ispell-pdict-save): Don't restart flyspell-mode, as bug#11963, which this was supposed to fix, is fixed better by ispell-command-loop, when the user types 'i' or 'a'. Restarting Flyspell mode when the personal dictionary is saved caused bug#31372 as side effect. (ispell-command-loop): Test 'flyspell-mode', not whether flyspell-unhighlight-at is fboundp, to determine whether Flyspell mode is turned on in the current buffer. (flyspell-unhighlight-at): Add declare-function form for it. (cherry picked from commit 91e582a31ada28fab5ae55bdbf959a9d30796587) --- lisp/textmodes/ispell.el | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el index 3674a7080be..2b88057dc4f 100644 --- a/lisp/textmodes/ispell.el +++ b/lisp/textmodes/ispell.el @@ -117,6 +117,8 @@ (defalias 'check-ispell-version 'ispell-check-version) +(declare-function flyspell-unhighlight-at "flyspell" (pos)) + ;;; ********************************************************************** ;;; The following variables should be set according to personal preference ;;; and location of binaries: @@ -2090,10 +2092,7 @@ If so, ask if it needs to be saved." (or no-query (y-or-n-p "Personal dictionary modified. Save? "))) (ispell-send-string "#\n") ; save dictionary - (message "Personal dictionary saved.") - (when flyspell-mode - (flyspell-mode 0) - (flyspell-mode 1))) + (message "Personal dictionary saved.")) ;; unassert variable, even if not saved to avoid questioning. (setq ispell-pdict-modified-p nil)) @@ -2221,15 +2220,16 @@ Global `ispell-quit' set to start location to continue spell session." ((= char ?i) ; accept and insert word into pers dict (ispell-send-string (concat "*" word "\n")) (setq ispell-pdict-modified-p '(t)) ; dictionary modified! - (when (fboundp 'flyspell-unhighlight-at) - (flyspell-unhighlight-at start)) + + (when flyspell-mode + (flyspell-unhighlight-at start)) nil) ((or (= char ?a) (= char ?A)) ; accept word without insert (ispell-send-string (concat "@" word "\n")) (cl-pushnew word ispell-buffer-session-localwords :test #'equal) - (when (fboundp 'flyspell-unhighlight-at) - (flyspell-unhighlight-at start)) + (when flyspell-mode + (flyspell-unhighlight-at start)) (or ispell-buffer-local-name ; session localwords might conflict (setq ispell-buffer-local-name (buffer-name))) (if (null ispell-pdict-modified-p) -- 2.11.4.GIT