changeset 86953:3508192ca0a3

Agustin Martin <agustin.martin at hispalinux.es> (flyspell-large-region): Explicitly set encoding for aspell process and for communication with it. Only add "-d" option if not already present. Use ispell-current-dictionary and ispell-current-personal-dictionary. General reorganization.
author Glenn Morris <rgm@gnu.org>
date Sun, 02 Dec 2007 18:17:34 +0000
parents 583c3d4f0b79
children 97ff503d0d62
files lisp/textmodes/flyspell.el
diffstat 1 files changed, 36 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/textmodes/flyspell.el	Sun Dec 02 18:17:08 2007 +0000
+++ b/lisp/textmodes/flyspell.el	Sun Dec 02 18:17:34 2007 +0000
@@ -1531,29 +1531,42 @@
     (if flyspell-issue-message-flag (message "Checking region..."))
     (set-buffer curbuf)
     (ispell-check-version)
-    (let ((c (apply 'ispell-call-process-region beg
-		    end
-		    ispell-program-name
-		    nil
-		    buffer
-		    nil
-		    (if ispell-really-aspell "list" "-l")
-		    (let (args)
-		      ;; Local dictionary becomes the global dictionary in use.
-		      (if ispell-local-dictionary
-			  (setq ispell-dictionary ispell-local-dictionary))
-		      (setq args (ispell-get-ispell-args))
-		      (if ispell-dictionary ; use specified dictionary
-			  (setq args
-				(append (list "-d" ispell-dictionary) args)))
-		      (if ispell-personal-dictionary ; use specified pers dict
-			  (setq args
-				(append args
-					(list "-p"
-					      (expand-file-name
-					       ispell-personal-dictionary)))))
-		      (setq args (append args ispell-extra-args))
-		      args))))
+    ;; 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)))))
+      (setq args (append args ispell-extra-args))
+      (if (and ispell-really-aspell
+	       ispell-aspell-supports-utf8)
+	  (setq args
+		(append args
+			(list
+			 (concat "--encoding="
+				 (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)