From e5ecb97e3c51e7addec88e3e3ac0a5fe03dc0f0e Mon Sep 17 00:00:00 2001 From: Marcus Kammer Date: Sat, 17 Aug 2024 11:01:59 +0200 Subject: [PATCH] Sett ispell and flyspell settings only if hunspell is available --- bundle/bundle--package.el | 59 ++++++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 20 deletions(-) diff --git a/bundle/bundle--package.el b/bundle/bundle--package.el index c190b2c5..7cab0338 100644 --- a/bundle/bundle--package.el +++ b/bundle/bundle--package.el @@ -56,11 +56,43 @@ (shrface-trial) (shrface-default-keybindings)) -(use-package flyspell - :hook ((LaTeX-mode . flyspell-mode) - (org-mode . flyspell-mode) - (text-mode . flyspell-mode) - (prog-mode . flyspell-prog-mode))) +(defun hunspell-available-p () + "Check if Hunspell is available on the system." + (cond + ;; Check for Windows + ((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 () (setq-local line-spacing 2)) @@ -262,7 +294,7 @@ (use-package spotify :bind ("S-" . spotify-playpause)) ;; (use-package clojure-mode) ;; (use-package cider) -) + ) (use-package mastodon :defer t @@ -302,20 +334,7 @@ ;; (cons "~/.rolo.otl" ;; (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 :mode ("\\.puml\\'" "\\.plantuml\\'")