今後の作業効率向上のために、.emacsをいじってみた。
ロードパスを通す
ロードパスとは、設定ファイルまでのパスである。
これを通し、elispファイルを読み込めるようにする。
ここでは、~/.emacs.dにelispというフォルダを作成し、そこに置くようにしている。
;; ローカルパスを設定 (setq load-path (cons "~/.emacs.d/elisp" load-path))
行番号の表示
まず、linum.elをロードパスに追加。
そして、.emacsに以下を記述。
;; 行番号の表示 (require 'linum) (global-linum-mode t) (setq linum-format "%3d ")
YaTeX
YaTexとは、Emacs上でLaTeXファイル作成を支援する統合環境。
これを入れようとしたことが、この様々なカスタマイズの始まりである。
まず、Yet Another LaTeX mode for Emacs. からYaTeX(最新版は1.74)をダウンロードし、適当なフォルダに追加(ここでは~/Proglam)。
そして、.emacsに以下を記述。
(setq load-path (cons "~/Program/yatex1.74" load-path)) (autoload 'yatex-mode "yatex" "Yet Another LaTeX mode" t) ;; YaTeX-mode (setq auto-mode-alist (cons (cons "\\.tex$" 'yatex-mode) auto-mode-alist)) (setq dvi2-command "xdvi" tex-command "platex" dviprint-command-format "dvips %s | lpr" YaTeX-kanji-code 3) ;; YaHtml-mode (setq auto-mode-alist (cons (cons "\\.html$" 'yahtml-mode) auto-mode-alist)) (autoload 'yahtml-mode "yahtml" "Yet Another HTML mode" t) (setq yahtml-www-browser "netscape") (setq mac-option-modifier 'meta) (setq indent-tabs-mode nil)
とりあえず補完機能がかなり便利。
しかも
\end{document}
と直接入力しようとすると、
\end{今度からはちゃんと ^C b を使いましょう}
って表示されるw 嫌でも覚えられそうだな。
Python
以下は、Python開発環境に限定した設定である。
python-mode
これは必須かな?
python-mode.el project files : python-mode.el からダウンロードし、.emacsに以下を記述。
;; python-mode (autoload 'python-mode "python-mode" "Python Mode." t) (add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode)) (add-to-list 'interpreter-mode-alist '("python" . python-mode))
iPython
C-c ! でpythonではなくipythonが起動される。
ipython.elからダウンロードし、.emacsに以下を記述。
;; ipython (setq ipython-command "/opt/local/bin/ipython2.5") (require 'ipython)
auto-complete
auto-completeは、入力中に補完候補を自動的に表示してくれる。
auto-complete.el をロードパスに追加し、.emacsに以下を記述。
(require 'auto-complete) (global-auto-complete-mode t)
pymacs
pymacsは、elispとpythonの双方向通信が可能になるツール。
[pymacs.progiciels-bpi.ca/index.html:title] からダウンロード(最新版は0.24)し、.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) (eval-after-load "pymacs" '(add-to-list 'pymacs-load-path "~/app/emacs/pymacs-elisp"))
他にはpysmellというものもあるが、補完しすぎて逆に使いにくいようなので入れていない。
こんな感じ。 Python環境構築はかなりめんどくさかった。
以下のページが参考になった。
Blog not found
Python+iPython+Emacsの設定 (Mac) - /Users/mizchi/workplace/
ipython.elも試してみた - 牌語備忘録 - pygo
最後に.emacsをあげておく。
1 ;; -------------------------------------------------- 2 ;; 一般設定 3 ;; -------------------------------------------------- 4 ;; ローカルパスを設定 5 (setq load-path (cons "~/.emacs.d/elisp" load-path)) 6 ;; 自動バックアップを抑制 7 (setq backup-inhibited t) 8 ;; オートセーブファイルを自動削除 9 (setq delete-auto-save-files t) 10 ;; インデントTAB文字を使わない(空白文字を使う) 11 (setq-default indent-tabs-mode nil) 12 ;; C-kで改行文字も削除 13 (setq kill-whole-line t) 14 ;; iswitchbを使う(C-xbによるバッファ選択が進化) 15 (iswitchb-mode 1) 16 ;; iswitchbの際に無視するバッファリスト 17 (setq iswitchb-buffer-ignore (append iswitchb-buffer-ignore '("*Messages*" "*scratch*" "*Completions*" "*Kill Ring*"))) 18 ;; 保存時に自動で行末にある無駄な空白を削除 19 (add-hook 'before-save-hook 'delete-trailing-whitespace) 20 ;; C-hでBackspace 21 (global-set-key "\C-h" 'delete-backward-char) 22 ;; C-dでPageUp 23 (global-set-key "\C-d" 'scroll-down) 24 ;; C-aで行の本当に先頭ではなく,行の非空白文字の先頭へ 25 (defun back-to-indentation-or-beginning () 26 (interactive) 27 (if (= (point) (save-excursion (back-to-indentation) (point))) 28 (beginning-of-line) (back-to-indentation))) 29 (global-set-key "\C-a" 'back-to-indentation-or-beginning) 30 ;; C-xkで現在バッファを削除 31 (global-set-key "\C-xk" 'kill-this-buffer) 32 ;; C-zでundo 33 (define-key global-map "\C-z" 'undo) 34 ;; 色の設定 35 (if (null window-system) 36 (progn 37 (set-face-foreground 'highlight "yellow") 38 (set-face-background 'highlight "unspecified-bg") 39 (set-face-foreground 'isearch "unspecified-bg") 40 (set-face-background 'isearch "cyan") 41 (set-face-foreground 'isearch-lazy-highlight-face "black") 42 (set-face-background 'isearch-lazy-highlight-face "gray") 43 ;;(set-face-foreground 'minibuffer-prompt "green") 44 (set-face-foreground 'font-lock-string-face "yellow") 45 (set-face-foreground 'font-lock-variable-name-face "blue") 46 (set-face-bold-p 'font-lock-variable-name-face t) 47 (set-face-foreground 'font-lock-keyword-face "cyan") 48 (set-face-foreground 'font-lock-function-name-face "green") 49 (setq hl-line-face 'underline) 50 (set-face-bold-p 'font-lock-keyword-face nil)) 51 ) 52 (set-face-foreground 'font-lock-comment-face "red") 53 54 ;; 行番号の表示 55 (require 'linum) 56 (global-linum-mode t) 57 (setq linum-format "%3d ") 58 59 ;; -------------------------------------------------- 60 ;; YaTeXの設定 61 ;; -------------------------------------------------- 62 63 (setq load-path (cons "~/Program/yatex1.74" load-path)) 64 (autoload 'yatex-mode "yatex" "Yet Another LaTeX mode" t) 65 66 ;; YaTeX-mode 67 (setq auto-mode-alist 68 (cons (cons "\\.tex$" 'yatex-mode) auto-mode-alist)) 69 (setq dvi2-command "xdvi" 70 tex-command "platex" 71 dviprint-command-format "dvips %s | lpr" 72 YaTeX-kanji-code 3) 73 74 ;; YaHtml-mode 75 (setq auto-mode-alist 76 (cons (cons "\\.html$" 'yahtml-mode) auto-mode-alist)) 77 (autoload 'yahtml-mode "yahtml" "Yet Another HTML mode" t) 78 (setq yahtml-www-browser "netscape") 79 80 (setq mac-option-modifier 'meta) 81 82 (setq indent-tabs-mode nil) 83 84 ;; -------------------------------------------------- 85 ;; Pythonの設定 86 ;; -------------------------------------------------- 87 88 ;; python-mode 89 (autoload 'python-mode "python-mode" "Python Mode." t) 90 (add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode)) 91 (add-to-list 'interpreter-mode-alist '("python" . python-mode)) 92 93 ;; iPython 94 (setq ipython-command "/opt/local/bin/ipython2.5") 95 (require 'ipython) 96 97 ;; auto-complete 98 (require 'auto-complete) 99 (global-auto-complete-mode t) 100 101 ;; Pymacs 102 (autoload 'pymacs-apply "pymacs") 103 (autoload 'pymacs-call "pymacs") 104 (autoload 'pymacs-eval "pymacs" nil t) 105 (autoload 'pymacs-exec "pymacs" nil t) 106 (autoload 'pymacs-load "pymacs" nil t) 107 (eval-after-load "pymacs" 108 '(add-to-list 'pymacs-load-path "~/app/emacs/pymacs-elisp"))
また、最近はこの本も読んでる。
Emacsテクニックバイブル ?作業効率をカイゼンする200の技?
- 作者: るびきち
- 出版社/メーカー: 技術評論社
- 発売日: 2010/08/03
- メディア: 単行本(ソフトカバー)
- 購入: 27人 クリック: 1,039回
- この商品を含むブログ (68件) を見る
emacsの便利な設定が沢山載ってるので、スキルを身に付けていってる。
快適なemacsライフを!