できる Emacs 第二回
/⌒ ⌒\ /( ●) (●)\ またまた登場のやる夫だお! /::::::⌒(__人__)⌒::::: \ 今日はEmacsをやる夫の好みにカスタマイズするお! | |r┬-| | \ `ー'´ / ___ / ⌒ ⌒\ / (⌒) (⌒) \ おいら、ちっちゃくって色白で / ///(__人__)/// \ 髪は黒くて長いのが好みだお! | u. `Y⌒y'´ | \ ゙ー ′ ,/ /ノ 0ヽ _|___|_ ヽ( # ゚Д゚)ノ Emacsより早くedはこの世にあった | 个 | 心はケン・トンプソンに捧げてもよい ノ| ̄ ̄ヽ だが貴様らのケツはストールマンのものだ! ∪⌒∪ ____ /ノ ヽ、_\ /( ○)}liil{(○)\ / (__人__) \ だ、誰だお? | ヽ |!!il|!|!l| / | \ |ェェェェ| /
…
……
………
すいません、上のは間違いです。
これまでのあらすじ
見た目のカスタマイズ
まずはフォントの設定を行います。xfonts-shinonome を apt からインストール。
フォントや色の設定は ~/.Xresources に記述します。フォントやフレームの設定はssh 越しに -nw で起動した場合には関係ないので、.emacs ではなく X 側で設定するのが自然な気がしますし、Emacs の起動速度も少し稼ぐことができます。
$ sudo apt-get install xfonts-shinonome
こちらは .emacs に書いている設定。
emacs*Background: gray30
emacs*Foreground: White
emacs*pointerColor: White
emacs*cursorColor: White
emacs*bitmapIcon: on
emacs*font: -shinonome-gothic-medium-r-*-*-12-*-*-*-*-*-*-*
emacs.geometry: 150x55
;;リージョンに色を付ける
(setq transient-mark-mode t);;フォントロック
(global-font-lock-mode 1)
(setq font-lock-support-mode 'jit-lock-mode);; 色づけは最大限に
(setq font-lock-maximum-decoration t);; デフォルトの色づけを変える
(add-hook 'font-lock-mode-hook '(lambda ()
(set-face-foreground 'font-lock-builtin-face "spring green")
(set-face-foreground 'font-lock-comment-face "slate gray")
(set-face-foreground 'font-lock-string-face "spring green")
(set-face-foreground 'font-lock-keyword-face "khaki")
(set-face-foreground 'font-lock-constant-face "violet")
(set-face-foreground 'font-lock-function-name-face "hot pink")
(set-face-foreground 'font-lock-variable-name-face "hot pink")
(set-face-foreground 'font-lock-type-face "cyan")
(set-face-foreground 'font-lock-warning-face "magenta")
(set-face-bold-p 'font-lock-function-name-face t)
(set-face-bold-p 'font-lock-warning-face nil)
));; カーソル行に下線を表示
(setq hl-line-face 'underline)
(global-hl-line-mode);; モードラインに行数と桁数を表示
(line-number-mode 1)
(column-number-mode 1);; モードラインに時間表示 月/日 曜日
(setq display-time-string-forms '(year "/" month "/" day " (" dayname ") " 24-hours ":" minutes))
(display-time);; タイトルバーの表示設定
(setq frame-title-format
`(" GNU/Emacs " emacs-version " -- %b " (buffer-file-name "( %f )")));; ツールバーを表示しない
(tool-bar-mode 0)
(menu-bar-mode 0);; スクロールバーはいらない
(set-scroll-bar-mode nil);; 起動時の画面はいらない
(setq inhibit-startup-message t);; 対応する括弧を強調表示
(show-paren-mode t)
(setq show-paren-style 'mixed);; マッチした場合の色
(set-face-background 'show-paren-match-face "dodger blue")
(set-face-foreground 'show-paren-match-face "white");; マッチしていない場合の色
(set-face-background 'show-paren-mismatch-face "Red")
(set-face-foreground 'show-paren-mismatch-face "black")
こんな感じの色になります。背景はグレーが好み。
シェルの設定
Emacs 使いはシェルも Emacs 上から起動します。Ubuntu はデフォルトでシェル文字に色がついていますが、Emacs 上からシェルを実行すると色コードがそのまま表示されてしまいます。こいつを回避するためには以下の設定を行います。
;; shell の色問題対応
(autoload 'ansi-color-for-comint-mode-on "ansi-color"
"Set `ansi-color-for-comint-mode' to t." t)
(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)