Function: flyspell-large-region

flyspell-large-region is a byte-compiled function defined in flyspell.el.gz.

Signature

(flyspell-large-region BEG END)

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/flyspell.el.gz
;;*---------------------------------------------------------------------*/
;;*    flyspell-large-region ...                                        */
;;*---------------------------------------------------------------------*/
(defun flyspell-large-region (beg end)
  (let* ((curbuf  (current-buffer))
	 (buffer  (get-buffer-create "*flyspell-region*")))
    (setq flyspell-external-ispell-buffer buffer)
    (setq flyspell-large-region-buffer curbuf)
    (setq flyspell-large-region-beg beg)
    (setq flyspell-large-region-end end)
    (flyspell-accept-buffer-local-defs)
    (set-buffer buffer)
    (erase-buffer)
    ;; this is done, we can start checking...
    (if flyspell-issue-message-flag (message "Checking region..."))
    (set-buffer curbuf)
    (ispell-set-spellchecker-params)  ; Initialize variables and dicts alists
    ;; Local dictionary becomes the global dictionary in use.
    (setq ispell-current-dictionary
	  (or ispell-local-dictionary ispell-dictionary))
    (setq ispell-current-personal-dictionary
	  (or ispell-local-pdict ispell-personal-dictionary))
    (let ((args (ispell-get-ispell-args))
	  (encoding (ispell-get-coding-system))
	  c)
      (if (and ispell-current-dictionary  ; use specified dictionary
	       (not (member "-d" args)))  ; only define if not overridden
	  (setq args
		(append (list "-d" ispell-current-dictionary) args)))
      (if ispell-current-personal-dictionary ; use specified pers dict
	  (setq args
		(append args
			(list "-p"
			      (expand-file-name
			       ispell-current-personal-dictionary)))))

      ;; Check for extended character mode
      (let ((extended-char-mode (ispell-get-extended-character-mode)))
        (and extended-char-mode          ; ~ extended character mode
	     (string-match "[^~]+$" extended-char-mode)
	     (cl-pushnew (concat "-T" (match-string 0 extended-char-mode))
                         args :test #'equal)))

      ;; Add ispell-extra-args
      (setq args (append args ispell-extra-args))

      ;; If we are using recent aspell or hunspell, make sure we use the right encoding
      ;; for communication. ispell or older aspell/hunspell does not support this
      (if ispell-encoding8-command
	  (setq args
		(append args
			(if ispell-really-hunspell
			    (list ispell-encoding8-command
				  (upcase (symbol-name encoding)))
			  (list (concat ispell-encoding8-command
					(symbol-name encoding)))))))

      (let ((process-coding-system-alist (list (cons "\\.*" encoding))))
	(setq c (apply 'ispell-call-process-region beg
		       end
		       ispell-program-name
		       nil
		       buffer
		       nil
		       (if ispell-really-aspell "list" "-l")
		       args)))
      (if (eq c 0)
	  (progn
	    (flyspell-process-localwords buffer)
	    (with-current-buffer curbuf
	      (flyspell-delete-region-overlays beg end)
	      (flyspell-check-region-doublons beg end))
	    (flyspell-external-point-words))
	(error "Can't check region")))))