.emacsの設定
プログラミング始めて秀丸使ってMicrosoft Visual Studio使ってEclipse使って。
提供されたり回りの人が使ってるエディタをその場その場でこだわりも少なくいろいろ使ってきたけどこのままじゃ自分が何をしたいのか分からなくなってきそうだったんでまずはEmacs(今回はWindows端末なのでMeadow)を使い始めることに。
価値感とかは人それぞれけどEmacsのキーバインドはコーディングスピードを確実にアップさせてくれる。キーボードから手を移動させずにコーディングからファイル管理やらその他もろもろの作業が行えるのはかなり嬉しい。最初は違和感だらけのキーバインドに悩むこともあったけど、慣れると実はUNIX系コンソールでのキーバインドとほぼ一緒なのでそっちの作業との併用時もストレスが無くなる。
シンプルイズベストな思想から外れてECBとか統合開発環境的なのも入れてかなり路線が外れて行ってそうけど、今時点での.emacsファイルの内容を以下にキロク。
;;;; -*- mode: emacs-lisp; coding: iso-2022-7bit -*- ;;;; ;;;; Copyright (C) 2001 The Meadow Team ;; Author: Koichiro Ohba <koichiro@meadowy.org> ;; Kyotaro HORIGUCHI <horiguti@meadowy.org> ;; Hideyuki SHIRAI <shirai@meadowy.org> ;; KOSEKI Yoshinori <kose@meadowy.org> ;; and The Meadow Team. ;; ;;; Mule-UCS の設定 ;; ;; ftp://ftp.m17n.org/pub/mule/Mule-UCS/ が オフィシャルサイトですが、 ;; ;; http://www.meadowy.org/~shirai/elisp/mule-ucs.tar.gz に既知のパッチ ;; ;; をすべて適用したものがおいてあります。 ;; ;; (set-language-environment) の前に設定します ;; (require 'jisx0213) ;;; 日本語環境設定 (set-language-environment "Japanese") ;;; IMEの設定 (mw32-ime-initialize) (setq default-input-method "MW32-IME") (setq-default mw32-ime-mode-line-state-indicator "[--]") (setq mw32-ime-mode-line-state-indicator-list '("[--]" "[あ]" "[--]")) (add-hook 'mw32-ime-on-hook (function (lambda () (set-cursor-height 2)))) (add-hook 'mw32-ime-off-hook (function (lambda () (set-cursor-height 4)))) ;; ;;; カーソルの設定 ;; ;; (set-cursor-type 'box) ; Meadow-1.10互換 (SKK等で色が変る設定) ;; ;; (set-cursor-type 'hairline-caret) ; 縦棒キャレット ;;; マウスカーソルを消す設定 (setq w32-hide-mouse-on-key t) (setq w32-hide-mouse-timeout 5000) ;;; font-lockの設定 (global-font-lock-mode t) (require 'font-lock) ;; ;;; TrueType フォント設定 ;; (w32-add-font ;; "private-fontset" ;; '((spec ;; ((:char-spec ascii :height 120) ;; strict ;; (w32-logfont "Courier New" 0 -13 400 0 nil nil nil 0 1 3 49)) ;; ((:char-spec ascii :height 120 :weight bold) ;; strict ;; (w32-logfont "Courier New" 0 -13 700 0 nil nil nil 0 1 3 49)) ;; ((:char-spec ascii :height 120 :slant italic) ;; strict ;; (w32-logfont "Courier New" 0 -13 400 0 t nil nil 0 1 3 49)) ;; ((:char-spec ascii :height 120 :weight bold :slant italic) ;; strict ;; (w32-logfont "Courier New" 0 -13 700 0 t nil nil 0 1 3 49)) ;; ((:char-spec japanese-jisx0208 :height 120) ;; strict ;; (w32-logfont "MS ゴシック" 0 -16 400 0 nil nil nil 128 1 3 49)) ;; ((:char-spec japanese-jisx0208 :height 120 :weight bold) ;; strict ;; (w32-logfont "MS ゴシック" 0 -16 700 0 nil nil nil 128 1 3 49) ;; ((spacing . -1))) ;; ((:char-spec japanese-jisx0208 :height 120 :slant italic) ;; strict ;; (w32-logfont "MS ゴシック" 0 -16 400 0 t nil nil 128 1 3 49)) ;; ((:char-spec japanese-jisx0208 :height 120 :weight bold :slant italic) ;; strict ;; (w32-logfont "MS ゴシック" 0 -16 700 0 t nil nil 128 1 3 49) ;; ((spacing . -1)))))) ;; (set-face-attribute 'variable-pitch nil :family "*") ;; ;;; BDF フォント設定 ;; ;; ;;; (方法その1) Netinstall パッケージを使う方法 ;; ;;; misc と intlfonts パッケージを入れます。 ;; ;;; .emacsの設定 ;; (setq bdf-use-intlfonts16 t) ;; (setq initial-frame-alist '((font . "intlfonts16"))) ;; ;; ;;; (方法その1') ;; ;;; intlfonts-file-16dot-alist の形式で bdf-fontset-alist を書き、 ;; ;;; 次を設定すれば良い。 ;; ;;; (require 'bdf) ;; ;;; (bdf-configure-fontset "bdf-fontset" bdf-fontset-alist) ;; ;;; 詳細は $MEADOW/pkginfo/auto-autoloads.el と $MEADOW/site-lisp/bdf.el を ;; ;;; 参照のこと。 ;; ;; ;;; (方法その2) ;; ;;; フォントの指定方法は次のサンプルを参考にする。 ;; ;;; normal, bold, italic, bold-itaric フォントを指定する必要あり。 ;; (setq bdf-font-directory "c:/Meadow/fonts/intlfonts/") ;; (w32-add-font "bdf-fontset" ;; `((spec ;; ;; ascii ;; ((:char-spec ascii :height any :weight normal :slant normal) ;; strict (bdf-font ,(expand-file-name "lt1-16-etl.bdf" bdf-font-directory))) ;; ((:char-spec ascii :height any :weight bold :slant normal) ;; strict (bdf-font ,(expand-file-name "lt1-16b-etl.bdf" bdf-font-directory))) ;; ((:char-spec ascii :height any :weight normal :slant any) ;; strict (bdf-font ,(expand-file-name "lt1-16i-etl.bdf" bdf-font-directory))) ;; ((:char-spec ascii :height any :weight bold :slant any) ;; strict (bdf-font ,(expand-file-name "lt1-16bi-etl.bdf" bdf-font-directory))) ;; ;; katakana-jisx0201 ;; ((:char-spec katakana-jisx0201 :height any :weight normal :slant normal) ;; strict (bdf-font ,(expand-file-name "8x16rk.bdf" bdf-font-directory)) ;; ((encoding . 1-byte-set-msb))) ;; ((:char-spec katakana-jisx0201 :height any :weight bold :slant normal) ;; strict (bdf-font ,(expand-file-name "8x16rk.bdf" bdf-font-directory)) ;; ((encoding . 1-byte-set-msb))) ;; ((:char-spec katakana-jisx0201 :height any :weight normal :slant any) ;; strict (bdf-font ,(expand-file-name "8x16rk.bdf" bdf-font-directory)) ;; ((encoding . 1-byte-set-msb))) ;; ((:char-spec katakana-jisx0201 :height any :weight bold :slant any) ;; strict (bdf-font ,(expand-file-name "8x16rk.bdf" bdf-font-directory)) ;; ((encoding . 1-byte-set-msb))) ;; ;; latin-jisx0201 ;; ((:char-spec latin-jisx0201 :height any :weight normal :slant normal) ;; strict (bdf-font ,(expand-file-name "8x16rk.bdf" bdf-font-directory))) ;; ((:char-spec latin-jisx0201 :height any :weight bold :slant normal) ;; strict (bdf-font ,(expand-file-name "8x16rk.bdf" bdf-font-directory))) ;; ((:char-spec latin-jisx0201 :height any :weight normal :slant any) ;; strict (bdf-font ,(expand-file-name "8x16rk.bdf" bdf-font-directory))) ;; ((:char-spec latin-jisx0201 :height any :weight bold :slant any) ;; strict (bdf-font ,(expand-file-name "8x16rk.bdf" bdf-font-directory))) ;; ;; japanese-jisx0208 ;; ((:char-spec japanese-jisx0208 :height any :weight normal :slant normal) ;; strict (bdf-font ,(expand-file-name "j90-16.bdf" bdf-font-directory))) ;; ((:char-spec japanese-jisx0208 :height any :weight bold :slant normal) ;; strict (bdf-font ,(expand-file-name "j90-16.bdf" bdf-font-directory))) ;; ((:char-spec japanese-jisx0208 :height any :weight normal :slant any) ;; strict (bdf-font ,(expand-file-name "j90-16.bdf" bdf-font-directory))) ;; ((:char-spec japanese-jisx0208 :height any :weight bold :slant any) ;; strict (bdf-font ,(expand-file-name "j90-16b.bdf" bdf-font-directory)))))) ;; 初期フレームの設定 ;; (setq default-frame-alist ;; (append (list '(foreground-color . "black") ;; '(background-color . "snow") ;; '(background-color . "gray") ;; '(border-color . "black") ;; '(mouse-color . "white") ;; '(cursor-color . "black") ;; ;; '(ime-font . (w32-logfont "MS ゴシック" ;; ;; 0 16 400 0 nil nil nil ;; ;; 128 1 3 49)) ; TrueType のみ ;; ;; '(font . "bdf-fontset") ; BDF ;; ;; '(font . "private-fontset"); TrueType ;; '(width . 80) ;; '(height . 40) ;; '(top . 100) ;; '(left . 100)) ;; default-frame-alist)) ;; ;;; shell の設定 ;; ;;; Cygwin の bash を使う場合 (setq explicit-shell-file-name "bash") (setq shell-file-name "sh") (setq shell-command-switch "-c") ;; ;;; Virtually UN*X!にある tcsh.exe を使う場合 ;; (setq explicit-shell-file-name "tcsh.exe") ;; (setq shell-file-name "tcsh.exe") ;; (setq shell-command-switch "-c") ;; ;;; WindowsNT に付属の CMD.EXE を使う場合。 ;; (setq explicit-shell-file-name "CMD.EXE") ;; (setq shell-file-name "CMD.EXE") ;; (setq shell-command-switch "\\/c") ;;; argument-editing の設定 (require 'mw32script) (mw32script-init) ;; ;;; browse-url の設定 ;; (global-set-key [S-mouse-2] 'browse-url-at-mouse) ;; ;;; 印刷の設定 ;; ;; この設定で M-x print-buffer RET などでの印刷ができるようになります ;; ;; ;; ;; notepad に与えるパラメータの形式の設定 ;; (define-process-argument-editing "notepad" ;; (lambda (x) (general-process-argument-editing-function x nil t))) ;; ;; (defun w32-print-region (start end ;; &optional lpr-prog delete-text buf display ;; &rest rest) ;; (interactive) ;; (let ((tmpfile (convert-standard-filename (buffer-name))) ;; (w32-start-process-show-window t) ;; ;; もし、dos 窓が見えていやな人は上記の `t' を `nil' にします ;; ;; ただし、`nil' にすると Meadow が固まる環境もあるかもしれません ;; (coding-system-for-write w32-system-coding-system)) ;; (while (string-match "[/\\]" tmpfile) ;; (setq tmpfile (replace-match "_" t nil tmpfile))) ;; (setq tmpfile (expand-file-name (concat "_" tmpfile "_") ;; temporary-file-directory)) ;; (write-region start end tmpfile nil 'nomsg) ;; (call-process "notepad" nil nil nil "/p" tmpfile) ;; (and (file-readable-p tmpfile) (file-writable-p tmpfile) ;; (delete-file tmpfile)))) ;; ;; (setq print-region-function 'w32-print-region) ;; ;;; fakecygpty の設定 ;; ;; この設定で cygwin の仮想端末を要求するプログラムを Meadow から ;; ;; 扱えるようになります ;; (setq mw32-process-wrapper-alist ;; '(("/\\(bash\\|tcsh\\|svn\\|ssh\\|gpg[esvk]?\\)\\.exe" . ;; (nil . ("fakecygpty.exe" . set-process-connection-type-pty))))) ;;; ;;; end of file ;;; ;; 追加設定 ;; ツールバーを消す (tool-bar-mode nil) ;; バッファ名をディレクトリ名に変更 (require 'uniquify) (setq uniquify-buffer-name-style 'post-forward-angle-brackets) ;; uniquify でバッファ名を変更しないものを正規表現で指定 (setq uniquify-ignore-buffers-re "*[^*]+*") ;; ファイル名が重複してない場合も常にディレクトリ名を表示するよう指定 (setq uniquify-min-dir-content 1) ;; デフォルトモード設定 (setq auto-mode-alist (cons '("\\.html?$" . html-mode) auto-mode-alist)) (setq auto-mode-alist (cons '("\\.tpl?$" . html-mode) auto-mode-alist)) ;; タブ幅を 4 に設定 (setq-default tab-width 4) ;; タブ幅の倍数を設定 (setq tab-stop-list '(4 8 12 16 20 24 28 32 36 40 44 48 52 56 60)) ;; タブではなくスペースを使う (setq-default indent-tabs-mode nil) ;; (setq indent-line-function 'indent-relative-maybe) ;; インデント幅を指定 (setq c-basic-offset 4) ;; (add-hook 'php-mode-user-hook ;; '(lambda () ;; (setq tab-width 4) ;; (setq indent-tabs-mode nil)) ;; ) ;; 自動セーブとバックアップファイルを無効にする ;; (setq make-backup-files nil) ;; (setq auto-save-default nil) ;;; スクロールバーを右側に表示する ;;(set-scroll-bar-mode 'right) ;; ---------------------------------------- ;; 行番号を表示 (wb-line-number.el) ;; (require 'wb-line-number) ;; (wb-line-number-toggle) ;; (custom-set-faces ;; '(wb-line-number-face ((t (:foreground "LightGrey")))) ;; '(wb-line-number-scroll-bar-face ;; ((t (:foreground "white" :background "LightBlue2"))))) ;; (setq truncate-partial-width-windows nil) ;; (set-scroll-bar-mode nil) ;;初回に表示させると番号の振りがおかしい。。 ;; (setq wb-line-number-scroll-bar t) ;; (global-set-key [f11] 'wb-line-number-toggle) ;; --------------------------------------- ;; 対応する括弧をハイライト表示 ;; (show-paren-mode) ;; (setq show-paren-style 'mixed) ;; (set-face-background 'show-paren-match-face "plum2") ;; (set-face-foreground 'show-paren-match-face "Blue") ;; --------------------------------------- ;; タブ, 全角スペース、改行直前の半角スペースを表示する ;; (when (require 'jaspace nil t) ;; (when (boundp 'jaspace-modes) ;; (setq jaspace-modes (append jaspace-modes ;; (list 'php-mode ;; 'yaml-mode ;; 'javascript-mode ;; 'ruby-mode ;; 'text-mode ;; 'fundamental-mode)))) ;; (when (boundp 'jaspace-alternate-jaspace-string) ;; (setq jaspace-alternate-jaspace-string "□")) ;; (when (boundp 'jaspace-highlight-tabs) ;; (setq jaspace-highlight-tabs ?^)) ;; (add-hook 'jaspace-mode-off-hook ;; (lambda() ;; (when (boundp 'show-trailing-whitespace) ;; (setq show-trailing-whitespace nil)))) ;; (add-hook 'jaspace-mode-hook ;; (lambda() ;; (progn ;; (when (boundp 'show-trailing-whitespace) ;; (setq show-trailing-whitespace t)) ;; (face-spec-set 'jaspace-highlight-jaspace-face ;; '((((class color) (background light)) ;; (:foreground "blue")) ;; (t (:foreground "green")))) ;; (face-spec-set 'jaspace-highlight-tab-face ;; '((((class color) (background light)) ;; (:foreground "red" ;; :background "unspecified" ;; :strike-through nil ;; :underline t)) ;; (t (:foreground "purple" ;; :background "unspecified" ;; :strike-through nil ;; :underline t)))) ;; (face-spec-set 'trailing-whitespace ;; '((((class color) (background light)) ;; (:foreground "red" ;; :background "unspecified" ;; :strike-through nil ;; :underline t)) ;; (t (:foreground "purple" ;; :background "unspecified" ;; :strike-through nil ;; :underline t)))))))) ;==================================== ;;jaspace.el を使った全角空白、タブ、改行表示モード ;;切り替えは M-x jaspace-mode-on or -off ;==================================== (require 'jaspace) (setq jaspace-modes (append jaspace-modes (list 'php-mode 'ruby-mode 'text-mode 'fundamental-mode))) ;; 全角空白を表示させる。 (setq jaspace-alternate-jaspace-string "□") ;; 改行記号を表示させる。 (setq jaspace-alternate-eol-string "↓\n") ;; タブ記号を表示。 (setq jaspace-highlight-tabs t) ; highlight tabs ;; EXPERIMENTAL: On Emacs 21.3.50.1 (as of June 2004) or 22.0.5.1, a tab ;; character may also be shown as the alternate character if ;; font-lock-mode is enabled. ;; タブ記号を表示。 ;(setq jaspace-highlight-tabs ?>) ; use ^ as a tab marker ;==================================== ;;全角スペースとかに色を付ける ;==================================== ;; (defface my-face-b-1 '((t (:background "medium aquamarine"))) nil) ;; (defface my-face-b-1 '((t (:background "dark turquoise"))) nil) ;; (defface my-face-b-2 '((t (:background "cyan"))) nil) ;; (defface my-face-b-2 '((t (:background "SeaGreen"))) nil) ;; (defface my-face-u-1 '((t (:foreground "SteelBlue" :underline t))) nil) ;; (defvar my-face-b-1 'my-face-b-1) ;; (defvar my-face-b-2 'my-face-b-2) ;; (defvar my-face-u-1 'my-face-u-1) ;; (defadvice font-lock-mode (before my-font-lock-mode ()) ;; (font-lock-add-keywords ;; major-mode ;; '( ;; (" " 0 my-face-b-1 append) ;; ("\t" 0 my-face-b-2 append) ;; ("[ ]+$" 0 my-face-u-1 append) ;; ))) ;; (ad-enable-advice 'font-lock-mode 'before 'my-font-lock-mode) ;; (ad-activate 'font-lock-mode) ;; (add-hook 'find-file-hooks '(lambda () ;; (if font-lock-mode ;; nil ;; (font-lock-mode t)))) ;; PHPモード読み込み (load-library "php-mode") (require 'php-mode) ;; ruby-mode (autoload 'ruby-mode "ruby-mode" "Mode for editing ruby source files" t) (setq auto-mode-alist (append '(("\\.rb$" . ruby-mode)) auto-mode-alist)) (setq interpreter-mode-alist (append '(("ruby" . ruby-mode)) interpreter-mode-alist)) (autoload 'run-ruby "inf-ruby" "Run an inferior Ruby process") (autoload 'inf-ruby-keys "inf-ruby" "Set local key defs for inf-ruby in ruby-mode") (add-hook 'ruby-mode-hook '(lambda () (inf-ruby-keys))) ;; ruby-electric (require 'ruby-electric) (add-hook 'ruby-mode-hook '(lambda () (ruby-electric-mode t))) ;; rubydb (autoload 'rubydb "rubydb3x" "run rubydb on program file in buffer *gud-file*. the directory containing file becomes the initial working directory and source-file directory for your debugger." t) ;; rails (defun try-complete-abbrev (old) (if (expand-abbrev) t nil)) (setq hippie-expand-try-functions-list '(try-complete-abbrev try-complete-file-name try-expand-dabbrev)) (setq rails-use-mongrel t) (require 'cl) (require 'rails) ;; ruby-block (require 'ruby-block) (ruby-block-mode t) ;; ミニバッファに表示し, かつ, オーバレイする. (setq ruby-block-highlight-toggle t) ;; ECB (require 'ecb) (setq ecb-tip-of-the-day nil) (setq ecb-windows-width 0.25) (defun ecb-toggle () (interactive) (if ecb-minor-mode (ecb-deactivate) (ecb-activate))) (global-set-key [f2] 'ecb-toggle) ;;透明化設定 (setq default-frame-alist (append (list '(alpha . (85 25)) ) default-frame-alist)) ;; color theme (require 'color-theme) (color-theme-initialize) (color-theme-midnight) (w32-maximize-frame) ;;選択範囲を色付け (transient-mark-mode 1) ;; エラーラインの変更 (set-face-background 'flymake-errline "DarkRed") ;; 終了時に自動生成されているオートセーブファイルを削除する (setq delete-auto-save-files t) ;; 対応する括弧をハイライト表示行う (show-paren-mode 1) ;; カーソルの位置を表示する (column-number-mode t) (line-number-mode t) ;; モードラインに時間を表示する (display-time) ;; 行の折り返し表示をする (setq truncate-lines nil) (setq truncate-partial-width-windows nil) ;; 起動時の画面を表示しない ;;(setq inhibit-startup-message t) ;; IMEのOnOffでカーソル色を変更する (add-hook 'mw32-ime-on-hook (function (lambda () (set-cursor-color "SkyBlue"))) (add-hook 'mw32-ime-off-hook (function (lambda () (set-cursor-color "Red"))) ;;; ;;; Subversion ;;; (require 'psvn)
いろんなサイトを参考にさせてもらったんで記述方法はかなりごちゃごちゃww
そろそろEmacs Lispの勉強もしよう。