Function: flyspell-process-localwords

flyspell-process-localwords is a byte-compiled function defined in flyspell.el.gz.

Signature

(flyspell-process-localwords MISSPELLINGS-BUFFER)

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/flyspell.el.gz
;;*---------------------------------------------------------------------*/
;;*    flyspell-process-localwords ...                                  */
;;*    -------------------------------------------------------------    */
;;*    This function is used to prevent marking of words explicitly     */
;;*    declared correct.                                                */
;;*---------------------------------------------------------------------*/
(defun flyspell-process-localwords (misspellings-buffer)
  (let ((localwords ispell-buffer-session-localwords)
	case-fold-search
	(ispell-casechars (ispell-get-casechars)))
    ;; Get localwords from the original buffer
    (save-excursion
      (goto-char (point-min))
      ;; Localwords parsing copied from ispell.el.
      (while (search-forward ispell-words-keyword nil t)
	(let ((end (point-at-eol))
	      string)
	  ;; buffer-local words separated by a space, and can contain
	  ;; any character other than a space.  Not rigorous enough.
	  (while (re-search-forward " *\\([^ ]+\\)" end t)
	    (setq string (buffer-substring-no-properties (match-beginning 1)
							 (match-end 1)))
	    ;; This can fail when string contains a word with invalid chars.
	    ;; Error handling needs to be added between Ispell and Emacs.
	    (if (and (< 1 (length string))
		     (equal 0 (string-match ispell-casechars string)))
		(push string localwords))))))
    ;; Remove localwords matches from misspellings-buffer.
    ;; The usual mechanism of communicating the local words to ispell
    ;; does not affect the special ispell process used by
    ;; flyspell-large-region.
    (with-current-buffer misspellings-buffer
      (save-excursion
	(dolist (word localwords)
	  (goto-char (point-min))
	  (let ((regexp (concat "^" word "\n")))
	    (while (re-search-forward regexp nil t)
	      (delete-region (match-beginning 0) (match-end 0)))))))))