Emacs org-mode python块有5个空格,但是我想要4个空格 [英] Emacs org-mode python blocks have 5 space tabs, but I want 4 space tabs

查看:306
本文介绍了Emacs org-mode python块有5个空格,但是我想要4个空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在组织模式文件中的源代码块内写入python代码;我正在使用emacs命令 Cc'


$ b在python模式中编辑
代码块$ b

示例:

 #+ begin_src python 
def函数(x):
hitting_tab_inserts_5_spaces = x * 2
如果x <0:
hitting_tab_inserts_5_spaces = -x
返回x

而且我现在有五个空格,而不是我想要的4个空格。



注意:我有viper(vim emulation)



配置中哪些参数影响组织模式文件中代码块中的制表?



如果我使用emacs编辑一个 .py 文件,我将获得4空格标签;这个5空格标签的东西只在组织模式下发生。

解决方案

 (defun my-tab-related-stuff()
(setq indent-tabs-mode t)
(setq tab-stop-list(number-sequence 4 200 4))
(setq tab-宽度4)
(setq indent-line-function'insert-tab)

(add-hook'org-mode-hook'my-tab-related-stuff)


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.

解决方案

(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)

这篇关于Emacs org-mode python块有5个空格,但是我想要4个空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