TGViewer
/r/emacs /r/emacs @r_emacs · 80 subscribers
Post #28668 6
What is the most appropriate way to setup evil-mode so it stays out of the way where it isn't wanted? See my use-package evil configuration in the text.

This is my use-package configuration

(use-package evil
:ensure t
:custom (evil-want-fine-undo t)
:custom (evil-undo-system 'undo-fu)
:config
(evil-mode 1)
(define-key evil-normal-state-map (kbd "g ESC") 'ESC-prefix)

;; More configuration goes here
(use-package evil-leader
:ensure t
:config
(global-evil-leader-mode))

(use-package evil-surround
:ensure t
:config
(global-evil-surround-mode))

(use-package evil-indent-textobject
:ensure t)
)

evil-org

(use-package evil-org
:config
(progn
(add-hook 'org-mode-hook 'evil-org-mode)
(evil-org-set-key-theme '(navigation insert textobjects additional))
)
)


vterm

(use-package vterm
:config
(with-eval-after-load 'evil (evil-set-initial-state 'vterm-mode 'insert))
(add-hook 'vterm-mode-hook
(lambda ()
(define-key evil-insert-state-local-map (kbd "C-r") #'vterm-send-C-r)))
:bind (:map vterm-mode-map
("C-r" . vterm-send-C-r))
;; check what shadowing means here. It is overridden by evil-insert-state-mode-map
)

I have been installing some new non texting editing packages and this is where I have been getting problems because evil-mode interferes with their command key transients because those transients buffers or the windows that control them seem to slip back into normal-mode.


vulpea-ui

(use-package vulpea-ui
:defer t
:ensure nil
:quelpa
(vulpea-ui
:fetcher github
:repo "d12frosted/vulpea-ui"
:commit "e8766fa")
:config
(evil-set-initial-state 'vulpea-ui-collection-mode 'emacs)
)

excali

(use-package excali
:ensure nil
:load-path "site-lisp/excali-mode/"
:commands (excali-open excali-new)
:config
(evil-set-initial-state 'excali-mode-hook 'emacs)
:hook ((excali-mode . turn-off-evil-mode)
(excali-library-mode . turn-off-evil-mode)
(excali-library-official . turn-off-evil-mode)
(excali-library-official-preview . turn-off-evil-mode)
(excali-dsl-mode . turn-off-evil-mode))
)


canvas-browser is another one I will have to devote my attention to.

The problem is even after setting them to emacs ie (evil-set-initial-state 'vulpea-ui-collection-mode 'emacs) or :hook ((excali-mode . turn-off-evil-mode)) they switch back to normal-mode with N in the mode line and I wonder what is going behind the scenes.

It seems that during some of the interactions some new replacement /shadow buffers are created or some operations turn the emacs-mode buffers back to normal-mode and those states must be trapped or reverted.

Which brings me to a question is (evil-set-initial-state 'some-mode 'emacs) a better way to turn off evil mode than :hook (some-mode . turn-off-evil-mode)?

What foolproof way is there of telling when a window has unexpectedly switched to evil-mode, or has been created with evil-mode ie mode-line contains N so I can use the right commands to turn off evil-mode in that window?

Is it possible for some mode to be activated in a window without some hook firing?

https://redd.it/1wyagc3
@r_emacs
Reddit From the emacs community on Reddit: canvas-browser: a Chromium page in an Emacs buffer, drawn on an Emacs 32 canvas image Explore this post and more from the emacs community
More from @r_emacs
  1. Oct 5, 2026I will never ever play "close words" game (low effort post) https://redd.it/1wyj7ll @r_ema…
  2. Oct 5, 2026M-x Machina — a workspace for coding agents inside Emacs https://preview.redd.it/5w1rmny7i…
  3. Oct 5, 2026Trouble setting up eglot I'm trying to set up eglot for javascript. I've installed typescr…
  4. Oct 5, 2026excali-mode 0.2.0: a diagram DSL with explicit placement and Org Babel support https://red…
  5. Oct 5, 2026Emacs vs Vim keys for the window manager TL;DR: How do y'all (if at all) juggle window man…
  6. Oct 5, 2026org-incremental-writing package I wanted a package which works well with denote, and would…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →