I am working on Spacemacs which gives you the ability toggle between Emacs "holy-mode" and Vim "evil-mode". However the evil-escape minor mode is still enabled. I am trying to find some way to disable evil-escape in the holy-mode setup function and then restore its previous state (enabled/disabled) in holy-mode's teardown function. I tried this but it didn't work.

  ;; setup
  (setq evil-escape-mode-set (symbol-value 'evil-escape-mode))
  (evil-escape-mode -1)

  ;; teardown
  (when (evil-escape-mode-set)

but the teardown doesn't seem to work. How can I accomplish this?

  • No need to use symbol-value or even define a variable. Every properly defined mode defined a variable with the same name you can use for this. – wasamasa May 18 '17 at 21:01
  • But when I have to save that variable evil-escape-mode in order to restore it correct? – Prgrm.celeritas May 18 '17 at 21:02
  • No, it's set to nil or t by the mode. – wasamasa May 19 '17 at 6:12

It's unclear to me just what you are trying to do.

But it looks like you are setting a variable and then expecting it to be used as a function.

Emacs Lisp is a "Lisp 2", which means that you can have a variable and a function with the same name, and they are totally unrelated, by default. It also means that if you want to invoke a function-valued variable you need to use something like funcall or apply, not just have that symbol as the car of a list that is evaluated.

I think all you really want to do is this:

(when evil-escape-mode-set ...

instead of this:

(when (evil-escape-mode-set) ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.