2017-03-26 5 views
1

emacs에서 comint 파생 된 모드에 대해 eval-print-last-sexp와 동일한 기능이 있습니까?Comint-Mode에 대해 eval-print-last-sexp와 같은 기능이 있습니까?

특히, 저는 python-mode (elpy 포함)를 사용하고 있습니다. 지역의 내용을 파이썬 프로세스에 보내고 파이썬 스크립트의 다음 줄에 결과를 인쇄하는 방법을 찾고 있습니다.

메시지 메시지에 결과를 인쇄해도 좋지만, eval-print-last-sexp의 동작이 선호됩니다.

저는 Emacs 25.1.1 및 elpy 1.13.0을 실행하고 있습니다.

답변

1

프로세스 출력을 리디렉션해야하므로 comint에서 파생 된 모드에 따라 달라집니다. 서로 다른 모드에는 열등한 프로세스와 상호 작용하는 다른 방법이 있습니다. 파이썬 모드는 이미 이것을 수행하는 함수 인 python-shell-send-string-no-output (다른 모드는 비슷한 기능을 가지고 있지만 검색해야합니다).

정확히 어떻게 당신이 파이썬에 대한 sexp를 정의하고 싶은지 잘 모르겠지만 여기에 eval-print-last-sexp과 같은 출력을 사용하여 현재 줄을 보내는 예제가 있습니다.

(defun python-eval-print-last-sexp() 
    "Print result of evaluating current line into current buffer." 
    (interactive) 
    (let ((res (python-shell-send-string-no-output 
       ;; modify to get a different sexp 
       (buffer-substring (line-beginning-position) 
           (line-end-position)))) 
     (standard-output (current-buffer))) 
    (when res 
     (terpri) 
     (princ res) 
     (terpri)))) 
+0

우수! 'python-shell-send-string-no-output'은 필자가 필요로하고 함수가 완벽하게 작동했습니다. – nslamberth