Commit c478e4c5 authored by Agustín Martín's avatar Agustín Martín
Browse files

(ispell-really-hunspell): new variable to signal hunspell

(ispell-check-version):
Check if hunspell and set ispell-really-hunspell if needed
(ispell-send-string), (ispell-start-process), (flyspell-large-region):
Pass right options for hunspell if needed
parent 5a130941
......@@ -1526,6 +1526,7 @@ The buffer to mark them in is `flyspell-large-region-buffer'."
(or ispell-local-pdict ispell-personal-dictionary))
(let ((args (ispell-get-ispell-args))
(encoding (ispell-get-coding-system))
encoding-command
c)
(if (and ispell-current-dictionary ; use specified dictionary
(not (member "-d" args))) ; only define if not overridden
......@@ -1538,14 +1539,21 @@ The buffer to mark them in is `flyspell-large-region-buffer'."
(expand-file-name
ispell-current-personal-dictionary)))))
(setq args (append args ispell-extra-args))
(if (and ispell-really-aspell
ispell-aspell-supports-utf8)
;; 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 (or (and ispell-really-aspell
ispell-aspell-supports-utf8
(setq encoding-command "--encoding="))
(and ispell-really-hunspell
(setq encoding-command "-i ")))
(setq args
(append args
(list
(concat "--encoding="
(concat encoding-command
(symbol-name
encoding))))))
(let ((process-coding-system-alist (list (cons "\\.*" encoding))))
(setq c (apply 'ispell-call-process-region beg
end
......
......@@ -668,7 +668,8 @@ Note that the CASECHARS and OTHERCHARS slots of the alist should
contain the same character set as casechars and otherchars in the
LANGUAGE.aff file \(e.g., english.aff\).")
(defvar ispell-really-aspell nil) ; Non-nil if aspell extensions should be used
(defvar ispell-really-aspell nil) ; Non-nil if aspell extensions should be used
(defvar ispell-really-hunspell nil) ; Non-nil if hunspell extensions should be used
(defvar ispell-aspell-supports-utf8 nil
"Non-nil means to try to automatically find aspell dictionaries.
......@@ -759,22 +760,29 @@ Otherwise returns the library directory name, if that is defined."
ispell-program-name (car ispell-required-version)
(car (cdr ispell-required-version))
(car (cdr (cdr ispell-required-version))))
;; check that it is the correct version.
(if (and (= (car (read-from-string (match-string-no-properties 2)))
(car (cdr ispell-required-version)))
(< (car (read-from-string (match-string-no-properties 3)))
(car (cdr (cdr ispell-required-version)))))
(setq ispell-offset 0))
;; Check to see if it's really aspell.
;; Check to see if it's really aspell or hunspell.
(goto-char (point-min))
(let (case-fold-search)
(setq ispell-really-aspell
(and (search-forward-regexp
"(but really Aspell \\(.*?\\)\\(-[0-9]+\\)?)" nil t)
(progn
(setq ispell-aspell-supports-utf8
(not (version< (match-string 1) "0.60")))
t)))))
(or
(setq ispell-really-aspell
(and (search-forward-regexp
"(but really Aspell \\(.*?\\)\\(-[0-9]+\\)?)" nil t)
(progn
(setq ispell-aspell-supports-utf8
(not (version< (match-string 1) "0.60")))
t)))
(setq ispell-really-hunspell
(search-forward-regexp
"(but really Hunspell \\(.*?\\)\\(-[0-9]+\\)?)" nil t))
)))
(kill-buffer (current-buffer)))
result))
......@@ -1493,7 +1501,10 @@ This allows it to improve the suggestion list based on actual mispellings."
(point-min) (point-max)
ispell-program-name nil
output-buf nil
"-a" "-m" ispell-args))
"-a"
;; hunspell -m option means something different
(if ispell-really-hunspell "" "-m")
ispell-args))
(set-buffer output-buf)
(goto-char (point-min))
(save-match-data
......@@ -2473,6 +2484,7 @@ When asynchronous processes are not supported, `run' is always returned."
"Start the ispell process, with support for no asynchronous processes.
Keeps argument list for future ispell invocations for no async support."
(let ((default-directory default-directory)
encoding-command
args)
(unless (and (file-directory-p default-directory)
(file-readable-p default-directory))
......@@ -2493,12 +2505,18 @@ Keeps argument list for future ispell invocations for no async support."
(append args
(list "-p"
(expand-file-name ispell-current-personal-dictionary)))))
(if (and ispell-really-aspell
ispell-aspell-supports-utf8)
;; 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 (or (and ispell-really-aspell
ispell-aspell-supports-utf8
(setq encoding-command "--encoding="))
(and ispell-really-hunspell
(setq encoding-command "-i ")))
(setq args
(append args
(list
(concat "--encoding="
(concat encoding-command
(symbol-name (ispell-get-coding-system)))))))
(setq args (append args ispell-extra-args))
......@@ -2509,9 +2527,9 @@ Keeps argument list for future ispell invocations for no async support."
(let ((process-connection-type ispell-use-ptys-p))
(apply 'start-process
"ispell" nil ispell-program-name
"-a" ; accept single input lines
"-m" ; make root/affix combos not in dict
args))
"-a" ; accept single input lines
(if ispell-really-hunspell "" "-m") ; make root/affix combos not in dict
args)) ; hunspell -m option means different
(setq ispell-cmd-args args
ispell-output-buffer (generate-new-buffer " *ispell-output*")
ispell-session-buffer (generate-new-buffer " *ispell-session*"))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment