setup flyweel with hunspell globally (spell checking)

This commit is contained in:
KemoNine 2022-08-25 14:03:48 -04:00
parent 6be2464ac7
commit 0f9321008e
2 changed files with 39 additions and 35 deletions

View File

@ -22,4 +22,6 @@ fi
cat ~/.emacs-profiles.el
echo "run emacs with each profile in '~/.emacs-profiles.el'"
echo "install multimarkdown (windows bin release + add to emacs path like sqlite3)"
echo "pacman -Ss mingw-w64-x86_64-{emacs,emacs-pdf-tools-server,imagemagick} in msys2"
echo "pacman -S mingw-w64-x86_64-{emacs,emacs-pdf-tools-server,imagemagick} in msys2"
echo "pacman -S mingw-w64-x86_64-texlive-full in msys2"
echo "pacman -S mingw-w64-x86_64-aspell mingw-w64-x86_64-hunspell mingw-w64-x86_64-hunspell-en in msys2"

View File

@ -395,38 +395,40 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; flyspell
;(require 'flyspell)
;(setenv "LANG" "en_US")
(require 'flyspell)
(setenv "LANG" "en_US")
;(setenv "DICPATH" "~/.emacs.d.profiles/common/dictionaries") ; https://github.com/wooorm/dictionaries
;(setq ispell-program-name "hunspell")
;(setq ispell-dictionary "en")
;
;(defun flyspell-on-for-buffer-type ()
; "Enable Flyspell appropriately for the major mode of the current buffer. Uses `flyspell-prog-mode' for modes derived from `prog-mode', so only strings and comments get checked. All other buffers get `flyspell-mode' to check all text. If flyspell is already enabled, does nothing."
; (interactive)
; (if (not (symbol-value flyspell-mode)) ; if not already on
; (progn
; (if (derived-mode-p 'prog-mode)
; (progn
; (message "Flyspell on (code)")
; (flyspell-prog-mode))
; ;; else
; (progn
; (message "Flyspell on (text)")
; (flyspell-mode 1)))
; ;; I tried putting (flyspell-buffer) here but it didn't seem to work
; )))
;
; (defun flyspell-toggle ()
; "Turn Flyspell on if it is off, or off if it is on. When turning on, it uses `flyspell-on-for-buffer-type' so code-vs-text is handled appropriately."
; (interactive)
; (if (symbol-value flyspell-mode)
; (progn ; flyspell is on, turn it off
; (message "Flyspell off")
; (flyspell-mode -1))
; ; else - flyspell is off, turn it on
; (flyspell-on-for-buffer-type)))
;
;(add-hook 'find-file-hook 'flyspell-on-for-buffer-type)
;(add-hook 'text-mode-hook 'flyspell-on-for-buffer-type)
;(add-hook 'after-change-major-mode-hook 'flyspell-on-for-buffer-type)
(setq ispell-program-name "hunspell")
(setq ispell-dictionary "en_US")
(global-set-key (kbd "C-c y") 'flyspell-toggle )
(defun flyspell-on-for-buffer-type ()
"Enable Flyspell appropriately for the major mode of the current buffer. Uses `flyspell-prog-mode' for modes derived from `prog-mode', so only strings and comments get checked. All other buffers get `flyspell-mode' to check all text. If flyspell is already enabled, does nothing."
(interactive)
(if (not (symbol-value flyspell-mode)) ; if not already on
(progn
(if (derived-mode-p 'prog-mode)
(progn
(message "Flyspell on (code)")
(flyspell-prog-mode))
;; else
(progn
(message "Flyspell on (text)")
(flyspell-mode 1)))
;; I tried putting (flyspell-buffer) here but it didn't seem to work
)))
(defun flyspell-toggle ()
"Turn Flyspell on if it is off, or off if it is on. When turning on, it uses `flyspell-on-for-buffer-type' so code-vs-text is handled appropriately."
(interactive)
(if (symbol-value flyspell-mode)
(progn ; flyspell is on, turn it off
(message "Flyspell off")
(flyspell-mode -1))
; else - flyspell is off, turn it on
(flyspell-on-for-buffer-type)))
(add-hook 'find-file-hook 'flyspell-on-for-buffer-type)
(add-hook 'text-mode-hook 'flyspell-on-for-buffer-type)
(add-hook 'after-change-major-mode-hook 'flyspell-on-for-buffer-type)