我知道许多人都提出过这类问题, 但我读了很多类似的帖子,但仍然不知道 该怎么办。所以这是.emacs中的elisp代码:
;; send line to python console
(require 'python-mode)
(defun py-execute-line-down ()
"execute python line and move cursor down"
(progn
(py-execute-line)
(evil-next-line)))
(add-hook 'python-mode-hook
(lambda () (define-key python-mode-map (kbd "C-c C-j") 'py-execute-line-down)))
我还尝试将(interactive)
添加到函数中,但它不起作用。
答案 0 :(得分:0)
为了保留这里的记录,这似乎可以解决问题,但不确定它是否是最佳的:
;; send line to python console
(require 'python-mode)
(defun py-execute-line-down ()
"execute python line and move cursor down"
(interactive)
(py-execute-line)
(evil-next-line 1))
(defun kaiyin-pykeys ()
"python mode custome keys"
(local-set-key (kbd "C-c j") 'py-execute-line-down)
)
(add-hook 'python-mode-hook 'kaiyin-pykeys)
根据Dan的建议,我将上述内容改为:
;; send line to python console
(require 'python-mode)
(defun py-execute-line-down ()
"execute python line and move cursor down"
(interactive)
(py-execute-line)
(forward-line 1))
(define-key python-mode-map (kbd "C-c j") 'py-execute-line-down)