gpt4 book ai didi

python - emacs 24 : How do I get back emacs-23 sexp behavior for python mode?

转载 作者:太空宇宙 更新时间:2023-11-03 16:59:03 27 4
gpt4 key购买 nike

我使用“--no-init-file”运行 emacs 23 和 24,以避免加载我的自定义设置。但后来我明确加载了我的旧版本 python-mode.el(版本 3.105,最后版权声明 1998 年),并看到了我将要描述的相同行为,所以我相信它是核心 emacs,而不是 python。

考虑以下代码(* 标记光标位置):

*def emacs_is_fun():
for x in range(3):
print(x)

将光标置于“def”开头的第 4 列。

在 emacs 23 中,运行 mark-sexp 选择“def”。

在 emacs 24 中,mark-sexp 选择整个代码块,直到最后打印语句。

这还不错。主要问题是这种常见用法:

    *very_long_var_name[very_long_expn] += long_function_call(long_arg_list, blah)

同样,光标位于该行可打印部分的开头,第 4 列。

在 emacs 23 中,mark-sexp 选择 very_long_var_name

在 emacs 24 中,mark-sexp 选择从第 4 列到末尾的整行。

我一直在使用Ctrl-alt-space alt-w来快速保存变量名称。(或者alt-2 ctrl-alt-space alt-w来保存引用表达式。)现在是走了。是emacs,所以这个肯定是可以定制的,但是我没找到实现新行为的地方(记住我正在使用 python 模式大约15岁)。我需要在 .emacs 文件中放入什么内容?

最佳答案

@Eric 有趣。感谢您在我的其他答案的评论中提供上下文。

我想你可能只是想要这个:

(add-hook 'python-mode-hook (lambda () (setqforward-sexp-function nil)))

来自 python-mode 内置 emacs 24 内的评论(我认为您可能会得到它)

At last but not least the specialized python-nav-forward-sexp allows easy navigation between code blocks. If you prefer cc-mode-like forward-sexp movement, setting forward-sexp-function to nil is enough...

这更接近我对 sexp 的看法,就像我在其他答案中提到的那样,但在 lisp 之外,sexp 似乎至少有些模棱两可。

关于python - emacs 24 : How do I get back emacs-23 sexp behavior for python mode?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35162556/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com