Skip to content

Instantly share code, notes, and snippets.

@starstuck
Created April 28, 2020 17:53
Show Gist options
  • Save starstuck/e63955e4beff2119fdb38a741b3bc19e to your computer and use it in GitHub Desktop.
Save starstuck/e63955e4beff2119fdb38a741b3bc19e to your computer and use it in GitHub Desktop.
Using cygwin hunspell as Emacs ispell program
;; Working hunspell configuration for emacs for windows. It is using hunspell under Cygwin.
;;
;; It will require cygwin-mount.el downloaded to your emacs library path from
;; https://www.emacswiki.org/emacs/cygwin-mount.el
;;
;; Setup cygwin-mount first
(setq cygwin-directory "c:/cygwin")
(require `cygwin-mount)
(setq cygwin-mount-cygwin-bin-directory (concat cygwin-directory "/bin"))
(cygwin-mount-activate)
;; Hunspell configuration
(setenv "LANG" "en_GB.utf-8")
(setq ispell-program-name (concat cygwin-directory "/bin/hunspell"))
(defun advice-fix-nul-arg (orig-fun &rest args)
(message "Calling patched call process")
(let ((fixed-args
(append (seq-take args 4)
(mapcar (lambda (x) (if (eq x null-device) "/dev/null" x)) (nthcdr 4 args)))))
(apply orig-fun fixed-args)))
(defun advice-wrap-with-fix-nul-arg (orig-fun &rest args)
(advice-add 'ispell-call-process :around #'advice-fix-nul-arg)
(let ((result (apply orig-fun args)))
(advice-remove 'ispell-call-process #'advice-fix-nul-arg)
result))
(advice-add 'ispell-find-hunspell-dictionaries :around #'advice-wrap-with-fix-nul-arg)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment