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

* Re: flyspell-buffer add word keep higlighted errors
  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
  0 siblings, 1 reply; 4+ messages in thread
From: Emanuel Berg @ 2016-01-06  6:02 UTC (permalink / raw)
  To: help-gnu-emacs

Thorsten Grothe <grothe_news@e.mail.de> writes:

> 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?

As I've said a couple of times, I don't think flyspell
is a good idea, instead I prefer to do spelling once
and have the write and spell processes separated in
time. (But that's me and not you.)

What you are doing wrong is most likely putting all
that code into itself and each other like
a glacier icefall!

Take a look at this file of code, which by accident is
what I use for spelling:

    http://user.it.uu.se/~embe8573/conf/emacs-init/spell.el

You see the variables clearly defined at base level -
the settings - then the functions to control behavior.
Without boasting, it is mostly short and isolated
stuff with clear purposes and intentions.

If you write code in that style this will in one
strike get you closer to solving your problem if
indeed it remains. Whatever future problems/wishes
will be much easier to detect/solve/do, as well.

-- 
underground experts united
http://user.it.uu.se/~embe8573




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

* Re: flyspell-buffer add word keep higlighted errors
  2016-01-06  6:02 ` Emanuel Berg
@ 2016-01-06  8:54   ` Thorsten Grothe
  2016-01-06 16:53     ` Emanuel Berg
  0 siblings, 1 reply; 4+ messages in thread
From: Thorsten Grothe @ 2016-01-06  8:54 UTC (permalink / raw)
  To: help-gnu-emacs

Emanuel,

many thanks for your response. Well the reason for my untidy code is 
that I'm a beginner in emacs. I'll look at your example and try to use 
it with hunspell and hope it goes better then!

Regards
Thorsten







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

* Re: flyspell-buffer add word keep higlighted errors
  2016-01-06  8:54   ` Thorsten Grothe
@ 2016-01-06 16:53     ` Emanuel Berg
  0 siblings, 0 replies; 4+ messages in thread
From: Emanuel Berg @ 2016-01-06 16:53 UTC (permalink / raw)
  To: help-gnu-emacs

Thorsten Grothe <grothe_news@e.mail.de> writes:

> many thanks for your response. Well the reason for
> my untidy code is that I'm a beginner in emacs.
> I'll look at your example and try to use it with
> hunspell and hope it goes better then!

Try to isolate what parts of you code works or has
nothing to do with your issue.

-- 
underground experts united
http://user.it.uu.se/~embe8573




^ 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).