PythonMode
目次
概要
Emacs上でのPython開発環境を構築する手順を含めてpython-modeの使い方など。
2つのPython用モード
Python用モードとしては Emacs22から標準搭載の python.el と 昔からある python-mode.el の2種類が存在しています。
python-mode.el の方が機能としては高機能ですし、歴史が長いここともありサポートしている関連モードが多いです。
python.el はやや機能的に不足している部分も存在しますが、設定が比較的簡単で、Emacsが標準でサポートしているのが楽です。
http://www.emacswiki.org/emacs/PythonMode
python-mode.el
- https://launchpad.net/python-mode/
- http://bazaar.launchpad.net/~python-mode-devs/python-mode/python-mode/files
- http://svn.python.org/view/python/trunk/Misc/python-mode.el?view=log
python.el
Pymacs
tar xvfz Pymacs.tar.gz
cd Pymacs
sudo python setup.py install
環境によってはパスの設定とかが必要な場合があるけど割愛
.emacsに以下を設定
(require '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)
Emacs上での動作確認
M-x pymacs-eval RET
repr(2L**111) RET
"2596148429267413814265248164610048L"
M-x pymacs-load RET
os RET RET
M-: (os-getcwd) RET
以下の機能が利用できる。
pymacs-exec :: (pymacs-exec text)でtextをPythonの文として評価
pymacs-eval :: (pymacs-eval text)でtextをPythonの式として評価
pymacs-call :: (pymacs-call "function")とか(pymacs-call "function" "arg1" "arg2")みたいにしてpythonの関数を呼びだす
pymacs-apply :: callと似た感じ。引数のリストを必須とする。何も渡さない時はnillを書く。(pymacs-apply "function" nil)とか(pymacs-apply "function" ("arg1" "arg2"))な感じ
pymacs-load :: (pymacs-load module prefix)のような感じでモジュールのimportができる
ipython.el
;; ipython
(setq ipython-command "/usr/local/bin/ipython")
(require 'ipython)
http://www.emacswiki.org/emacs/anything-ipython.el
http://ipython.scipy.org/doc/manual/html/config/editors.html
http://ipython.scipy.org/moin/Cookbook/IPythonEmacs23
文法チェック
速度を求めるか、厳密さを求めるかで選択すると良い
gist: 302847 - Run pep8.py on Python source in Emacs.-GitHubpep8.py
gist: 302848 - Run pylint on Python source in Emacs.-GitHub:pylint
RonnyPfannschmidt / pytest-codecheckers / overview ---bitbucket.org
http://pypi.python.org/pypi/ZenCheck
補完
ropemacs
http://pypi.python.org/pypi/ropemacs
http://sourceforge.net/projects/rope/files/
pysmell
Django
http://code.djangoproject.com/wiki/Emacs
その他
- py-mode-ext.el
- py-complete.el
- pylint.el
mattharrison's pycoverage.el at master -GitHub
Emacs上でソース探険
etagsを利用する。
find . -name "*.[ch]" -print | etags -
find . -name "*.py" -print | etags -a -
とりあえずPythonのソースコードでこれやってTAGS作成。M-.で検索とかして読んでいる。
http://code.google.com/p/python-etags/source/browse/trunk/do_tags
参考
http://richardriley.net/projects/emacs/dotprogramming
Setup Perfect Python Environment In Emacs « The website of LeiChen
My Emacs Python environment « SaltyCraneBlog
http://gabrielelanaro.github.com/emacs-for-python/
Configuring Emacs as a Python IDE | PedroKroger
EmacsLispPythonLanguage CategoryPrograming CategoryEmacsCategoryPython
