emacs-evil / evil-surround

you will be surrounded (surround.vim for evil, the extensible vi layer)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Does not enable on buffers without a file

Silex opened this issue · comments

Hello,

I found a weird issue: if I do C-x b asdasd C-j then I'm in a buffer named asdasd that is not backed by a file. Here evil is enabled but evil-surround is NOT enabled.

If I enable evil-surround in that buffer then everything works as expected, I don't get why it does not get enabled, because I have (global-evil-surround-mode 1) in my config.

Here's my config:

(use-package evil
  :demand t
  :custom
  (evil-want-keybinding nil)
  (evil-want-C-d-scroll nil)
  (evil-want-C-i-scroll nil)
  (evil-want-Y-yank-to-eol t)
  (evil-default-cursor '(t "white"))
  (evil-magic 'very-magic)
  (evil-shift-width 2)
  (evil-want-fine-undo t)
  (evil-search-module 'evil-search)
  :config
  (evil-mode)
  (defalias #'forward-evil-word #'forward-evil-symbol))

(use-package evil-collection
  :demand t
  :after evil
  :config
  (evil-collection-init))

(use-package evil-surround
  :demand t
  :after evil
  :config
  (global-evil-surround-mode 1)
  (evil-define-key 'visual evil-surround-mode-map "s" 'evil-surround-region)
  (evil-define-key 'visual evil-surround-mode-map "S" 'evil-Surround-region))

Found this comment in evil-mode that is likely relevant:

;; No hooks are run in Fundamental buffers, so other measures are
;; necessary to initialize Evil in these buffers. When Evil is
;; enabled globally, the default value of `major-mode' is set to
;; `turn-on-evil-mode', so that Evil is enabled in Fundamental
;; buffers as well. Then, the buffer-local value of `major-mode' is
;; changed back to `fundamental-mode'. (Since the `evil-mode' function
;; is created by a macro, we use `defadvice' to augment it.)
(defadvice evil-mode (after start-evil activate)...

The funny thing is if I M-x fundamental-mode in that buffer then evil-surround is enabled 😕

well, I must admit that this seems way above my pay grade. 😄

(setq-default major-mode 'text-mode)

and forget about this fundamental mode limitation :)

see more details here #107 (comment)

I suggest this issue is closed, it's not specific to evil-surround

thank you @edkolev. closing.

Great, thanks for the workaround 👍