evil
evil copied to clipboard
Evil mode breaks TAB keybind in OrgMode on Emacs 28
Issue type
- Bug report
Environment
Emacs version: 28.1
Operating System: Arch Linux
Evil version: 1.14.0
Evil installation type: MELPA
Graphical/Terminal: Graphical
Tested in a make emacs
session (see CONTRIBUTING.md): yes
Reproduction steps
-
make emacs
- Open any Org mode file (or create a new file ending in ".org", add a few heading lines that begin with
*
and have some text on and under them -- see example at the bottom) - Hit Tab
Expected behavior
org-cycle
function is toggled, headings collapse and open as they are supposed to
Actual behavior
Nothing seems to happens.
The describe-key
function says TAB is bound to evil-jump-forward
, instead of what it usually is (a large block of text from org.el
)
As of Emacs 27.1, the same reproduction steps do not reproduce the bug. Tab still does org-cycle
, as expected.
Further notes
Disabling evil-mode is an immediate fix
Just running M-x evil-mode
makes the issue go away, so the problem is a conflict with evil.
Reinstall has an error
When I package-reinstall
evil from my regular session (outside of make
, with config), I see an error of the following:
Compiling file /home/nicholas/.emacs.d/elpa/evil-1.14.0/evil-ex.el at Sat Apr 16 12:55:17 2022
evil-ex.el:596:1: Error: Wrong number of arguments: (3 . 4), 2
Perhaps this is mucking something up?
Sample org file
Just copy these contents into sample.org
, if you aren't a big OrgMode user
* Hello
** Subheading one
I have text here
** Subheading two
Me too
*** Third level heading
Final text
Workaround
Add this to your .emacs
config:
(with-eval-after-load 'evil-maps (define-key evil-motion-state-map (kbd "TAB") nil))
Thank you @wasamasa at https://github.com/wasamasa/dotemacs/blob/master/init.org#keymap-hacking!
Add this to your
.emacs
config:(with-eval-after-load 'evil-maps (define-key evil-motion-state-map (kbd "TAB") nil))
Unfortunately this does not work for me - e.g. I cannot jump through org-mode tables in Emacs 28 using TAB. Is there any other kind of workaround?
No, it works perfectly fine:
cd ~/git/emacs-evil && make emacs
# press n to skip tests
# M-: (with-eval-after-load 'evil-maps (define-key evil-motion-state-map (kbd "TAB") nil))
# switch to an org buffer
# M-x org-mode
# F1 k TAB (it shows org-cycle)
Ask yourself instead what exactly is different in your init file to cause that divergence.
Ah, thanks! After finding that the TAB
key being bound to outline-cycle
rather than org-cycle
, I did some digging around for a while and found the outline-magic
package somewhere in my config file. In particular,
(define-key outline-minor-mode-map (kbd "<C-tab>") 'outline-cycle)
was in the use-package
config, and I'm guessing this might conflict with your fix, evil
, org-mode
and whatever happens in Emacs 28
. (This all seemed to work fine in 27.2, FWIW).
In fact, removing your fix as well as outline-magic
gives me the desired normal behavior (jumping between table cells, <s TAB
creating source blocks), so it's probably outline-magic
that was the cause of my problems. After removing both, TAB
is bound to
(evil-jump-forward &optional COUNT)
when in NORMAL mode, and (org-cycle &optional ARG)
when in INSERT mode, according to C-h k TAB
.
Hope this helps whoever else comes across this problem.
Thanks for your fix, and for looking into my response.
Closing since this is working as intended. Evil binds C-i
/TAB
just like Vim does and for those who don't need it, this workaround works fine.