unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* flyspell-buffer add word keep higlighted errors
@ 2016-01-05  7:36 Thorsten Grothe
  2016-01-06  6:02 ` Emanuel Berg
  0 siblings, 1 reply; 4+ messages in thread
From: Thorsten Grothe @ 2016-01-05  7:36 UTC (permalink / raw)
  To: help-gnu-emacs

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






^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-01-06 16:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-05  7:36 flyspell-buffer add word keep higlighted errors Thorsten Grothe
2016-01-06  6:02 ` Emanuel Berg
2016-01-06  8:54   ` Thorsten Grothe
2016-01-06 16:53     ` Emanuel Berg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).