私はしばらくの間emacsを使用していますが、lispプログラミングにはあまり詳しくありません。私がemacsでPythonのコーディングを始めたのはほんの数日でした。python-modeは非常に便利であることがわかったので、さらに詳しく調べたいと思います。私はインターネット上でいくつかのemacslips関数を見つけ、インターフェースをユーザーフレンドリーにするためにそれらを少し弱めました。私は次の行動を達成しようとしています
私は通常、2つの垂直ウィンドウでemacsを開始します。1つはPythonソースで、もう1つはシェルです。キーボードバインディングを使用して次のことができるはずです
- バッファを切り替える(動作中)
- リージョンを実行します(動作中)が、ソースバッファーをシェルバッファーに置き換えます。元のシェルバッファで選択した領域を実行したい。
- 行を実行します(動作中)が、上記と同じ問題です。私が言うとき、行はバッファを置き換えずにPythonシェルで実行する必要があります。したがって、行をコピーし、Pythonシェルに切り替え、行を実行し、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-modeを初めて使用するので、誰かが上記のようなpython-modeを使用するための優れた初期化を共有できますか?
あなたの助けに感謝します。
よろしく、AJ