Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "zg" and "zG" bindings #1491

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions evil-commands.el
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
(require 'evil-jumps)
(require 'evil-vars)
(require 'flyspell)
(require 'ispell)
(require 'cl-lib)
(require 'reveal)

Expand Down Expand Up @@ -636,6 +637,38 @@ 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 t)))
;; accept and insert word into personal dictionary.
(ispell-send-string (concat "*" word "\n"))
condy0919 marked this conversation as resolved.
Show resolved Hide resolved
;; dictionary modified!
(setq ispell-pdict-modified-p '(t))
(ispell-pdict-save ispell-silently-savep)
(when (bound-and-true-p flyspell-mode)
(let ((start (car (bounds-of-thing-at-point 'word))))
(when start
(flyspell-unhighlight-at start))))
(message "Word '%s' added to personal dictionary" (upcase word)))

(defun evil-ispell-mark-word-as-locally-good (word &optional buffer-local)
"Add WORD under the cursor to the session dictionary.
If BUFFER-LOCAL is non-nil, the word will be added to current buffer."
(interactive (list (thing-at-point 'word t) current-prefix-arg))
;; accept word without insertion
(ispell-send-string (concat "@" word "\n"))
(add-to-list 'ispell-buffer-session-localwords word)
;; session localwords might conflict.
(unless ispell-buffer-local-name
(setq ispell-buffer-local-name (buffer-name)))
(when buffer-local
(ispell-add-per-file-word-list word))
(when (bound-and-true-p flyspell-mode)
(let ((start (car (bounds-of-thing-at-point 'word))))
(when start
(flyspell-unhighlight-at start))))
(message "Word '%s' added to local dictionary" (upcase word)))

(evil-define-motion evil-next-flyspell-error (count)
"Go to the COUNT'th spelling mistake after point."
(interactive "p")
Expand Down
2 changes: 2 additions & 0 deletions evil-maps.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down