Futurismo
●
posts
●
categories
●
tags
●
search
●
about
Home » Posts
Emacs で Python 開発環境を構築
Emacs で Python 開発環境を構築
November 9, 2014 · 2 min · tsu-nera
Table of Contents
●
入力支援
●
python
●
python-mode
●
インデント設定
●
コードリーディング
●
helm-etags-plus
●
swoop
●
imenu
●
リファクタリング
●
anzu
●
iedit
●
Ropemacs
●
コーディング支援
●
jedi
●
ac-python
●
quickrun
●
静的解析
●
flymake
●
さいごに
●
Environment
●
Special Thanks
coursera で Python をつかう講座を2つとった.
●Computational Investing, Part I | coursera
●Survey of Music Technology | coursera
もちろん Emacs で開発環境をつくったので, 構築メモ.
入力支援#
python.el は公式, python-mode.el は Python コミュニティによって作成されたもの.
python#
Emacs にデフォルトではいっているやつ.
python-mode#
Python コミュニティによって作成されたもの.
●emacsmirror/python-mode
●python-mode.el in Launchpad
●Guide - Software - Emacs - python-mode
ショートカットがまとまっている.
●python-mode の便利なショートカットまとめ - まったりいんふぉまてぃくすめもらんだむ
インデント設定#
4で設定.
(add-hook 'python-mode-hook
'(lambda ()
(setq indent-tabs-mode nil)
(setq indent-level 4)
(setq python-indent 4)
(setq tab-width 4)))
コードリーディング#
helm-etags-plus#
ダグジャンプ. ctags を利用する.
そして, ctags を Emacs から利用するために,
最近は helm-etags-plus なるものを使っていたりする.
●jixiuf/helm-etags-plus
(require 'helm-etags+)
$ ctags -o TAGS *.py
swoop#
ctags はメソッドの定義にはジャンプできるけど,
変数の宣言にジャンプできない.
変数の宣言に飛びたいときは, swoop が最近は大のお気に入り.
●Emacs バッファ内高速ナビゲーション Swoop.el を作りました. - Web 学び
(require 'swoop)
(global-set-key (kbd "M-o") 'swoop)
(global-set-key (kbd "C-M-o") 'swoop-multi)
;; (global-set-key (kbd "M-o") 'swoop-pcre-regexp)
(global-set-key (kbd "C-S-o") 'swoop-back-to-last-position)
(define-key isearch-mode-map (kbd "M-o") 'swoop-from-isearch)
(define-key swoop-map (kbd "M-o") 'swoop-multi-from-swoop)
;; サイズ変更禁止
(setq swoop-font-size-change: nil)
imenu#
関数一覧を表示する.
そのままだと動かなかったので, いかのリンクを参考にした.
●Emacs の Python 開発環境構築メモ - Qiita
(semantic-mode 1)
(add-hook 'python-mode-hook
(lambda ()
(setq imenu-create-index-function 'python-imenu-create-index)))
リファクタリング#
主に名前変更の Elisp を導入.
参考リンク:
●What refactoring tools do you use for Python? - Stack Overflow
anzu#
インタラクティブな補完.
●syohex/emacs-anzu
iedit#
C-;から気軽に同じキーワードを編集できる.
●EmacsWiki: Iedit
Ropemacs#
Python 用のリファクタリングツール.
●ropemacs, rope in emacs
コーディング支援#
jedi#
Python のオムニ補完 (かしこい補完) をしてくれる.
●emacs-jedi の install - Qiita
ac-python#
auto-complete の python 強化版.
(require 'ac-python)
(add-to-list 'ac-modes 'python-2-mode)
quickrun#
quickrun を利用すれば, python コードを Emacs から実行可能.
●https://github.com/syohex/emacs-quickrun
システムの version が3で, Emacs からは2を利用したいときは,
以下のようにすれば実行コマンドをオーバライドできる.
(quickrun-add-command "python"
'((:command . "python2"))
:override t)
静的解析#
flymake#
flymake でエラーチェックを実施.
エラーチェックのエンジンに pyflakes を利用する.
$ sudo pip install pyflakes
Emacswiki を参考に設定.
●EmacsWiki: Python Programming In Emacs
(when (load "flymake" t)
(defun flymake-pyflakes-init ()
; Make sure it's not a remote buffer or flymake would not work
(when (not (subsetp (list (current-buffer)) (tramp-list-remote-buffers)))
(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 "pyflakes" (list local-file)))))
(add-to-list 'flymake-allowed-file-name-masks
'("\\.py\\'" flymake-pyflakes-init)))
さいごに#
Environment#
●ArchLinux
●Emacs 24.4
Special Thanks#
●EmacsWiki: Python Programming In Emacs
●Emacs as a Python IDE - Jessica Hamrick
●Configuring Emacs as a Python IDE - Pedro Kroger
●Emacs を Python 用 IDE としてセットアップ - uchikoshi22’s blog
●emacs の python 開発環境を整える - フリーフォーム フリークアウト
●Emacs の Python 開発環境を整えた
●Vim を最強の Python 開発環境にする 2 - Λ Lisue’s blog
●gabrielelanaro/emacs-for-python
●Python
●Emacs
システムトレードで億万長者になるぞ! coursera で Computational Investing Part I を受けた
Next »
コマンドラインから JUnit を使う方法
rismo
Powered by
Hugo &
PaperMod