2014-02-19 2 views
6

제 목표는 이맥스 24를 파이썬 편집기로 사용하는 것입니다 (Matlab과 R 편집기가 있지만 내 질문에 관한 것은 아닙니다).파이썬 모드, ipython, (ipython.el) 버전/릴리스 및 init.el/.emacs.d 코드의 조합은 무엇입니까?

(나는 분명히 뭔가를 명시하지 않은 경우 제가 어떤 정보를 왼쪽으로 알고 또는 주시기 바랍니다.) 나는 그런 식으로 내 패키지 내 init.el 파일을 설정 할 수있었습니다

그 탭 완료, 올바른 강조 표시 및 Python을위한 미리보기를 가져올 수 있습니다. python-mode.el을 파이썬 모드로 사용하고 있습니다. 문제는 다음과 같습니다. 파이썬 쉘로 ipython을 사용하여 스크립트를 디버깅 할 때 탭 완성 기능을 사용하고 싶습니다.

  • 그러나 ipython (M-x ipython 사용)을 시작하면 탭 완료가 없습니다. 또한 "[1] in :"을 표시하지 않지만 "[1] out :"을 표시합니다.
  • 저는 이맥스에서 ipython을 기본 쉘로 만들고 싶습니다. 그러나이 시도는 실패했습니다 (예 : py-python-command에 C : \ PATH \ TO \ IPython.exe 설정).
  • 파이썬 스크립트를 C-C C-C를 사용하여 실행하려고하면 일반 파이썬을 사용하여 실행되며 사실 멈추는 위치에 멈 춥니 다 (ipdb.set_trace 사용). 그러나 IPython을 시작해야하는 또 다른 유형의 명령을 사용할 때 (예 : 내 전체 스크립트에 영역을 설정하고 py-execute-region-ipython을 실행하는 것처럼) IPython이 작동하지 않습니다. IPython 셸을 시작하거나 적어도 그렇게 보이지만 필자는 텍스트 편집기 (fyi : "Comint : run shell-compile"라는 미니 버퍼에 있음)처럼 셸에 입력 할 수 있습니다.

내 질문입니다 : 내가 이맥스에서 내 기본 쉘로 탭 완료와 함께 ipython 사용할 수 있도록해야 내 init.el 파일에 패키지 버전과 LISP 코드의 어떤 조합? 필요한 경우 일부 패키지를 다운 그레이드 할 용의가 있습니다.

추가 정보이 : 아마 그래서

내가 이해 파이썬 mode.el의 프로젝트 페이지에서 읽은 바로는

, 여전히이 패키지의 최신 버전 IPython에 대한 몇 가지 버그가 있음 이전 버전을 사용하는 데 필요합니다. 저는 솔루션을 찾기 위해 많은 검색을 해왔고 저에게 적합한 솔루션을 찾을 수 없었습니다.

내가

내 init.엘 (파이썬 물건 하단에) 다음과 같습니다 ipython 탭 완성을 수행하지 않는 보통 때

