为什么当我打开一个 .py 文件(emacs test.py)时,主模式没有自动设置为 python 模式?我的 .emacs 中处理 python 的一些部分是:
(setq
python-shell-interpreter "ipython"
python-shell-interpreter-args "--gui=wx --matplotlib=wx --colors=Linux"
)
(defun my-eval-after-load-python()
(setq initial-frame-alist '((top . 48) (left . 45) (width . 142) (height . 57)))
(split-window-horizontally (floor (* 0.49 (window-width))))
(other-window 1)
(run-python (python-shell-parse-command))
(python-shell-switch-to-shell)
(other-window 1)
)
(eval-after-load "python" '(my-eval-after-load-python))
左侧窗口应显示 ipython shell,右侧窗口应显示打开的文件 test.py。一切正常,但 test.py 处于基本模式,实际上暂存缓冲区设置为 python 模式。
编辑
好吧,问题只是我的 eval 函数处理窗口和缓冲区的方式,因此这段代码可以正确处理主要模式:
(defun my-eval-after-load-python()
(setq initial-frame-alist '((top . 48) (left . 45) (width . 142) (height . 57)))
(split-window-horizontally (floor (* 0.49 (window-width))))
(run-python (python-shell-parse-command))
)
(eval-after-load "python" '(my-eval-after-load-python))
左侧窗口显示 foo.py(python 模式),右侧窗口显示暂存缓冲区(文本模式)。还有消息缓冲区和 python shell 缓冲区(inferior-python-mode)。现在只需在左侧窗口打开inferior-python-mode,在右侧窗口打开foo.py。