[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
flyspell-buffer add word keep higlighted errors
From: |
Thorsten Grothe |
Subject: |
flyspell-buffer add word keep higlighted errors |
Date: |
Tue, 5 Jan 2016 08:36:06 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 |
Hello,
I got a small problem with flyspell. I start flyspell for my latex files
with a hook
(add-hook 'LaTeX-mode-hook #'turn-on-flyspell)
That checks only errors for the current session of course. So sometimes
I need to flyspell-buffer my old text. When I add an unknown word to the
user dic *all* other marked words vanish and I have to run
flyspell-buffer again, this is very frustrating for me, what I'm doing
wrong?
Here's my setup for flyspell and use-package:
;; Flyspell
(use-package flyspell
:ensure t
:bind (("<f8>" . flyspell-buffer)
("C-<f8>" . flyspell-goto-next-error)
("S-<f8>" . flyspell-goto-previous-error)
)
:init
(add-hook 'LaTeX-mode-hook #'turn-on-flyspell)
;;(add-hook 'LaTeX-mode-hook #'flyspell-buffer)
:config
;; move point to previous error
;; based on code by hatschipuh at
;; http://emacs.stackexchange.com/a/14912/2017
(defun flyspell-goto-previous-error (arg)
"Go to arg previous spelling error."
(interactive "p")
(while (not (= 0 arg))
(let ((pos (point))
(min (point-min)))
(if (and (eq (current-buffer) flyspell-old-buffer-error)
(eq pos flyspell-old-pos-error))
(progn
(if (= flyspell-old-pos-error min)
;; goto beginning of buffer
(progn
(message "Restarting from end of buffer")
(goto-char (point-max)))
(backward-word 1))
(setq pos (point))))
;; seek the next error
(while (and (> pos min)
(let ((ovs (overlays-at pos))
(r '()))
(while (and (not r) (consp ovs))
(if (flyspell-overlay-p (car ovs))
(setq r t)
(setq ovs (cdr ovs))))
(not r)))
(backward-word 1)
(setq pos (point)))
;; save the current location for next invocation
(setq arg (1- arg))
(setq flyspell-old-pos-error pos)
(setq flyspell-old-buffer-error (current-buffer))
(goto-char pos)
(if (= pos min)
(progn
(message "No more miss-spelled word!")
(setq arg 0))
(forward-word)))))
;; rechte Maus für Korrekturvorschläge
(progn
(define-key flyspell-mouse-map [down-mouse-3] #'flyspell-correct-word)
(define-key flyspell-mouse-map [mouse-3] #'undefined)
)
;; Hunspell
(when (executable-find "hunspell")
(setq-default ispell-program-name "hunspell")
(setq ispell-really-hunspell t))
(setq ispell-dictionary "de_DE")
)
Thanks in advance
Regards
Thorsten
- flyspell-buffer add word keep higlighted errors,
Thorsten Grothe <=