reddit / emacs

src block indentation in org-mode

Domva · 2022-10-13 18:16
Hi there. I'm having trouble finding how to solve this problem. What I want is for src blocks to respect the indentation of the language. However, it does not get indented correctly. Below is a video that shows this: ​ https://reddit.com/link/y35q95/video/xk4nkwvu6mt91/player I couldn't find a solution to this, so maybe someone could help me out.
CulturMultur · 2022-10-13 19:22
Try `(setq org-src-tab-acts-natively t)`. Also check `org-edit-src-content-indentation` and `org-src-preserve-indentation` variables.
Domva · 2022-10-13 20:44
Thanks. It does not seem to work though. `org-src-tab-acts-natively` was already `t`. I did set it in the config just for good measure though, restarted - no fix. `org-edit-src-content-indentation` sets the initial indentation, however, it does not seem to affect the code that follows `:` in python. Not sure what setting `org-src-preserve-indentation`does though. After setting it, there's no indentation inside source blocks at all. <TAB> does not move the line by two (the default) characters further, but what I get is a message `Can't guess python-indent-offset, using default: 4`. When running `emacs -q` indentation works as expected. It could be some plugin/setting. I will try to find out what might be the case.
Domva · 2022-10-13 21:10
Pretty strange. I've found the culprit, but have no idea how it's related. Basically, I commented out the whole config and uncommented setting by setting. I narrowed it down to this seemingly unrelated keybinding: &#x200B; Now, the keybinding that is problematic is the last one - `C-i`. Commenting it fixes the problem and uncommenting it brings it back. I have no idea how this is related though. EDIT: forgot to add a screenshot. EDIT EDIT: I can't see the screenshot I uploaded, so I will copy and paste the code: ``` (general-define-key ;normal visual states :states '(normal visual) "s" 'evil-avy-goto-char-timer "S" 'evil-avy-goto-char-timer "K" 'lsp-ui-doc-toggle "C-s" 'evil-search-forward "C-S-s" 'evil-search-backward "C-i" 'evil-jump-forward ) ```
MitchellMarquez42 · 2022-10-13 22:33
C-i is the same as TAB in the terminal, that could be why
mkleehammer · 2022-10-15 01:22
I’ve found it a lot easier to use C-‘ to pop the source into a buffer with the right mode. For those not familiar with it: https://orgmode.org/manual/Editing-Source-Code.html