leopardに、cocoa emacs (emacs23.1) をインストールした時のメモ。
INSTALL
インストールそのものは、
MacEmacs JP Project の
「IMEパッチの適用」に書いてあるコマンドを、そのまま実行すればうまくいく。
$ tar xvfz inline_patch-20090617.tar.gz $ tar xvfz emacs-23.1.tar.gz $ cd emacs-23.1 $ patch -p 0 < ../inline_patch-20090617/emacs-inline.patch $ ./configure --with-ns --without-x $ make bootstrap $ make install $ open nextstep/Emacs.app
ただし、これらの作業を、emacsのシェルモードで行うと、
Error: charsets directory does not exist.
ethiopic.el: Error: Failure in loading charset map: MULE-ethiopic
のエラーが出てコンパイルに失敗する。ethiopic.el: Error: Failure in loading charset map: MULE-ethiopic
たぶん、EMACS関連の環境変数が邪魔になっているのだろうと思い、
configure実行の前に、
$ unset EMACSAPP EMACSDATA EMACSPATH EMACSDOC INSIDE_EMACS EMACSLOADPATHを実行すれば解決。もっとも、ターミナルで作業する分には問題ない。
フォント設定
こんな感じだ。
(create-fontset-from-fontset-spec
"-*-*-medium-r-normal--14-*-*-*-*-*-fontset-hiramaru14" nil t)
(create-fontset-from-fontset-spec
"-*-*-medium-r-normal--16-*-*-*-*-*-fontset-hiramaru16" nil t)
(create-fontset-from-fontset-spec
"-*-*-medium-r-normal--20-*-*-*-*-*-fontset-hiramaru20" nil t)
(mapc
#'(lambda (fontset)
(set-fontset-font fontset 'japanese-jisx0208
'("Hiragino Maru Gothic Pro" . "iso10646-1"))
(set-fontset-font fontset 'katakana-jisx0201
'("Hiragino Maru Gothic Pro" . "iso10646-1"))
(set-fontset-font fontset 'japanese-jisx0212
'("Hiragino Maru Gothic Pro" . "iso10646-1"))
) (list "fontset-hiramaru20" "fontset-hiramaru16" "fontset-hiramaru14"))
(let (
;; (my-fontset "fontset-hiramaru14") ;; ちっちゃいフォント
(my-fontset "fontset-hiramaru20") ;; でっかいフォント
)
(set-default-font my-fontset)
(add-to-list 'default-frame-alist `(font . ,my-fontset)))
いちおう、これで、英数文字と日本語文字の幅が1対2になり、
carbon の時と同等にきれいに表示されるようになった。
IMの設定
.emacs.el に以下を追加すると、
かなキーでモードラインに「あU:」とかが表示されるようになる。
(set-language-environment "Japanese") (setq default-input-method "MacOSX")
ただ、「ことえり」の場合は、 C-x o
などでバッファーを切り替えた時に、
モードラインの表示が現在の変換モードと一致しなくなる。
そこで、コマンドループのフック( post-command-hook )に、
IMの更新をするコードを追加してみた。
(load "cl")
(add-hook
'post-command-hook
(lexical-let ((previous-buffer nil))
#'(lambda ()
(unless (eq (current-buffer) previous-buffer)
;; (message "Change IM %S -> %S" previous-buffer (current-buffer))
(if (bufferp previous-buffer) (mac-handle-input-method-change))
(setq previous-buffer (current-buffer))))))
無理矢理っぽいコードだが、とりあえずこれで、
バッファー切り替えでも違和感なく使えるようになった。
DocView
emacs の中でPDFがみられるという、 doc-view を試してみた。
でも、ディスク内のあらゆるPDFを試してもうまく表示されない。
emacs-23.1/lisp/doc-view.el をみてみると、Ghostscript と、
xpdf または teTeX が必要と書いてある。
さっそく port でインストール。
$sudo port install ghostscript $sudo port install ghostscript-fonts-hiragino $sudo port install xpdf
これでdoc-viewが動き、PDFが表示できるようになる。
でも、macでは、全てのpdfをdocviewで表示できるわけではないらしい。
見れるファイルもあるし見れないのもある。
.emacs.el
cocoa emacs用に、僕が使っている .emacs.el の抜粋。
いろいろなサイトに載っていた設定例の寄せ集めだが、
これでも、試行錯誤の連続で、落ち着くまでには結構苦労した。
(if (>= emacs-major-version 23)
;; cocoa emacsの設定
(progn
;; Command キーをMetaキーにする
(setq ns-command-modifier (quote meta))
;; (setq ns-alternate-modifier (quote super))
(setq ns-alternate-modifier nil)
;; IM 設定
(set-language-environment "Japanese")
(setq default-input-method "MacOSX")
(prefer-coding-system 'utf-8-unix)
;; minibufferは英数モードで始める
(add-hook 'minibuffer-setup-hook 'mac-change-language-to-us)
;; buffer切り替えの時にも、IM状態をアップデート
(load "cl")
(add-hook
'post-command-hook
(lexical-let ((previous-buffer nil))
#'(lambda ()
(unless (eq (current-buffer) previous-buffer)
;; (message "Change IM %S -> %S" previous-buffer (current-buffer))
(if (bufferp previous-buffer) (mac-handle-input-method-change))
(setq previous-buffer (current-buffer))))))
(define-key global-map [ns-drag-file] 'ns-find-file) ;; find-file
;; Set text scale key
(global-set-key "\C-c+" #'(lambda () (interactive) (text-scale-increase 1)))
(global-set-key "\C-c-" #'(lambda () (interactive) (text-scale-decrease 1)))
(global-set-key "\C-c0" #'(lambda () (interactive) (text-scale-increase 0)))
;; font 設定
;; (setq fixed-width-use-QuickDraw-for-ascii t)
(setq mac-allow-anti-aliasing t)
(create-fontset-from-fontset-spec
"-*-*-medium-r-normal--14-*-*-*-*-*-fontset-hiramaru14" nil t)
(create-fontset-from-fontset-spec
"-*-*-medium-r-normal--16-*-*-*-*-*-fontset-hiramaru16" nil t)
(create-fontset-from-fontset-spec
"-*-*-medium-r-normal--20-*-*-*-*-*-fontset-hiramaru20" nil t)
(mapc
#'(lambda (fontset)
(set-fontset-font fontset 'japanese-jisx0208
'("Hiragino Maru Gothic Pro" . "iso10646-1"))
(set-fontset-font fontset 'katakana-jisx0201
'("Hiragino Maru Gothic Pro" . "iso10646-1"))
(set-fontset-font fontset 'japanese-jisx0212
'("Hiragino Maru Gothic Pro" . "iso10646-1"))
) (list "fontset-hiramaru20" "fontset-hiramaru16" "fontset-hiramaru14"))
(create-fontset-from-fontset-spec
"-*-*-medium-r-normal--14-*-*-*-*-*-fontset-hirakaku14" nil t)
(create-fontset-from-fontset-spec
"-*-*-medium-r-normal--16-*-*-*-*-*-fontset-hirakaku16" nil t)
(create-fontset-from-fontset-spec
"-*-*-medium-r-normal--20-*-*-*-*-*-fontset-hirakaku20" nil t)
(mapc
#'(lambda (fontset)
(set-fontset-font fontset 'japanese-jisx0208
'("Hiragino Kaku Gothic Pro" . "iso10646-1"))
(set-fontset-font fontset 'katakana-jisx0201
'("Hiragino Kaku Gothic Pro" . "iso10646-1"))
(set-fontset-font fontset 'japanese-jisx0212
'("Hiragino Kaku Gothic Pro" . "iso10646-1"))
) (list "fontset-hirakaku20" "fontset-hirakaku16" "fontset-hirakaku14"))
(setq face-font-rescale-alist
'(("^-apple-hiragino.*" . 1.2)
(".*osaka-bold.*" . 1.2)
(".*osaka-medium.*" . 1.2)
(".*courier-bold-.*-mac-roman" . 1.0)
(".*monaco cy-bold-.*-mac-cyrillic" . 0.9)
(".*monaco-bold-.*-mac-roman" . 0.9)
("-cdac$" . 1.3)))
(let ((my-fontset "fontset-hirakaku20")
;; (my-fontset "fontset-hiramaru20")
)
(set-default-font my-fontset)
(add-to-list 'default-frame-alist `(font . ,my-fontset)))
)
;; carbon emacs (emacs 22) の設定
(progn
(require 'carbon-font)
;; ...................................................
;; ...................................................
))