Emacs defadvice在python模式下的功能 [英] Emacs defadvice on python-mode function
问题描述
在python模式中,有一个名为py-execute-region的函数,它将高亮显示的代码区域发送到Python缓冲区进行评估。评估后,光标在Python缓冲区中,但我宁愿保留在脚本缓冲区中,因此我可以继续生成更多的代码。我写了一个简单的建议功能:
(defadvice py-execute-region
/ pre>
(py-execute-region-其他窗口激活)
执行后,将光标返回到脚本缓冲区
(other-window 1)
)
但这根本不做任何事情。我尝试过其他变体,如使用周围而不是之后;将变量设置为脚本缓冲区名称,然后弹出缓冲区到该缓冲区和类似的东西。没有成功!我想知道这个机制对于某人来说是显而易见的...谢谢!
解决方案在这种情况下,解决方案似乎是
(custom-set-variables
'(py-shell-switch-buffers-on-execute nil))
In python-mode, there is a function called py-execute-region which sends a highlighted region of code to the Python buffer for evaluation. After evaluation, the cursor is in the Python buffer, but I would prefer that it remain in the script buffer so I can continue producing more code. I wrote a simple advising function:
(defadvice py-execute-region (after py-execute-region-other-window activate) """ After execution, return cursor to script buffer """ (other-window 1) )
But this does not do anything at all. I've tried other variants like using 'around' rather than 'after'; setting a variable to the script buffer name and then pop-to-buffer to that buffer and stuff like that. No success! I wonder if the mechanics of this is obvious to someone... Thanks!
解决方案In this case the solution appears to be
(custom-set-variables '(py-shell-switch-buffers-on-execute nil))
这篇关于Emacs defadvice在python模式下的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!