Created
June 10, 2020 02:15
-
-
Save michaelmhoffman/285e1024b4195aec7bd34d34bc9accd0 to your computer and use it in GitHub Desktop.
Workaround for Emacs for unimplemented part of hunspell win32 listdicpath()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require 'ispell) | |
(when (string-equal (getenv "LANG") "ENU") | |
(setenv "LANG" "en_US")) | |
;; XXX: hunspell doesn't work because Emacs wants to figure out where its | |
;; directories are, and for win32 hunspell 1.7.0, `hunspell -D` *never* runs listdicpath() | |
;; https://github.com/hunspell/hunspell/issues/669 | |
;; to correct, copied this bit from ispell-find-hunspell-dictionaries and | |
;; changed so that it removes a .dic extension from the list of dictionaries | |
;; used so can find the appropriate .aff file | |
;; XXX: should be advice instead of running absolutely | |
(when is-win32 | |
(let ((hunspell-found-dicts | |
(eval-when-compile | |
(split-string | |
(with-temp-buffer | |
(ispell-call-process ispell-program-name | |
null-device | |
t | |
nil | |
"-D" | |
"-a" | |
null-device) | |
(buffer-string)) | |
"[\n\r]+" | |
t)))) | |
(dolist (dict hunspell-found-dicts) | |
(let* ((full-name (file-name-nondirectory dict)) | |
(basename (file-name-sans-extension full-name)) | |
;; CHANGED from ispell.el: remove .dic if it's there | |
(affix-file (concat (file-name-sans-extension dict) ".aff"))) | |
(if (and (not (assoc basename ispell-hunspell-dict-paths-alist)) | |
(file-exists-p affix-file)) | |
;; Entry has an associated .aff file and no previous value. | |
(let ((affix-file (expand-file-name affix-file))) | |
(cl-pushnew (list basename affix-file) | |
ispell-hunspell-dict-paths-alist :test #'equal))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment