Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 332
Dave Avatar asked Oct 01 '22 20:10

Dave


1 Answers

(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)
like image 160
lawlist Avatar answered Oct 12 '22 07:10

lawlist