1
votes

I've been using emacs for a little while now and am still trying to get the hang of elisp. In my init.el, I have the following lines:

(define-key evil-insert-state-map (kbd "RET") 'newline-and-indent)
(add-hook 'org-mode-hook (lambda () (define-key evil-insert-state-map (kbd "RET") 'newline)))

The intended effect of these two lines of elisp is to disable automatic indentation in org-mode only, but keep automatic indentation for every other mode. However, while this code does disable automatic indentation for org-mode, it has the unintended effect of disabling it for everything else as well. Does anyone know of a way to achieve the desired effect?

1

1 Answers

1
votes

You're looking for evil-define-key:

(evil-define-key 'insert org-mode-map (kbd "RET") 'newline)

This will define return to call newline in insert state only in org-mode. What your hook was doing was redefining the global insert state map every time you opened an org buffer.