[Top][All Lists]

[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


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)
  (add-hook 'LaTeX-mode-hook #'turn-on-flyspell)
  ;;(add-hook 'LaTeX-mode-hook #'flyspell-buffer)
  ;; move point to previous error
  ;; based on code by hatschipuh at
  (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))
              (if (= flyspell-old-pos-error min)
                  ;; goto beginning of buffer
                    (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)
              (message "No more miss-spelled word!")
              (setq arg 0))
  ;; rechte Maus für Korrekturvorschläge
    (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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]