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 [M-left]  'windmove-left)
(global-set-key [M-right] 'windmove-right)
(global-set-key [M-up]    'windmove-up)
(global-set-key [M-down]  'windmove-down)

;; show or hide window
(global-set-key [C-f1] 'ecb-hide-ecb-windows)
(global-set-key [C-f2] '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),比较易用。但是还未试用。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值