From 3f4fcd7c87c99efaf688f30984c813c5ec711557 Mon Sep 17 00:00:00 2001 From: condy Date: Sat, 10 Jul 2021 02:59:00 +0800 Subject: [PATCH] Add "zg" and "zG" bindings Implements evil-ispell-mark-word-as-good and evil-ispell-mark-word-as-locally-good --- evil-commands.el | 21 +++++++++++++++++++++ evil-maps.el | 2 ++ 2 files changed, 23 insertions(+) diff --git a/evil-commands.el b/evil-commands.el index 90ad702f8..1241f114b 100644 --- a/evil-commands.el +++ b/evil-commands.el @@ -636,6 +636,27 @@ and jump to the corresponding one." (when ov (goto-char (overlay-start ov)))))))) +(defun evil-ispell-mark-word-as-good (word) + "Add WORD under the cursor as a good word to the Ispell dictionary." + (interactive (list (thing-at-point 'word))) + (ispell-send-string (concat "*" word "\n")) + ;; dictionary modified! + (setq ispell-pdict-modified-p '(t)) + (ispell-pdict-save ispell-silently-savep) + (when-let ((flyspell-mode) + (start (car (bounds-of-thing-at-point 'word)))) + (flyspell-unhighlight-at start)) + (message "Word '%s' added to dictionary" (upcase word))) + +(defun evil-ispell-mark-word-as-locally-good (word) + "Add WORD under the cursor to the local word list." + (interactive (list (thing-at-point 'word))) + (ispell-add-per-file-word-list word) + (when-let ((flyspell-mode) + (start (car (bounds-of-thing-at-point 'word)))) + (flyspell-unhighlight-at start)) + (message "Word '%s' added to local word list" (upcase word))) + (evil-define-motion evil-next-flyspell-error (count) "Go to the COUNT'th spelling mistake after point." (interactive "p") diff --git a/evil-maps.el b/evil-maps.el index 7429acdb1..7e9875e38 100644 --- a/evil-maps.el +++ b/evil-maps.el @@ -82,6 +82,8 @@ (define-key evil-normal-state-map "za" 'evil-toggle-fold) (define-key evil-normal-state-map "zr" 'evil-open-folds) (define-key evil-normal-state-map "zm" 'evil-close-folds) +(define-key evil-normal-state-map "zg" 'evil-ispell-mark-word-as-good) +(define-key evil-normal-state-map "zG" 'evil-ispell-mark-word-as-locally-good) (define-key evil-normal-state-map "z=" 'ispell-word) (define-key evil-normal-state-map "\C-n" 'evil-paste-pop-next) (define-key evil-normal-state-map "\C-p" 'evil-paste-pop)