I use Emacs 27.1 with org-mode and Evil. Currently my setup has these two indentation features:
1. Headings and content are _displayed_ indented, even though there is no leading whitespace on the line.
2. When editing a code block, leading whitespace is added to the new line and sometimes the entire code block has leading whitespace added to it.
I would like to keep the first feature (which I think is provided by `evil-auto-indent`). I would like to disable the second feature, which I could not figure out with much experimentation and googling.
Of specific interest is the `org-indent-mode` setting, which when set to `t` seems to be the feature that provides feature 1. But what is providing feature 2? I've tried playing with `org-adapt-indentation` but I'm not sure if I should be setting it as `(setq org-adapt-indentation nil)` or possibly `(org-adapt-indentation nil)` and no matter what I do I still get that leading whitespace added to code blocks.
**How do I preserve the virtual indention yet prevent the insertion of whitespace?**
The relevant parts of my `~/.emacs` file are:
; Open only a single window.
; https://stackoverflow.com/questions/29915133/how-can-i-open-the-files-only-in-a-specific-window-in-emacs
(setq inhibit-splash-screen t)
; Start maximized
(add-to-list 'default-frame-alist '(fullscreen . maximized))
; Vim Emulation
; https://emacs.amodernist.com/
(unless (package-installed-p 'evil)
(package-refresh-contents)
(package-install 'evil))
; Proper Tab-key behaviour in org-mode
; Must be set before enabling evil
; https://stackoverflow.com/questions/22878668/emacs-org-mode-evil-mode-tab-key-not-working
(setq evil-want-C-i-jump nil)
; Enable Evil
(require 'evil)
(evil-mode 1)
; Enable org-evil
; https://github.com/GuiltyDolphin/org-evil
(require 'org-evil)
; Have _ be considered part of a word in evil
; https://emacs.stackexchange.com/questions/9583/how-to-treat-underscore-as-part-of-the-word
; https://github.com/emacs-evil/evil/issues/721
(modify-syntax-entry ?_ "w")
; esc quits pretty much anything (like pending prompts in the minibuffer)
; https://modulitos.com/blog/lightning-intro-to-emacs-using-evil-mode-and-org-mode/
(define-key evil-normal-state-map [escape] 'keyboard-quit)
(define-key evil-visual-state-map [escape] 'keyboard-quit)
(define-key minibuffer-local-map [escape] 'minibuffer-keyboard-quit)
(define-key minibuffer-local-ns-map [escape] 'minibuffer-keyboard-quit)
(define-key minibuffer-local-completion-map [escape] 'minibuffer-keyboard-quit)
(define-key minibuffer-local-must-match-map [escape] 'minibuffer-keyboard-quit)
(define-key minibuffer-local-isearch-map [escape] 'minibuffer-keyboard-quit)
; Ctrl-C W Toggle word wrap
; https://emacs.stackexchange.com/questions/30171/how-do-i-toggle-soft-wrapped-lines-in-org-mode
(global-set-key (kbd "C-c w") 'toggle-truncate-lines)
; Run these options only in org-mode
; https://modulitos.com/blog/lightning-intro-to-emacs-using-evil-mode-and-org-mode/
(add-hook 'org-mode-hook (lambda()
; Reenable <sTAB
; https://github.com/syl20bnr/spacemacs/issues/11798
(require 'org-tempo)
; Indent org-mode files nicely
; https://modulitos.com/blog/lightning-intro-to-emacs-using-evil-mode-and-org-mode/
(local-set-key (kbd "C-c C-c") 'org-table-align)
(local-set-key (kbd "C-c C-f") 'org-table-calc-current-TBLFM)
(org-indent-mode t)
; Proper RTL in org-mode
; https://emacs.stackexchange.com/questions/71371/rtl-text-with-left-alignment-and-reversed-line-wrapping-in-org-mode
;(setq bidi-paragraph-direction 'right-to-left)
(setq bidi-paragraph-direction nil)
; Proper wrapping!
(visual-line-mode 1)
; Evil: Edit mode on new Org mode heading
; https://www.reddit.com/r/emacs/comments/uw01gz/evil_edit_mode_on_new_org_mode_heading/
; https://emacs.stackexchange.com/questions/71637/evil-edit-mode-on-new-org-mode-heading
(add-hook 'org-insert-heading-hook (apply-partially #'evil-insert 1))
) )
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(blink-cursor-mode nil)
'(package-selected-packages '(csv-mode org-evil dash)))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(default ((t (:family "Source Code Pro" :foundry "ADBO" :slant normal :weight normal :height 143 :width normal)))))