[ホーム]-> [Mac]->[Emacs]

Carbon Emacs

Carbon Emacs は /Applications にインストールした。

Spotlightのキー変更

Emacs で多用する Control-Spaceが Spotlight に取られてしまうので、

のキーボードショートカットのタブで、Spotlight のキーを無効化ないしは変更する。

スペースキーでファイル名補完

次のようにするとスペースキーでもファイル名補完できる。

 (define-key minibuffer-local-filename-completion-map
  " " 'minibuffer-complete-word)
 (define-key minibuffer-local-must-match-filename-map
  " " 'minibuffer-complete-word)

YaTeX

TeXファイルの編集には野鳥 (YaTeX)を利用している。これについては、TeXのページを参照。

emacs-w3m

cvs でソースを取ってくる。

cvs -d :pserver:anonymous@cvs.namazu.org:/storage/cvsroot login
cvs -d :pserver:anonymous@cvs.namazu.org:/storage/cvsroot co emacs-w3m
そして
autoconf
./configure --with-emacs=/Applications/Emacs.app/Contents/MacOS/Emacs \
  --with-lispdir=/Applications/Emacs.app/Contents/Resources/site-lisp/w3m \
  --with-icondir=/Applications/Emacs.app/Contents/Resources/etc/w3m
make
sudo make install
sudo make install-icons
で OK.

.emacs.elには、

(require 'w3m-load)
(require 'mime-w3m)
と書いておく。emacs-w3m はホームに .emacs-w3m という ファイルがあると自動的に読んでくれるみたいなので、ここにその他の記述することに。
(setq w3m-home-page "file://Users/foo/Documents/.web/index.html")
(setq w3m-use-cookies t)
(setq w3m-use-form t)
(setq w3m-icon-directory "/Applications/Emacs.app/Contents/Resources/etc/w3m")
などとすると、起動時には /Users/foo/Documents/.web/index.htmlを読み込んだりしてくれる。その他にもいろいろ設定したくなるが、それは Web で調べればよい。

Wanderlust

メーラーには Wanderlust を利用している。

Xcode をインストールしてるにもかかわらず何故か Net Install できなかったので、自分で入れる。 こちらは mime 関係もインストールしないといけないので、ちょっと面倒。

flim, semi

まずは、 flimsemi を インストールする。ともにソースを展開して

make EMACS=/Applications/Emacs.app/Contents/MacOS/Emacs \
LISPDIR=/Applications/Emacs.app/Contents/Resources/site-lisp \
VERSION_SPECIFIC_LISPDIR=/Applications/Emacs.app/Contents/Resources/site-lisp \
INFODIR=/Applications/Emacs.app/Contents/Resources/share/info

sudo make \
EMACS=/Applications/Emacs.app/Contents/MacOS/Emacs \
LISPDIR=/Applications/Emacs.app/Contents/Resources/site-lisp \
VERSION_SPECIFIC_LISPDIR=/Applications/Emacs.app/Contents/Resources/site-lisp \
INFODIR=/Applications/Emacs.app/Contents/Resources/share/info install
で大丈夫。

Wanderlust本体

Wanderlust本体は、 スナップショットのページから最新のベータ版を取ってきた。ソースを展開し、 Makefileでは

LISPDIR = /Applications/Emacs.app/Contents/Resources/site-lisp
PIXMAPDIR = /Applications/Emacs.app/Contents/Resources/etc/wl/icons
また、WL-CFG では
(setq load-path (append
		 (list "/Applications/Emacs.app/Contents/Resources/site-lisp/apel"
		       "/Applications/Emacs.app/Contents/Resources/site-lisp/flim"
		       "/Applications/Emacs.app/Contents/Resources/site-lisp/semi"
			   "/Applications/Emacs.app/Contents/Resources/site-lisp/emu"
			   "/Applications/Emacs.app/Contents/Resources/site-lisp/w3m"
			   )
		 load-path))

などの設定をしておいてから、
make
sudo make install

SKK

SKK Openlabからソースを取ってくる。展開して次のようにすればインストールできる。

export SKK_LISPDIR=/Applications/Emacs.app/Contents/Resources/site-lisp/skk \
	SKK_INFODIR=/Applications/Emacs.app/Contents/Resources/info \
	SKK_DATADIR=/Applications/Emacs.app/Contents/Resources/share/skk ; \
make EMACS=/Applications/Emacs.app/Contents/MacOS/Emacs \
     prefix=/Applications/Emacs.app/Contents/Resources install

SKK用の辞書はhttp://openlab.jp/skk/の dic のところから、実際には使わないものまでいろいろダウンロードして /Applications/Emacs.app/Contents/Resources/share/skk/にインストールした。通常は.skk

(setq skk-large-jisyo "/Applications/Emacs.app/Contents/Resources/share/skk/SKK-JISYO.L")
と書いておけば十分だが、ちょっとマニアックに次のように設定した。
(setq skk-search-prog-list
      (append
       '((skk-search-jisyo-file skk-initial-search-jisyo 0 t)
	 (skk-search-jisyo-file skk-jisyo 0 t))
       (let ((path "/Applications/Emacs.app/Contents/Resources/share/skk/"))
	 (mapcar #'(lambda (x)
		     `(skk-search-jisyo-file ,(concat path (car x)) ,(cdr x)))
		 '(("SKK-JISYO.L" . 10000)
		   ("SKK-JISYO.assoc" . 10000)
		   ("SKK-JISYO.edict" . 10000)
		   ("SKK-JISYO.fukugo" . 10000)
		   ("SKK-JISYO.fullname" . 10000)
		   ("SKK-JISYO.geo" . 10000)
		   ("SKK-JISYO.station" . 10000)
		   ("SKK-JISYO.jinmei" . 10000)
		   ("SKK-JISYO.propernoun" . 10000)
		   ("SKK-JISYO.okinawa" . 10000)
		   ("SKK-JISYO.law" . 10000)
		   ("SKK-JISYO.pubdic+" . 10000))))))

.skkにはその他に次のように書いている。 これは(も) Linux と共通だが、句読点のインテリジェントな入力のためのもの。 skk の ML やネットで見たコードをちょっとだけ修正して利用。

(setq-default skk-kutouten-type 'jp)

(add-hook 'yatex-mode-hook
	  '(lambda () (setq skk-kutouten-type 'jp-en)))

(defun skk-insert-hyphen (arg)
  (interactive "P")
  (insert
   (let (s
	 (c (char-before (point))))
     (if c (setq s (char-to-string (char-before (point)))))
     (cond ((null s) "ー")
	   ((string-match "[0-9]" s) "-")
	   ((string-match "[0-9]" s) "−")
	   (t "ー")))))

; from kitamoto tsuyoshi さん
(defun skk-period (arg)
  (let ((c (char-before (point))))
    (cond ((null c) (cadr (assoc skk-kutouten-type skk-kuten-touten-alist)))
	  ((and (<= ?0 c) (>= ?9 c)) ".")
	  ((and (<= ?0 c) (>= ?9 c)) ".")
	  (t (cadr (assoc skk-kutouten-type skk-kuten-touten-alist))))))

(defun skk-comma (arg)
  (let ((c (char-before (point))))
    (cond ((null c) (cddr (assoc skk-kutouten-type skk-kuten-touten-alist)))
	  ((and (<= ?0 c) (>= ?9 c)) ",")
	  ((and (<= ?0 c) (>= ?9 c)) ",")
	  (t (cddr (assoc skk-kutouten-type skk-kuten-touten-alist))))))

(setq skk-rom-kana-rule-list
      (nconc skk-rom-kana-rule-list
	     '(
	       ("!" nil "!")
	       (":" nil ":")
	       (";" nil ";")
	       ("?" nil "?")
	       ("-" nil skk-insert-hyphen)
	       ("." nil skk-period)
	       ("," nil skk-comma)
	       )))

.emacs.el

その他 .emacs.el でこまごまと設定。 まずはキー関係。Ctrl-hで前一文字削除できるようにし、 そのかわりM-hをヘルプコマンドにした。 その他、修飾キーも設定。
(keyboard-translate ?\C-h ?\C-?)
(global-set-key "\C-h" nil)
(global-set-key "\M-h" 'help-command)
(setq mac-command-modifier 'meta)
(setq mac-control-modifier 'control)
(setq mac-option-modifier 'alt)

表示についても設定。

(setq inhibit-startup-message t)
(tool-bar-mode nil)
(set-scroll-bar-mode nil)
(line-number-mode t)
(if window-system
    (progn
      (setq default-frame-alist
	    (append
	     '((width . 80) (height . 36)
	       (background-color . "cornsilk")
	       )
	     default-frame-alist))))

(if (eq window-system 'mac) (require 'carbon-font))
(fixed-width-set-fontset "hirakaku_w3" 12)
スクロールバーやツールバーはどうせ使わないので表示しない。 ウィンドウの大きさとか、色を設定。 フォントはこりだすときりがないので、取り敢えずヒラギノで。

圧縮ファイルもそのまま扱えるように。また最近使ったファイルもファイルメニューから選べるようにする。

(auto-compression-mode t)
(recentf-mode 1)

拡張子が gpg のファイルは自動で gnupg を使って暗号化/復号化するように。 もちろん macports で gnupg をあらかじめインストールしておく。 また、gpg.el も Emacs のパスにインストールしておく。

(autoload 'gpg-after-find-file "gpg" nil t)
(add-hook 'find-file-hooks 'gpg-after-find-file)

個人用の Emacs Lisp

個人用の emacs lisp は ~/lib/emacs/ に入れることにする。

(setq load-path (cons "~/lib/emacs" load-path))

session.el

session.elのための設定。ネットで見たものをほぼ丸写し。 終了しても前に開いたファイルや編集位置を覚えていてくれるので、とても便利。

(when (locate-library "session")
  (setq session-globals-max-size 512)
  (setq session-globals-regexp "-\\(ring\\|history\\|hist\\)\\'")
  (require 'session)
  (defadvice find-alternate-file
    (before session-store-buffer-places last activate)
    "Invoke session-kill-buffer-hook."
    (session-kill-buffer-hook))
  (add-to-list 'session-kill-buffer-commands 'find-alternate-file)
 
  (add-hook 'after-init-hook 'session-initialize))

(when (locate-library "minibuf-isearch")
  (setq minibuf-isearch-indicator-string nil)
  (setq minibuf-isearch-display-message-always t)
  (setq minibuf-isearch-match-format-string "[isearch with '%s']")
  (setq minibuf-isearch-no-match-format-string "[No further match with '%s']")
  (setq minibuf-isearch-message-on-right t)
  (setq history-length 128)
  (require 'minibuf-isearch))

lookup

辞書の検索には lookup を使っている。

準備として、ebeblook が必要で、 macports からインストールする。

lookup 本体は、 1.4.1 のソースを展開して

./configure \
  --with-emacs=/Applications/Emacs.app/Contents/MacOS/Emacs \
  --with-lispdir=/Applications/Emacs.app/Contents/Resources/site-lisp/lookup \
  --infodir=/Applications/Emacs.app/Contents/Resources/info/
make
sudo make install
でインストール。

辞書ファイルは他の環境と揃えるために /usr/share/dict に入れることにした。その他の設定はネットを参考にする。


[ホーム]-> [Mac]->[Emacs]