I'm using evil-mode
and trying to make sure that it gets disabled after invoking an ansi-term
.
I've tried using before
and after
advice to advise the ansi-term
function, as well as adding a hook to term-mode
, but that doesn't seem to disable evil mode in the ansi-term buffer.
I ended up defining a separate interactive function that calls ansi-term
with a fixed argument and then disables evil-mode for just the current buffer.
(defun ansi-term-disable-evil ()
"interactively call ansi-term"
(interactive)
(ansi-term "/bin/tcsh") ; probably shouldn't be hardcoded
(evil-local-mode -1))
This function has the desired effect (disabling evil-mode in the ansi-term buffer).
Using after advice, however, does not work and I'm trying to understand why.
Here is what I I tried in an attempt to disable evil-mode locally after executing ansi-term
.
(defun ansi-term-post ()
"configuration settings for ansi-term"
(evil-local-mode -1))
(advice-add 'ansi-term :after 'ansi-term-post) ; I used an ordinary symbol here, not a function object with #'
However, this didn't actually disable evil-mode in the ansi-term buffer. I'm trying to understand why.
funcall
that value inside the body of the new definition ofansi-term
. Advice is visible on the advised function, is disable-able, and IIRC there are a fixed number of advice slots on a function. But yeah I'd like to advise a function in such a way that the advised-ness is not visible to the outside world ...defun
. Why don't you want to use an around advice? As @npostavs said: show what you've tried and explain what doesn't "work". And say why you do not want "visible" advice.