Sett ispell and flyspell settings only if hunspell is available

This commit is contained in:
Marcus Kammer 2024-08-17 11:01:59 +02:00
parent 64d76217f7
commit e5ecb97e3c
Signed by: marcuskammer
GPG key ID: C374817BE285268F

View file

@ -56,11 +56,43 @@
(shrface-trial) (shrface-trial)
(shrface-default-keybindings)) (shrface-default-keybindings))
(use-package flyspell (defun hunspell-available-p ()
:hook ((LaTeX-mode . flyspell-mode) "Check if Hunspell is available on the system."
(org-mode . flyspell-mode) (cond
(text-mode . flyspell-mode) ;; Check for Windows
(prog-mode . flyspell-prog-mode))) ((eq system-type 'windows-nt)
(or (executable-find "hunspell.exe")
(executable-find "hunspell")))
;; Check for Linux and other Unix-like systems
((or (eq system-type 'gnu/linux)
(eq system-type 'darwin)
(eq system-type 'berkeley-unix))
(executable-find "hunspell"))
;; Return nil for unsupported systems
(t nil)))
(when (hunspell-available-p)
(progn
(use-package flyspell
:hook ((LaTeX-mode . flyspell-mode)
(org-mode . flyspell-mode)
(text-mode . flyspell-mode)
(prog-mode . flyspell-prog-mode)))
(use-package ispell
:ensure nil
:config
;; On windows: Copy *.aff and *.dic files to C:\msys64\ucrt64\share\hunspell
;; `hunspell -D`, the program will display the dictionaries and affix files it
;; finds and loads.
;; (when (eq system-type 'windows-nt)
;; (setq ispell-program-name "c:/msys64/ucrt64/bin/hunspell.exe"))
(setq ispell-dictionary "german,english")
(setq ispell-local-dictionary-alist
'(("german" "[[:alpha:]]" "[^[:alpha:]]" "[']" t ("-d" "de_DE_frami,de_AT_frami,de_CH_frami") nil utf-8)
("english" "[[:alpha:]]" "[^[:alpha:]]" "[']" nil ("-d" "en_US,en_GB") nil utf-8)
("german,english" "[[:alpha:]]" "[^[:alpha:]]" "[']" nil ("-d" "de_DE_frami,en_US") nil utf-8)))
(setq ispell-hunspell-dictionary-alist ispell-local-dictionary-alist))))
(defun mk/nov-font-settings () (defun mk/nov-font-settings ()
(setq-local line-spacing 2)) (setq-local line-spacing 2))
@ -262,7 +294,7 @@
(use-package spotify :bind ("S-<pause>" . spotify-playpause)) (use-package spotify :bind ("S-<pause>" . spotify-playpause))
;; (use-package clojure-mode) ;; (use-package clojure-mode)
;; (use-package cider) ;; (use-package cider)
) )
(use-package mastodon (use-package mastodon
:defer t :defer t
@ -302,20 +334,7 @@
;; (cons "~/.rolo.otl" ;; (cons "~/.rolo.otl"
;; (directory-files-recursively org-directory (rx "." (or "org" "otl") eos)))))))) ;; (directory-files-recursively org-directory (rx "." (or "org" "otl") eos))))))))
(use-package ispell
:ensure nil
:config
;; On windows: Copy *.aff and *.dic files to C:\msys64\ucrt64\share\hunspell
;; `hunspell -D`, the program will display the dictionaries and affix files it
;; finds and loads.
;; (when (eq system-type 'windows-nt)
;; (setq ispell-program-name "c:/msys64/ucrt64/bin/hunspell.exe"))
(setq ispell-dictionary "german,english")
(setq ispell-local-dictionary-alist
'(("german" "[[:alpha:]]" "[^[:alpha:]]" "[']" t ("-d" "de_DE_frami,de_AT_frami,de_CH_frami") nil utf-8)
("english" "[[:alpha:]]" "[^[:alpha:]]" "[']" nil ("-d" "en_US,en_GB") nil utf-8)
("german,english" "[[:alpha:]]" "[^[:alpha:]]" "[']" nil ("-d" "de_DE_frami,en_US") nil utf-8)))
(setq ispell-hunspell-dictionary-alist ispell-local-dictionary-alist))
(use-package plantuml-mode (use-package plantuml-mode
:mode ("\\.puml\\'" "\\.plantuml\\'") :mode ("\\.puml\\'" "\\.plantuml\\'")