When using a C++ source block in org-mode, the indentation doesn't match that of the C++ major mode.
Viewing the source block in the org file:
Viewing the same code in a C++ mode buffer or using
In the major mode buffer, the indentation is correctly treated as spaces as per my configuration
(use-package cc-mode :config (defun my-c-mode-common-hook () (c-set-offset 'substatement-open 0) (setq c++-tab-always-indent t) (setq c-basic-offset 4) (setq c-indent-level 4) (setq tab-stop-list '(4 8 12 16 20 24 28 32 36 40 44 48 52 56 60)) (setq tab-width 4) (setq indent-tabs-mode t)) (add-hook 'c-mode-common-hook 'my-c-mode-common-hook))
whereas in the source block they are treated as 6 characters wide tabs. The way the indentation is treated simply switches between being a tab and being 4 spaces, when I switch between the
org-edit-special environment and the plain org file.
The relevant part of my configuration:
(setq org-src-preserve-indentation nil) (setq org-src-tab-acts-natively t) (setq org-edit-src-content-indentation 0)
(org-babel-do-load-languages 'org-babel-load-languages '((emacs-lisp . t) (C . t)))
I would be fine with the editing being wonky in the org file, but I would very much prefer the display of the code being correct. How could I accomplish this?