Skip to content

Commit

Permalink
tweak(natural-langs): make spell-fu obsolete
Browse files Browse the repository at this point in the history
  • Loading branch information
abougouffa committed Dec 25, 2023
1 parent 9e8ae0a commit 79aba80
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 40 deletions.
13 changes: 8 additions & 5 deletions modules/extras/me-spell-fu.el
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

;;; Code:

(message "me-spell-fu is deprecated")

;; Adapted from Doom Emacs
(defun +spell-fu--correct (replace poss word orig-pt start end)
"Correct word with spell-fu."
Expand Down Expand Up @@ -98,11 +100,12 @@
;;;###autoload
(defmacro +spell-fu-register-dictionaries! (&rest langs)
"Register dictionaries for `LANGS` to spell-fu's multi-dict."
(let* ((fn-name (intern (format "+spell-fu--multi-langs-%s-h" (string-join langs "-"))))
(closure `(defun ,fn-name ())))
(dolist (lang langs)
(setq closure (append closure `((+spell-fu--add-dictionary ,lang)))))
(append '(add-hook (quote spell-fu-mode-hook)) (list closure))))
(with-eval-after-load 'spell-fu
(let* ((fn-name (intern (format "+spell-fu--multi-langs-%s-h" (string-join langs "-"))))
(closure `(defun ,fn-name ())))
(dolist (lang langs)
(setq closure (append closure `((+spell-fu--add-dictionary ,lang)))))
(append '(add-hook (quote spell-fu-mode-hook)) (list closure)))))


(provide 'me-spell-fu)
Expand Down
35 changes: 0 additions & 35 deletions modules/me-natural-langs.el
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,6 @@

;;; Code:

(use-package spell-fu
:straight t
:when (executable-find "aspell")
:hook (text-mode . spell-fu-mode)
:hook (spell-fu-mode . +spell-fu--init-excluded-faces-h)
:custom
(spell-fu-directory (+directory-ensure minemacs-local-dir "spell-fu/"))
(spell-fu-word-delimit-camel-case t)
:init
(+map! "ts" #'spell-fu-mode)
(+nvmap! "z=" #'+spell-fu-correct) ; autoloaded from `me-spell-fu'

(defcustom +spell-excluded-faces-alist
'((markdown-mode
. (markdown-code-face markdown-html-attr-name-face markdown-html-attr-value-face
markdown-html-tag-name-face markdown-inline-code-face markdown-link-face
markdown-markup-face markdown-plain-url-face markdown-reference-face markdown-url-face))
(org-mode
. (org-block org-block-begin-line org-block-end-line org-cite org-cite-key org-code
org-date org-footnote org-formula org-inline-src-block org-latex-and-related org-link
org-meta-line org-property-value org-ref-cite-face org-special-keyword org-tag org-todo
org-todo-keyword-done org-todo-keyword-habt org-todo-keyword-kill org-todo-keyword-outd
org-todo-keyword-todo org-todo-keyword-wait org-verbatim))
(latex-mode
. (font-latex-math-face font-latex-sedate-face font-lock-function-name-face
font-lock-keyword-face font-lock-variable-name-face)))
"Faces in certain major modes that spell-fu will not spellcheck."
:group 'minemacs-ui
:type '(repeat (cons symbol (repeat face))))
:config
(defun +spell-fu--init-excluded-faces-h ()
"Set `spell-fu-faces-exclude' according to `+spell-excluded-faces-alist'."
(when-let (excluded (cdr (cl-find-if #'derived-mode-p +spell-excluded-faces-alist :key #'car)))
(setq-local spell-fu-faces-exclude excluded))))

(use-package go-translate
:straight (:host github :repo "lorniu/go-translate")
:commands +gts-yank-translated-region +gts-translate-with
Expand Down
50 changes: 50 additions & 0 deletions modules/obsolete/me-spell-fu.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
;;; me-spell-fu.el --- Spell-Fu -*- lexical-binding: t; -*-

;; Copyright (C) 2022-2023 Abdelhak Bougouffa

;; Author: Abdelhak Bougouffa (concat "abougouffa" "@" "fedora" "project" "." "org")

;;; Commentary:

;;; Code:

(use-package spell-fu
:straight t
:when (executable-find "aspell")
:hook (text-mode . spell-fu-mode)
:hook (spell-fu-mode . +spell-fu--init-excluded-faces-h)
:custom
(spell-fu-directory (+directory-ensure minemacs-local-dir "spell-fu/"))
(spell-fu-word-delimit-camel-case t)
:init
(+map! "ts" #'spell-fu-mode)
(+nvmap! "z=" #'+spell-fu-correct) ; autoloaded from `me-spell-fu'

(defcustom +spell-excluded-faces-alist
'((markdown-mode
. (markdown-code-face markdown-html-attr-name-face markdown-html-attr-value-face
markdown-html-tag-name-face markdown-inline-code-face markdown-link-face
markdown-markup-face markdown-plain-url-face markdown-reference-face markdown-url-face))
(org-mode
. (org-block org-block-begin-line org-block-end-line org-cite org-cite-key org-code
org-date org-footnote org-formula org-inline-src-block org-latex-and-related org-link
org-meta-line org-property-value org-ref-cite-face org-special-keyword org-tag org-todo
org-todo-keyword-done org-todo-keyword-habt org-todo-keyword-kill org-todo-keyword-outd
org-todo-keyword-todo org-todo-keyword-wait org-verbatim))
(latex-mode
. (font-latex-math-face font-latex-sedate-face font-lock-function-name-face
font-lock-keyword-face font-lock-variable-name-face)))
"Faces in certain major modes that spell-fu will not spellcheck."
:group 'minemacs-ui
:type '(repeat (cons symbol (repeat face))))
:config
(defun +spell-fu--init-excluded-faces-h ()
"Set `spell-fu-faces-exclude' according to `+spell-excluded-faces-alist'."
(when-let (excluded (cdr (cl-find-if #'derived-mode-p +spell-excluded-faces-alist :key #'car)))
(setq-local spell-fu-faces-exclude excluded))))


(provide 'obsolete/me-spell-fu)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; me-cov.el ends here

0 comments on commit 79aba80

Please sign in to comment.