;; Requisites: Emacs >= 24 
(require 'package) 
(package-initialize) 

(add-to-list 'package-archives 
      '("melpa" . "http://melpa.milkbox.net/packages/")) 
(add-to-list 'package-archives 
      '("marmalade" . "http://marmalade-repo.org/packages/") t) 

(package-refresh-contents) 

(defun install-if-needed (package) 
    (unless (package-installed-p package) 
    (package-install package))) 

;; make more packages available with the package installer --> 
;; removed python mode since the version I got had errors 
(setq to-install 
     '(
;python-mode 
magit yasnippet jedi auto-complete autopair find-file-in-repository flycheck)) 

(mapc 'install-if-needed to-install) 


;;------------R STUFF----------- 

(add-to-list 'load-path "C:\\emacs-24.3\\site-lisp\\ess-13.09-1") 
(setq ess-use-auto-complete t) 
(load "ess-site") 

;;------------MatLab STUFF----------- 
; add folder of matlab-mode.el 
(add-to-list 'load-path "C:\\Users\\Rob Ter Horst\\AppData\\Roaming\\.emacs.d\\elpa\\matlab-mode-20130829.142") 
(load-library "matlab-load") 

(matlab-cedet-setup) 


(setq matlab-show-mlint-warnings t) 
(add-hook 'matlab-mode-hook 'auto-complete-mode) 
(add-hook 'matlab-mode-hook 'mlint-minor-mode) 
;;------------GENERAL STUFF----------- 

; Ido mode: Ido-powered versions of code. Most ido commands are named ido-xxxxx 
; so find-file becomes ido-find-file, and so on. 
(setq ido-enable-flex-matching t) 
(setq ido-everywhere t) 
(ido-mode t) 
(global-linum-mode t) 
;Use y or n always instead of yes/no 
(defalias 'yes-or-no-p 'y-or-n-p) 

;; -------------------- extra nice things Andrea Crotti-------------------- 
;; use shift to move around windows 
(windmove-default-keybindings 'shift) 
(show-paren-mode t) 
; Turn beep off 
(setq visible-bell nil) 
(custom-set-variables 
'(ansi-color-names-vector ["#242424" "#e5786d" "#95e454" "#cae682" "#8ac6f2" "#333366" "#ccaa8f" "#f6f3e8"]) 
'(custom-enabled-themes (quote (wheatgrass)))) 
(custom-set-faces 
;; custom-set-faces was added by Custom. 
;; If you edit it by hand, you could mess it up, so be careful. 
;; Your init file should contain only one such instance. 
;; If there is more than one, they won't work right. 
) 
(put 'downcase-region 'disabled nil) 

;;------------PYTHON STUFF----------- 
;(require 'magit) 
;(global-set-key "\C-xg" 'magit-status) 

(require 'auto-complete) 
(require 'autopair) 
(require 'yasnippet) 
(require 'jedi) 

;yasnipped settings 
(setq yas-snippet-dirs 
     '("C:\\Users\\Rob Ter Horst\\AppData\\Roaming\\.emacs.d\\elpa\\yasnippet-20140106.1009\\snippets")) 
(add-to-list 'load-path "C:\\Users\\Rob Ter Horst\\AppData\\Roaming\\.emacs.d\\elpa\\yasnippet-20140106.1009") 

(global-set-key [f7] 'find-file-in-repository) 

; auto-complete mode extra settings 
(setq 
ac-auto-start 2 
ac-override-local-map nil 
ac-use-menu-map t 
ac-candidate-limit 20) 

;; ;; Python mode settings 
(setq py-install-directory "C:\\Users\\Rob Ter Horst\\AppData\\Roaming\\.emacs.d\\self_installed\\python-mode.el-6.1.3") 
(add-to-list 'load-path py-install-directory) 
(add-to-list 'auto-mode-alist '("\\.py$" . python-mode)) 
(when (featurep 'python) (unload-feature 'python t)) 
(require 'python-mode) 

(setq py-electric-colon-active t) 
(add-hook 'python-mode-hook 'autopair-mode) 
(add-hook 'python-mode-hook 'yas-minor-mode) 
(add-hook 'python-mode-hook 'auto-complete-mode) 

;; ;; Jedi settings 

;; It's also required to run "pip install --user jedi" and "pip 
;; install --user epc" to get the Python side of the library work 
;; correctly. 
;; With the same interpreter you're using. 

;; if you need to change your python intepreter, if you want to change it 
;; (setq jedi:server-command 
;;  '("python2" "/home/andrea/.emacs.d/elpa/jedi-0.1.2/jediepcserver.py")) 

(add-hook 'python-mode-hook 
      (lambda() 
      (jedi:setup) 
      (jedi:ac-setup) 
      (local-set-key "\C-cd" 'jedi:show-doc) 
      (local-set-key (kbd "M-SPC") 'jedi:complete) 
      (local-set-key (kbd "M-.") 'jedi:goto-definition))) 

; ipython settings 

(setq py-python-command "C:\\Python27\\Scripts\\ipython.exe") 
(setq py-complete-function 'ipython-complete 
     py-shell-complete-function 'ipython-complete 
     py-shell-name "ipython" 
     py-which-bufname "IPython") 
;(require 'ipython) 

;With tab autocompletion in ipdb I get an error that might be solved by changing this var 
;the error: "variable binding depth exceeds max-specpdl-size" 
(setq max-specpdl-size 32000) 

; Try to add flycheck --> flycheck causes emacs to become incredibly slow on big script with 
; many style errors (as present in a lot of my older scripts, so I do not want to activate it 
; by default 
;(setq flycheck-highlighting-mode 'lines) 
;(add-hook 'python-mode-hook 'global-flycheck-mode) 
;(flycheck-select-checker 'python-flake8) 
;(provide 'init-flycheck) 

(yas-reload-all) 

답변

-1

내가 이맥스 (나는 VIM의 팬이에요)를 사용하지 않지만, 그것은 당신의 실종을 의미한다 파이썬 - mode.el 같은 IPython 쉘에서 https://pypi.python.org/pypi/readline/6.2.2

+0

왜 이것이 투표에 실패 했습니까? 나는 이것이 특정 쟁점이 아니었을지도 모르지만 그 논평은 완전히 유효하며 주제에 관한 것입니다. 나는 & readline을 설치하기 전에이 문제를 겪어 보았다. – user590028

+0

나는 다운 투표하지는 않았지만 내 인상 (언급하지는 않았지만)은 이맥스 외부의 ipython에서 Rubbert *가 TAB 완성을했다는 것인데,이 경우 응답은 아마도 주제가 아니다. 그것은 내 가정 일뿐입니다. – phils

1

의 readline 모듈은 TAB 통화 py-indent-line 제공합니다. 그런 식으로 가능한 들여 쓰기는 스크립트 버퍼 에서처럼 작동합니다. 완료는 M-TAB입니다. 해당 키를 다시 정의 할 수 있습니다.

3

Emacs24에서는 기본적으로 on github을 시작한 python.el (python-mode.el 아님)을 사용합니다.

  1. 내가 python-shell-switch-to-shell 또는 C-c C-p로 ipython 시작할 때 (파이썬 메뉴 -> 인터프리터를 시작), 내가 ipython 얻을. 탭 완성.

  2. ipython은 (내 init 파일 참조) 기본 파이썬 인터프리터입니다

  3. 나는 그것 (메뉴에서 사용 가능한 명령) 파일 또는 선택 영역을 보낼 수있는 ipython 쉘을 시작

    하고, 올바르게 평가됩니다. 당신은 파이썬 쉘에있을 때

는 보조 노트로서, 당신은 jedi:setup과 제다이 자동 완성을 시작할 수 있습니다. 그것은 매개 변수 도움말 및 의사와 좋은 팝업을 제공하고, 도트 (3 문자 후) 대신에 그것을 발사하도록 선택할 수 있습니다. IPython auto-completion emacs24 doesn't work을 참조하십시오. 그것은 ipython을 대체하기보다는 보완적인 것으로 볼 수 있습니다.
;; trying ipython tab completion: that works :) 
(setq 
python-shell-interpreter "ipython" 
python-shell-interpreter-args "" 
python-shell-prompt-regexp "In \\[[0-9]+\\]: " 
python-shell-prompt-output-regexp "Out\\[[0-9]+\\]: " 
python-shell-completion-setup-code "from IPython.core.completerlib import module_completion" 
    python-shell-completion-module-string-code "';'.join(module_completion('''%s'''))\n" 
    python-shell-completion-string-code "';'.join(get_ipython().Completer.all_completions('''%s'''))\n" 
    ) 

이 도움이 http://www.emacswiki.org/emacs/PythonProgrammingInEmacs#toc5

희망에서 촬영 : 내 설정에 따라

.