From: Thorsten Grothe <grothe_news@e.mail.de>
To: help-gnu-emacs@gnu.org
Subject: flyspell-buffer add word keep higlighted errors
Date: Tue, 5 Jan 2016 08:36:06 +0100 [thread overview]
Message-ID: <n6frp6$4v4$1@ger.gmane.org> (raw)
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
next reply other threads:[~2016-01-05 7:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-05 7:36 Thorsten Grothe [this message]
2016-01-06 6:02 ` flyspell-buffer add word keep higlighted errors Emanuel Berg
2016-01-06 8:54 ` Thorsten Grothe
2016-01-06 16:53 ` Emanuel Berg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='n6frp6$4v4$1@ger.gmane.org' \
--to=grothe_news@e.mail.de \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).