emacs python ide_Emacs Python IDE win7 x64
安裝平臺 win7 x64 ,emacs 23.3.1
snippet工具,可自定義一些模板:
.emacs 配置如下
(add-to-list 'load-path "~/.emacs.d/yasnippet")
(require 'yasnippet) ;; not yasnippet-bundle
(yas/global-mode 1)
自動完成工具,其實只是一個前端工具。當然也可以用ropemacs 作為它補全的后端使用。
.emacs 配置如下:
(add-to-list 'load-path "~/.emacs.d/")
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "~/.emacs.d//ac-dict")
(ac-config-default)
安裝python-mode :
4.Rope and Ropemacs
Ropemacs非常棒的重構(gòu)工具,比如rename,move,extract method等等。還有非常好用的goto difinition(跳到定義),show documents(顯示文檔)、代碼補全等等。安裝Ropemacs前,必須先安裝rope和pymacs實際上還要安裝rope-mode。
rope的安裝方法:
python setup.py install
pymacs的win上安裝方法:
python pppp -C ppppconfig.py pppp.rst.in pymacs.el.in \ pymacs.rst.in Pymacs contrib tests
python setup.py install
注意此處:我git pymacs到本地后無法install成功,后來別人給一個pymacs包,我放在git的pymacs里,重新執(zhí)行上面的安裝方法后,成功。pymacs包見本文尾
如果成功,則在python環(huán)境中輸入以下,不會報錯:
from Pymacs import lisp
.emacs中:
(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)
注意完成后,將下圖552行的Pymacs.pymacs 改成Pymacs
python setup.py install
.emacs中:
(require 'pymacs)
(pymacs-load "ropemacs" "rope-")
(setq ropemacs-enable-autoimport t)
注意:ropemacs時,先將ropemacs解壓縮,然后將剛剛安裝好的ropemode拷貝進去,再執(zhí)行安裝,否則會出錯。C:\Python27\Lib\site-packages\ropemacs
基本操作
rope-code-assist, M-/
Code completionrope-rename, C-c r r
Rename a variable, function, etc.
5.程序調(diào)試
在Emacs中,通過M-x pdb可調(diào)出pdb對python代碼進行調(diào)試。但是發(fā)現(xiàn)在Windows系統(tǒng)中,總進入不了調(diào)試模式。主要原因有:
1. windows中,找不到pdb.py位置。需自己制定pdb的路徑。可以通過下面的方法設置pdb的路徑:
;; pdb setup, note the python version
(setq pdb-path 'c:/python25/Lib/pdb.py
gud-pdb-command-name (symbol-name pdb-path))
(defadvice pdb (before gud-query-cmdline activate)
"Provide a better default command line when called interactively."
(interactive
(list (gud-query-cmdline pdb-path
(file-name-nondirectory buffer-file-name)))))
2. windows中,調(diào)用pdb時,未使用python -i 參數(shù)。
針對上面兩個問題,我的解決辦法是,不設置pdb具體路徑,M-x pdb 回車后,出現(xiàn)下面命令:
Run pdb (like this): pdb
然后手動修改一下:
Run pdb (like this): python -i -m pdb test.py
6.代碼檢查
基本上都是flymake+pyflakes 或者 flymake +pylint模式,我選擇了前者。并安裝了pep8
flymake是emacs自帶的,下載pep8 安裝好后,按下面配置好即可:
c-c c-w是執(zhí)行命令!
注意pyflakes 和pep8 都是在cmd中執(zhí)行命令的。
;pycheck grammer ; indent something
(add-to-list 'load-path "~/.emacs.d/")
(add-hook 'find-file-hook 'flymake-find-file-hook)
(when (load "flymake" t)
(defun flymake-pyflakes-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
(list "pychecker" (list local-file))))
(add-to-list 'flymake-allowed-file-name-masks
'("\\.py\\'" flymake-pyflakes-init)))
(load-library "flymake-cursor")
;(global-set-key [f10] 'flymake-goto-prev-error)
;(global-set-key [f11] 'flymake-goto-next-error)
(setq python-check-command "pyflakes")
然后創(chuàng)建一個pychecker.bat的文檔 丟到python里面,我的目錄是c:\python27
python C:\Python27\runpyflakes.py %*
pep8 --ignore=E221,E701,E202 --repeat %*
再在該目錄創(chuàng)建一個runpyflakes.py的程序
from pyflakes.scripts.pyflakes
import mainmain()
效果如下:
7.文檔幫助
我還是喜歡firefox直接上官方文檔庫查找。
emacs wiki 也給出了sphinx后格式的文檔下載,可以直接在emacs info里查看幫助。
具體鏈接請見本文末尾處效果可以看最后一個鏈接。
8.段落注解:
Comment/Uncomment Region
If you have ‘transient-mark-mode’ on, you can just use ‘comment-dwim’:
select a region and hit ‘M-;’.
The DoWhatIMean means that it will comment or uncomment the regionas appropriate.
If youdo not have ‘transient-mark-mode’ on bydefault, you can hit C-SPC twice to activate it temporarily.
( doesn’t python-mode.el offer `py-comment-region? --CH )
You can also use “rectangles” with comment/uncomment region (among other things that you cando with rectangles).
See RectangleCommands or “(emacs) Rectangles”in the Emacs manual.
9.框架支持
10.測試
待完善,下面的link中含有。
主要參考了:
總結(jié)
以上是生活随笔為你收集整理的emacs python ide_Emacs Python IDE win7 x64的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 怎么鉴定U盘是否扩容?检测U盘伪劣产品的
- 下一篇: python3 selenium_Pyt