Function: flyspell-check-previous-highlighted-word

flyspell-check-previous-highlighted-word is an interactive and byte-compiled function defined in flyspell.el.gz.

Signature

(flyspell-check-previous-highlighted-word &optional ARG)

Documentation

Correct the closest previous word that is highlighted as misspelled.

This function scans for a word which starts before point that has been highlighted by Flyspell as misspelled. If it finds one, it proposes a replacement for that word. With prefix arg N, check the Nth word before point that's highlighted as misspelled.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/flyspell.el.gz
;;*---------------------------------------------------------------------*/
;;*    flyspell-check-previous-highlighted-word ...                     */
;;*---------------------------------------------------------------------*/
(defun flyspell-check-previous-highlighted-word (&optional arg)
  "Correct the closest previous word that is highlighted as misspelled.
This function scans for a word which starts before point that has been
highlighted by Flyspell as misspelled.  If it finds one, it proposes
a replacement for that word.  With prefix arg N, check the Nth word
before point that's highlighted as misspelled."
  (interactive "P")
  (let ((pos1 (point))
	(pos  (point))
	(arg  (if (or (not (numberp arg)) (< arg 1)) 1 arg))
	ov ovs)
    (if (catch 'exit
	  (while (and (setq pos (previous-overlay-change pos))
		      (not (= pos pos1)))
	    (setq pos1 pos)
	    (if (>= pos (point-min))
		(progn
		  (setq ovs (overlays-at pos))
		  (while (consp ovs)
		    (setq ov (car ovs))
		    (setq ovs (cdr ovs))
		    (if (and (flyspell-overlay-p ov)
			     (= 0 (setq arg (1- arg))))
			(throw 'exit t)))))))
	(save-excursion
	  (goto-char pos)
	  (ispell-word)
	  (setq flyspell-word-cache-word nil) ;; Force flyspell-word re-check
	  (flyspell-word))
      (error "No word to correct before point"))))