Try out jinx

This commit is contained in:
larstvei 2024-07-20 19:53:06 +02:00
parent dd47252be7
commit 8d5c90d13f

View File

@ -918,50 +918,17 @@
#+end_src #+end_src
* Spelling * Spelling
** Flyspell ** Jinx
Flyspell offers on-the-fly spell checking. Trying out [[https://github.com/minad/jinx][jinx]] in favor of the builtin flyspell.
When working with several languages, we should be able to cycle through the
languages we most frequently use. Every buffer should have a separate cycle
of languages, so that cycling in one buffer does not change the state in a
different buffer (this problem occurs if you only have one global cycle). We
can implement this by using a [[http://www.gnu.org/software/emacs/manual/html_node/elisp/Closures.html][closure]].
#+begin_src emacs-lisp #+begin_src emacs-lisp
(defun cycle-languages () (use-package jinx
"Changes the ispell dictionary to the first element in :hook (emacs-startup . global-jinx-mode)
ISPELL-LANGUAGES, and returns an interactive function that cycles :bind ("C-." . jinx-correct)
the languages in ISPELL-LANGUAGES when invoked."
(let ((ispell-languages (list "american" "norsk")))
(lambda ()
(interactive)
;; Rotates the languages cycle and changes the ispell dictionary.
(let ((rotated (nconc (cdr ispell-languages) (list (car ispell-languages)))))
(ispell-change-dictionary (car (setq ispell-languages rotated)))))))
#+end_src
We enable =flyspell-mode= for all text-modes, and use =flyspell-prog-mode=
for spell checking comments and strings in all programming modes. We bind
=C-c l= to a function returned from =cycle-languages=, giving a language
switcher for every buffer where flyspell is enabled.
#+begin_src emacs-lisp
(use-package flyspell
:ensure nil
:defer t
:if (executable-find "aspell")
:hook ((text-mode . flyspell-mode)
(prog-mode . flyspell-prog-mode)
(flyspell-mode . (lambda ()
(local-set-key
(kbd "C-c l")
(cycle-languages)))))
:config :config
(ispell-change-dictionary "american" t)) (setq jinx-languages "en_US nb"))
#+end_src #+end_src