Emacs org-mode python blocks have 5 space tabs, but I want 4 space tabs

ε祈祈猫儿з 提交于 2019-12-21 05:01:02

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!