[英]Emacs - Python Indent in parenthesis
My default python mode in emacs indents the following multiline code this way: 我在emacs中的默认python模式以这种方式缩进以下多行代码:
mydict = {
"a": 1,
"b": 2,
}
which is okay as of PEP8 从PEP8开始还可以
I' d rather use the following style: 我宁愿使用以下样式:
mydict = {
"a": 1,
"b": 2,
}
which is also ok with PEP8. PEP8也可以。
How do I tell emacs to indent the last parenthesis accordingly to the beginning of the previous line? 如何告诉emacs根据上一行的开头缩进最后一个括号?
Just install the latest python-mode.el (from https://launchpad.net/python-mode ). 只需安装最新的python-mode.el(来自https://launchpad.net/python-mode )。
In the latest version 6.1.4, the PEP8 "indent-alternatives when closing a list" is implemented (see release notes .) 在最新版本6.1.4中,实现了PEP8“关闭列表时的缩进替代”(请参阅发行说明 。)
In your case, you don't have to customize it, and just accept the default. 在您的情况下,您不必自定义它,而只需接受默认值即可。
By default, py-close-at-start-column-p
is nil
, which looks like: 默认情况下, py-close-at-start-column-p
为nil
,如下所示:
my_list = [
1, 2, 3,
4, 5, 6,
]
result = some_function_that_takes_arguments(
'a', 'b', 'c',
'd', 'e', 'f',
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.