emacs交互式python shell不显示任何反馈
在我的终端外壳中,如果我只是计算,例如,emacs交互式python shell不显示任何反馈,python,emacs,Python,Emacs,在我的终端外壳中,如果我只是计算,例如,3+3,我得到 Python 3.6.1 (default, May 21 2017, 04:38:38) [GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.42)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> 3+3 6 >>> 但是,
3+3
,我得到
Python 3.6.1 (default, May 21 2017, 04:38:38)
[GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.42)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 3+3
6
>>>
但是,使用emacs的交互式shell,并且在使用pythonshell发送行
或pythonshell发送区域
评估代码时,我没有收到任何关于正在执行的代码的反馈(当然,除非涉及到一些打印
)
我在.emacs
中的相关配置如下:
(setq python-shell-interpreter "/opt/local/bin/python3.6"
python-shell-interpreter-args "-i")
(add-hook 'python-mode-hook 'anaconda-mode)
我不确定它是否相关,但即使我安装了readline
(如图所示),我也会收到以下警告:
Warning (python): Your ‘python-shell-interpreter’ doesn’t seem to support readline, yet ‘python-shell-completion-native’ was t and "python3.6" is not part of the ‘python-shell-completion-native-disabled-interpreters’ list. Native completions have been disabled locally.
我希望看到一些关于我执行的代码的反馈。有什么想法吗?我使用以下绑定到C-C-C的命令。如果一行不是以YMMV开头,那么发送打印语句只是一个简单的技巧
;; send current line, with prefix print result
(defun python--send-line (arg)
(interactive "P")
(if (not arg)
(python-shell-send-region (line-beginning-position) (line-end-position))
(save-excursion
(beginning-of-line)
(if (looking-at-p "\\s-*print")
(python-shell-send-region (line-beginning-position)
(line-end-position))
(python-shell-send-string
(concat "print(" (buffer-substring (line-beginning-position)
(line-end-position))
")")))))
(display-buffer (process-buffer (python-shell-get-process))))