checkers/spell: add add/remove word & next/prev error commands
So both spell-fu and flyspell users have a more consistent interface.
This commit is contained in:
parent
5de263f6a4
commit
91c1e705e6
4 changed files with 66 additions and 9 deletions
|
@ -26,3 +26,57 @@
|
|||
(cl-loop for ov in (overlays-at (or point (point)))
|
||||
if (overlay-get ov 'flyspell-overlay)
|
||||
return t))
|
||||
|
||||
;;;###autoload
|
||||
(defun +spell/add-word (word &optional scope)
|
||||
"Add WORD to your personal dictionary, within SCOPE.
|
||||
|
||||
SCOPE can be `buffer' or `session' to exclude words only from the current buffer
|
||||
or session. Otherwise, the addition is permanent."
|
||||
(interactive
|
||||
(list (progn (require 'flyspell)
|
||||
(flyspell-get-word))))
|
||||
(require 'flyspell)
|
||||
(cond
|
||||
((null scope)
|
||||
(ispell-send-string (concat "*" word "\n"))
|
||||
(ispell-send-string "#\n")
|
||||
(flyspell-unhighlight-at (point))
|
||||
(setq ispell-pdict-modified-p '(t)))
|
||||
((memq scope '(buffer session))
|
||||
(ispell-send-string (concat "@" word "\n"))
|
||||
(add-to-list 'ispell-buffer-session-localwords word)
|
||||
(or ispell-buffer-local-name ; session localwords might conflict
|
||||
(setq ispell-buffer-local-name (buffer-name)))
|
||||
(flyspell-unhighlight-at (point))
|
||||
(if (null ispell-pdict-modified-p)
|
||||
(setq ispell-pdict-modified-p
|
||||
(list ispell-pdict-modified-p)))
|
||||
(if (eq replace 'buffer)
|
||||
(ispell-add-per-file-word-list word))))
|
||||
(ispell-pdict-save t))
|
||||
|
||||
;;;###autoload
|
||||
(defun +spell/remove-word (word &optional _scope)
|
||||
"Remove WORD from your personal dictionary."
|
||||
(interactive)
|
||||
(user-error "Not supported yet with +flyspell"))
|
||||
|
||||
;;;###autoload
|
||||
(defun +spell/next-error ()
|
||||
"Jump to next flyspell error."
|
||||
(interactive)
|
||||
(call-interactively
|
||||
(if (featurep 'evil)
|
||||
#'evil-next-flyspell-error
|
||||
#'flyspell-goto-next-error)))
|
||||
|
||||
;;;###autoload
|
||||
(defun +spell/previous-error ()
|
||||
"Jump to previous flyspell error."
|
||||
(interactive)
|
||||
(call-interactively
|
||||
(if (featurep 'evil)
|
||||
#'evil-prev-flyspell-error
|
||||
;; TODO Implement this
|
||||
(user-error "Not supported"))))
|
||||
|
|
|
@ -105,3 +105,8 @@
|
|||
(unless (string-equal wrd word)
|
||||
(+spell--correct wrd poss word orig-pt start end))))))
|
||||
(ispell-pdict-save t)))))))
|
||||
|
||||
;;;###autoload (defalias '+spell/add-word #'spell-fu-word-add)
|
||||
;;;###autoload (defalias '+spell/remove-word #'spell-fu-word-remove)
|
||||
;;;###autoload (defalias '+spell/next-error #'spell-fu-goto-next-error)
|
||||
;;;###autoload (defalias '+spell/previous-error #'spell-fu-goto-previous-error)
|
||||
|
|
|
@ -390,12 +390,11 @@ directives. By default, this only recognizes C directives.")
|
|||
|
||||
;; implement dictionary keybinds
|
||||
;; evil already defines 'z=' to `ispell-word' = correct word at point
|
||||
(:when (not (featurep! :checkers spell +flyspell))
|
||||
:n "zq" #'spell-fu-word-add
|
||||
:n "zw" #'spell-fu-word-remove
|
||||
:m "[s" #'spell-fu-goto-previous-error
|
||||
:m "]s" #'spell-fu-goto-next-error
|
||||
)
|
||||
(:when (featurep! :checkers spell)
|
||||
:n "zq" #'+spell/add-word
|
||||
:n "zw" #'+spell/remove-word
|
||||
:m "[s" #'+spell/previous-error
|
||||
:m "]s" #'+spell/next-error)
|
||||
|
||||
;; ported from vim-unimpaired
|
||||
:n "] SPC" #'+evil/insert-newline-below
|
||||
|
|
|
@ -247,8 +247,7 @@ If rtags or rdm aren't available, fail silently instead of throwing a breaking e
|
|||
`((:ccls . ((:clang . ,(list :extraArgs ["-isystem/Library/Developer/CommandLineTools/usr/include/c++/v1"
|
||||
"-isystem/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include"
|
||||
"-isystem/usr/local/include"]
|
||||
:resourceDir (string-trim (shell-command-to-string "clang -print-resource-dir"))))))))))))
|
||||
|
||||
:resourceDir (cdr (doom-call-process "clang" "-print-resource-dir"))))))))))))
|
||||
|
||||
|
||||
(use-package! ccls
|
||||
|
@ -266,4 +265,4 @@ If rtags or rdm aren't available, fail silently instead of throwing a breaking e
|
|||
`(:clang ,(list :extraArgs ["-isystem/Library/Developer/CommandLineTools/usr/include/c++/v1"
|
||||
"-isystem/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include"
|
||||
"-isystem/usr/local/include"]
|
||||
:resourceDir (string-trim (shell-command-to-string "clang -print-resource-dir")))))))
|
||||
:resourceDir (cdr (doom-call-process "clang" "-print-resource-dir")))))))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue