Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelmhoffman/285e1024b4195aec7bd34d34bc9accd0 to your computer and use it in GitHub Desktop.
Save michaelmhoffman/285e1024b4195aec7bd34d34bc9accd0 to your computer and use it in GitHub Desktop.
Workaround for Emacs for unimplemented part of hunspell win32 listdicpath()
(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