gacvd 发表于 2017-4-22 09:22:21

emacs python ide

  申明:本文章内容结合了踢开Eclisep&Aptana,Emacs变身强大IDE和Emacs中打造强大的Python
IDE两篇文章,主要为了记录配置过程!
  1, 添加load-path

(add-to-list 'load-path "~/.emacs.d/lisp/")
  

  2, 安装emacs, python
 

$sudo apt-get install emacs
$sudo apt-get install python
 




  
3,安装yasnippet


下载地址
解压后,将文件yasnippet.el,以及文件夹snippets分别复制到目录~/.emacs.d/lisp/,~/.emacs.d/lisp/yasnippet中
 

$cp yasnippet ~/.emacs.d/lisp/
$move snippets ~/.emacs.d/lisp/yasnippet/




配置~/.emacs,添加如下配置信息
 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;    yasnippet
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'yasnippet)
(yas/initialize)
(yas/load-directory "~/.emacs.d/lisp/yasnippet/snippets")
 

4,rope,pymacs,ropemode,ropemacs


rope下载地址,pymacs下载地址,ropemode下载地址,ropemacs下载地址
1>  解压并安装rope:
 
 

$sudo python setup.py install




 
安装成功后,将会在/usr/local/lib/python2.7/dist-packages 出现与rope相关得文件信息(python2.7为本机python版本号)

  2> 解压,安装,配置pymacs

$make install
$sudo python setup.py install

      
     配置~/.emacs,添加如下配置信息


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;    pymacs
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(autoload 'pymacs-apply "pymacs")
(autoload 'pymacs-call "pymacs")
(autoload 'pymacs-eval "pymacs" nil t)
(autoload 'pymacs-exec "pymacs" nil t)
(autoload 'pymacs-load "pymacs" nil t)
 







3> 解压并安装ropemode
 
 

$sudo python setup.py install






4>  解压,安装,配置ropemacs
 

$sudo python setup.py install

      
      配置~/.emacs,添加如下配置信息



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;    repomacs
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(pymacs-load "ropemacs" "rope-")
(setq ropemacs-enable-autoimport t







  5,auto-complete


下载地址
配置~/.emacs,添加如下配置信息



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;    auto-complete
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(add-to-list 'load-path "~/.emacs.d/lisp/auto-complete-1.3.1")
(require 'auto-complete)
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "~/.emacs.d/lisp/auto-complete-1.3.1/dict")
(ac-config-default)
(global-auto-complete-mode t)
;(setq-default ac-sources '(ac-source-words-in-same-mode-buffers))
(setq-default ac-sources '(ac-source-yasnippet
ac-source-semantic
ac-source-ropemacs
ac-source-imenu
ac-source-words-in-buffer
ac-source-dictionary
ac-source-abbrev
ac-source-words-in-buffer
ac-source-files-in-current-dir
ac-source-filename))
(add-hook 'emacs-lisp-mode-hook    (lambda () (add-to-list 'ac-sources 'ac-source-symbols)))
(add-hook 'auto-complete-mode-hook (lambda () (add-to-list 'ac-sources 'ac-source-filename)))
;;下面这句是从auto-complete-config.el中翻出来的
;;加上这句,在python中输入类的 . 就可以提示里面的方法了
(add-hook 'python-mode-hook      (lambda () (add-to-list 'ac-omni-completion-sources (cons "\\." '(ac-source-ropemacs)))))
(set-face-background 'ac-candidate-face "lightgray")
(set-face-underline 'ac-candidate-face "darkgray")
(set-face-background 'ac-selection-face "steelblue")
(setq ac-auto-start 2)
(setq ac-dwim t)
 
  6,pycomplete(pycomplete.py,pycomplete.el,python-mode.el)

  pycomplete.py下载地址,pycomplete.el下载地址,python-mode.el下载地址

  1> 将pycomplete.el,python-mode.el复制到~/.emacs.d/lisp/


2> 将pycomplete.py复制到 /usr/local/lib/python2.7/dist-packages/ 中

3>
配置~/.emacs,添加如下配置信息



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;pycomplete
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'pycomplete)
(setq auto-mode-alist (cons '("\\.py$" . python-mode) auto-mode-alist))
(setq interpreter-mode-alist(cons '("python2.7" . python-mode) interpreter-mode-alist))
(setq py-python-command "python2.7") ;;这是我指定pythyon版本
(autoload 'python-mode "python-mode" "Python editing mode." t)



  7,cedete


下载地址
配置~/.emacs,添加如下配置信息



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;      Cedet 1.0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(load-file "~/.emacs.d/lisp/cedet-1.0.1/common/cedet.el")
(global-ede-mode 1)                      ; Enable the Project management system
(semantic-load-enable-code-helpers)      ; Enable prototype help and smart completion
(global-srecode-minor-mode 1)            ; Enable template insertion menu



  8,ecb

  下载地址
  配置~/.emacs,添加如下配置信息
  


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;      ECB 2.40
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(add-to-list 'load-path "~/.emacs.d/lisp/ecb-2.40")
(require 'ecb)
(require 'ecb-autoloads)
;; 窗口间切换
(global-set-key 'windmove-left)
(global-set-key 'windmove-right)
(global-set-key     'windmove-up)
(global-set-key 'windmove-down)
;; show or hide window
(global-set-key 'ecb-hide-ecb-windows)
(global-set-key 'ecb-show-ecb-windows)
;; 使某一ecb窗口最大化
(global-set-key (kbd "C-c 1") 'ecb-maximize-window-directories)
(global-set-key (kbd "C-c 2") 'ecb-maximize-window-sources)
(global-set-key (kbd "C-c 3") 'ecb-maximize-window-methods)
(global-set-key (kbd "C-c 4") 'ecb-maximize-window-history)
;; 恢复原始窗口布局
(global-set-key (kbd "C-c 0") 'ecb-restore-default-window-sizes)
(custom-set-variables
;; custom-set-variables 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.
'(ecb-layout-window-sizes nil)
'(ecb-options-version "2.40"))
(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.
)
(setq ecb-auto-activate t)      ;;auto startup
(setq ecb-tip-of-the-day nil)   ;;turn off the tips



  
emacs-for-python:如此文所介绍,几乎把上面这些插件都集成起来了(除了pycomplete/cedet/ecb),比较易用。但是还未试用。
页: [1]
查看完整版本: emacs python ide