Function: flyspell-goto-next-error
flyspell-goto-next-error is an interactive and byte-compiled function
defined in flyspell.el.gz.
Signature
(flyspell-goto-next-error &optional PREVIOUS)
Documentation
Go to the next error.
If PREVIOUS (interactively, the prefix), go to the previous error instead.
In general FLYSPELL-GOTO-NEXT-ERROR must be used after FLYSPELL-BUFFER.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/flyspell.el.gz
;;*---------------------------------------------------------------------*/
;;* flyspell-goto-next-error ... */
;;*---------------------------------------------------------------------*/
(defun flyspell-goto-next-error (&optional previous)
"Go to the next error.
If PREVIOUS (interactively, the prefix), go to the previous error
instead.
In general FLYSPELL-GOTO-NEXT-ERROR must be used after
FLYSPELL-BUFFER."
(interactive "P")
(let ((pos (point))
(max (if previous (point-min) (point-max))))
(when (and (eq (current-buffer) flyspell-old-buffer-error)
(eq pos flyspell-old-pos-error))
(if previous
(if (= flyspell-old-pos-error max)
(progn
(message "Restarting from end of the buffer")
(goto-char (point-max)))
(forward-word -1))
(if (= flyspell-old-pos-error max)
(progn
(message "Restarting from beginning of buffer")
(goto-char (point-min)))
(forward-word 1)))
(setq pos (point)))
;; Seek the next error.
(while (and (/= pos max)
(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)))
(setq pos (if previous (1- pos) (1+ pos))))
(goto-char pos)
(when previous
(forward-word -1))
;; Save the current location for next invocation.
(setq flyspell-old-pos-error (point))
(setq flyspell-old-buffer-error (current-buffer))
(when (= (point) max)
(message "No more miss-spelled words"))))