问题
I'm writing python code inside source blocks within an org-mode file; I'm editing
the code-block in a sub-buffer, in python mode using the emacs command C-c '
Example:
#+begin_src python
def function(x):
hitting_tab_inserts_5_spaces=x*2
if x<0:
hitting_tab_inserts_5_spaces=-x
return x
and I'm getting 5 space tabs everywhere, instead of the 4 space tabs that I want.
Note: I have viper (vim emulation) on.
Where in the configuration are the parameters that affect tabination inside codeblocks in org-mode files?
If I edit a .py
file using emacs, I do get 4-space tabs; this 5-space tab thing is only happening inside org-mode.
回答1:
(defun my-tab-related-stuff ()
(setq indent-tabs-mode t)
(setq tab-stop-list (number-sequence 4 200 4))
(setq tab-width 4)
(setq indent-line-function 'insert-tab))
(add-hook 'org-mode-hook 'my-tab-related-stuff)
来源:https://stackoverflow.com/questions/21150062/emacs-org-mode-python-blocks-have-5-space-tabs-but-i-want-4-space-tabs