Add emacs mode checks to insert mode checks

This is to accommodate users who default to emacs mode, rather than
insert mode. The two are also very alike, so many of these checks should
apply to both (almost) equally.
This commit is contained in:
Henrik Lissner 2020-12-11 17:36:12 -05:00
parent 8edabbecfa
commit d149c59d2e
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
4 changed files with 13 additions and 5 deletions

View file

@ -199,7 +199,10 @@ e.g. proselint and langtool."
(add-hook 'flyspell-mode-hook #'+spell-init-flyspell-predicate-h) (add-hook 'flyspell-mode-hook #'+spell-init-flyspell-predicate-h)
(let ((flyspell-correct (let ((flyspell-correct
(cmds! (and (not (or mark-active (ignore-errors (evil-insert-state-p)))) (cmds! (and (not mark-active)
(not (and (bound-and-true-p evil-local-mode)
(or (evil-insert-state-p)
(evil-emacs-state-p))))
(memq 'flyspell-incorrect (face-at-point nil t))) (memq 'flyspell-incorrect (face-at-point nil t)))
#'flyspell-correct-at-point))) #'flyspell-correct-at-point)))
(map! :map flyspell-mouse-map (map! :map flyspell-mouse-map

View file

@ -121,7 +121,8 @@ more information on modifiers."
(defun +evil--insert-newline-below-and-respect-comments-a (orig-fn count) (defun +evil--insert-newline-below-and-respect-comments-a (orig-fn count)
(if (or (not +evil-want-o/O-to-continue-comments) (if (or (not +evil-want-o/O-to-continue-comments)
(not (eq this-command 'evil-open-below)) (not (eq this-command 'evil-open-below))
(evil-insert-state-p)) (evil-insert-state-p)
(evil-emacs-state-p))
(funcall orig-fn count) (funcall orig-fn count)
(letf! (defun evil-insert-newline-below () (+evil--insert-newline)) (letf! (defun evil-insert-newline-below () (+evil--insert-newline))
(let ((evil-auto-indent evil-auto-indent)) (let ((evil-auto-indent evil-auto-indent))
@ -131,7 +132,8 @@ more information on modifiers."
(defun +evil--insert-newline-above-and-respect-comments-a (orig-fn count) (defun +evil--insert-newline-above-and-respect-comments-a (orig-fn count)
(if (or (not +evil-want-o/O-to-continue-comments) (if (or (not +evil-want-o/O-to-continue-comments)
(not (eq this-command 'evil-open-above)) (not (eq this-command 'evil-open-above))
(evil-insert-state-p)) (evil-insert-state-p)
(evil-emacs-state-p))
(funcall orig-fn count) (funcall orig-fn count)
(letf! (defun evil-insert-newline-above () (+evil--insert-newline 'above)) (letf! (defun evil-insert-newline-above () (+evil--insert-newline 'above))
(let ((evil-auto-indent evil-auto-indent)) (let ((evil-auto-indent evil-auto-indent))

View file

@ -93,6 +93,7 @@ info in the `header-line-format' is a more visible indicator."
"Start git-commit-mode in insert state if in a blank commit message, "Start git-commit-mode in insert state if in a blank commit message,
otherwise in default state." otherwise in default state."
(when (and (bound-and-true-p evil-mode) (when (and (bound-and-true-p evil-mode)
(not (evil-emacs-state-p))
(bobp) (eolp)) (bobp) (eolp))
(evil-insert-state))))) (evil-insert-state)))))

View file

@ -387,7 +387,8 @@ another level of headings on each invocation."
Made for `org-tab-first-hook' in evil-mode." Made for `org-tab-first-hook' in evil-mode."
(interactive) (interactive)
(cond ((not (and (bound-and-true-p evil-local-mode) (cond ((not (and (bound-and-true-p evil-local-mode)
(evil-insert-state-p))) (or (evil-insert-state-p)
(evil-emacs-state-p))))
nil) nil)
((org-at-item-p) ((org-at-item-p)
(if (eq this-command 'org-shifttab) (if (eq this-command 'org-shifttab)
@ -424,7 +425,8 @@ Made for `org-tab-first-hook'."
;; in the few cases where it does. ;; in the few cases where it does.
(yas-indent-line 'fixed)) (yas-indent-line 'fixed))
(cond ((and (or (not (bound-and-true-p evil-local-mode)) (cond ((and (or (not (bound-and-true-p evil-local-mode))
(evil-insert-state-p)) (evil-insert-state-p)
(evil-emacs-state-p))
(yas--templates-for-key-at-point)) (yas--templates-for-key-at-point))
(yas-expand) (yas-expand)
t) t)