python - 在 Emacs 中更改 python 函数参数格式

标签 python emacs python-mode

我有办法改变函数参数的 python 模式缩进,所以而不是

urlpattrens = patterns('',
                       view,
                       name='view')

按回车键后,格式将如下:

urlpattrens = patterns('',
    view,
    name='view')

最佳答案

即将发布 python-mode.el 6.1.2 后,缩进样式的引入就摆在桌面上。

参见https://bugs.launchpad.net/python-mode/+bug/1197521

考虑在那里添加您的请求。

目前,您可以安装一个宏来纠正第一行“ View ”的缩进 - 之后应该尊重该缩进。

对于任何想破解缩进机的人:这里有一些指示入口点的伪代码:

+++ python-mode.el  2013-08-16 13:47:45.059486451 +0200
@@ -10859,7 +10859,10 @@
                            ((< (current-indentation) (current-column))
                             (+ (current-indentation) py-indent-offset))
                            (t (py-fetch-previous-indent orig)))
-                        (cond ((looking-at "\\s([ \t]*$")
+                        (cond (
+                               NEW_VAR_SET
+
+                               (looking-at "\\s([ \t]*$")
                                (py-empty-arglist-indent nesting py-indent-offset indent-offset))
                               ((looking-at "\\s([ \t]*\\([^ \t]+.*\\)$")
                                (goto-char (match-beginning 1))

关于python - 在 Emacs 中更改 python 函数参数格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18271621/

相关文章:

python - 为什么添加 : to any out of range index on a list slice not return out of range?

javascript - 如何根据 Odoo12 中的字段值更改列的颜色?

python - Twisted 中是否有用于 .tac 文件的 Emacs 模式?

Vim pymode : meaning of <C-c> key combination

python - Emacs python 模式 : Keyboard shortcuts for pdb step-by-step debugging

python - 在 Python 中迭代 URL 列表 - bs4

python - 转换列表

javascript - Emacs 中的 Node REPL 打印我的输入

emacs - 终端上的 Makefile

emacs - 在 3 窗口设置中调用 ipython 编译时,如何强制 emacs 使用底部窗口而不是底部窗口