我一直在使用emacs一段时间,但不太熟悉lisp编程。几天之后,我开始在emacs上编写Python代码。我发现Python模式非常有用,我想进一步探索它。我在互联网上发现了一些emacs的嘴唇功能,用它们来使用户界面友好。我试图实现以下操作在emacs中使用python-mode切换缓冲区设置?
我通常用2个垂直窗口启动emacs,一个使用python source,另一个使用shell。我应该能够做到使用键盘绑定以下缓冲区(工作)之间
- 开关
- 执行区域(工作),但替换外壳缓冲区源缓冲区。我想在原始的shell缓冲区中执行选定的区域。
- 执行一行(工作) 但与上面相同的问题。当我先说,该行应该在python shell中执行而不需要替换任何缓冲区。所以复制该行,切换到python shell,执行行,切换回python源缓冲区。
我无法实现上面的切换操作。以下是我的代码从我的init.el文件
(defun goto-python-shell()
"Go to the python command window (start it if needed)"
(interactive)
(setq current-python-script-buffer (current-buffer))
(if (boundp 'current-python-shell-buffer)
(switch-to-buffer-other-window current-python-shell-buffer)
(py-shell))
(end-of-buffer)
)
(defun goto-python-source()
"switch back to source window"
(interactive)
(setq current-python-shell-buffer (current-buffer))
(switch-to-buffer-other-window current-python-script-buffer)
)
(defun py-execute-statement-and-step()
"select a statement, submit as a region and then step forward"
(interactive)
(beginning-of-line 1)
(let ((beg (point)))
(py-next-statement 1)
; if last statement.
(if (= (point) beg) (end-of-buffer))
; (switch-to-buffer-other-window current-python-shell-buffer)
(py-execute-region beg (point))
(switch-to-buffer-other-window current-python-script-buffer)
)
)
; some key bindings
(define-key python-mode-map (quote [f9]) 'py-execute-statement-and-step)
;(define-key python-mode-map (quote [f10]) `py-execute-region)
;py-shell-switch-buffers-on-execute
(define-key python-mode-map (quote [f10]) `py-shell-switch-buffers-on-execute)
(define-key python-mode-map (quote [f11]) `py-execute-buffer)
(define-key python-mode-map (quote [f12]) `goto-python-shell)
(define-key py-shell-map (quote [f12]) `goto-python-source)
请指教。
此外,由于我是新的python模式,有人可以分享使用python模式类似于上面的很好的初始化?
非常感谢您的帮助。
问候, AJ
希望如果有人知道答案..我只是想复制一个字符串,发送到其他缓冲区..做一些动作并返回到前一个缓冲区。 – Alok 2012-03-29 00:48:27