In org-mode, the link-following behaviour of RET, that should be present when org-return-follows-link is set, doesn't work in evil-mode.

MWE from emacs -q:

  1. Load an org buffer containing a link. Note that RET is bound to org-ret, but doesn't follow links. [Expected]
  2. Set org-return-follows-link. Hit RET when point is over a link. Emacs follows the link. [Expected]
  3. Enable evil-mode. Note that RET is now bound to evil-ret, and no longer follows links. [Not what I expected]

It makes no difference if evil-mode is enabled before or after we enter org-mode or set org-return-follows-link.

I also tried it with evil-org-mode from https://github.com/Somelauw/evil-org-mode, but that didn't make any difference either. I did notice some code in there that seems to optionally customise the behaviour of the return key according to a "keymap theme", but I didn't seem to be able to make any difference either by playing with that.

So, any idea how I can follow links in org-mode with evil-mode enabled, using RET? I suppose one option is just to override the mapping of RET to be org-ret, but I get the feeling that that will interfere with other uses of the key that evil relies on. Is there a smarter way that these two behaviours should be integrated?

Thanks.

The easy way out is to unbind RET for Evil as it isn't bound to a useful command anyway. This will let Emacs look it up in keymaps with less priority. You can do the same with SPC and TAB (keep in mind that this is the same as C-i, so maybe not). The following is lifted from my personal setup:

(with-eval-after-load 'evil-maps
  (define-key evil-motion-state-map (kbd "SPC") nil)
  (define-key evil-motion-state-map (kbd "RET") nil)
  (define-key evil-motion-state-map (kbd "TAB") nil))

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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