With the guide on extending Emacs, I discovered the volatile highlights package.

But it only works on Emacs operations like kill and yank. I would like to use it with Evil operations like evil-yank evil-delete, and evil-paste-after.

I thought about advising those functions with defadvice, but that didn't work. Any other suggestions for getting it working with Evil?

  • 2
    Post the advice please. Maybe we can fix it. – PythonNut Jun 4 '15 at 23:39
  • I had the defadvice that calls the yank operation after the evil-yank, in order to trigger defadvice. But then it yanked two times, which was not the intention. – ReneFroger Jun 5 '15 at 15:21
  • 2
    Please just add the advice to the question. If you do, we can fix it (probably). If you don't we won't. – PythonNut Jun 9 '15 at 22:46

Read the source code of volatile-highlights and you'll find you don't need advice at all, supporting any command is built into volatile-highlights. All you need is two lines of code:

(vhl/define-extension 'my-evil-highlights 'evil-yank 'evil-move 'some-other-functions ...)
(vhl/install-extension 'my-evil-highlights)

Read the docs for the two functions above for more info.

  • Error: [vhl] No load function for extension `vhl/use-my-evil-highlights-extension-p'. I'm not sure what to make of this. – PythonNut Jun 10 '15 at 2:35
  • 1
    Hmm. Works for me without errors (vhl/define-extension 'ut 'undo-tree-redo 'undo-tree-undo) (vhl/load-extension 'ut) – Tom Regner Jun 10 '15 at 8:25
  • Thanks for your answer, but it's not working in my case: pastebin.com/hUMDvEdM I looked up the commands that get called when press y or p or d in Evil, and added it to the list of my-evil-highlights. I don't get any error message, and I see no highlighting at all. Only when I do undo-operations. So I'm wondering what I'm missing here yet. – ReneFroger Jun 10 '15 at 15:41
  • 2
    The code in your paste works fine for me. I evaluated the two lines, enabled volatile-highlights-mode and then ran evil-paste-after and the pasted text was highlighted. – Jordon Biondo Jun 10 '15 at 16:14
  • 1
    After reading PythonNut answer, I tried it out. And yes, after running Emacs, you need to enable Volatile-highlights-mode, then it will run. Jordon, thanks for your answer. I have validated it. Congrats with your 5000 points! – ReneFroger Jun 14 '15 at 20:44

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.