程序运行的光标跳转小问题

Emacs:27.2 配置:无自定义 OS:w10 Pyhton:3.10

程序文件中c-c c-p后光标跳转到python buffer, 然后还要手动将光标跳转到程序文件c-c c-c 感觉有点小麻烦

咱一般把他当做普通buffer对待,使用C-xo(或自定义的按键)跳转

把下面代码加到你的配置文件就好了,不知道是不是你要的效果。

(with-eval-after-load 'python
  (define-key python-mode-map [remap run-python] (lambda ()
												   (interactive)
												   (execute-extended-command current-prefix-arg "run-python")
												   (other-window -1))))


这个λ可以改进一下:

(lambda ()
  (interactive)
  (call-interactively #'run-python)
  (other-window -1))

这样可以避免一个string和symbol的转换。这里current-prefix-arg是可以直接传进run-python的。

1 个赞