Mac版VirtualBoxの設定
USB接続のDVD/BDドライブを認識させる
パッケージでauto-completeを入れた場合の初期設定
Emacs24のパッケージ機能を使ってauto-completeをインストールしたが、init.elの中で設定しようとすると、そんなファイルは無いといって怒られる。これは、パッケージ機能が起動されるのがinit.elを読み込んだ後なので、init.elの中ではパッケージ置き場へのload-pathがまだ設定されていないため。
したがって、パッケージ機能が起動してから初期設定するようにすればよい。
(add-hook 'emacs-startup-hook (function (lambda () (require 'auto-complete-config) (ac-config-default))))
Emacs24+Howm+Org
Emacs24に移行したらHowmでエラーが出るようになったので、Howmのバージョンを上げる。
howm-1.4.0rc2はEmacs24に対応しているので、これをインストールする。ElispファイルをDropboxに置いて共有しているので、configureのオプションで置き場所を指定する。
$ ./configure --prefix=~/Dropbox/ --with-lispdir=~/Dropbox/share/emacs/lisp/
ついでにHowmのファイルをOrgで書くようにする。OrgとHowmでアウトラインに使う記号やキーバインディングが違うので、共存できるように設定しなければいけない。
;; HOWM (add-to-list 'load-path "~/Dropbox/share/emacs/lisp/howm") ; C-c , がOrgとぶつかるので、C-x , に変更。 (global-set-key "\C-x,," 'howm-menu) (setq howm-prefix "\C-x,") (autoload 'howm-menu "howm" "Hitori Otegaru Wiki Modoki" t) (setq howm-directory "~/Dropbox/Howm/") (setq howm-history-file "~/Dropbox/Howm/.howm-history") (setq howm-keyword-file "~/Dropbox/Howm/.howm-keys") ; 新しくメモを作る時は、先頭の「=タイトル」だけ挿入。 (setq howm-template "= %title%cursor\n\n") (add-hook 'howm-mode-hook (function (lambda () ; Orgは見出しに*を使う。Howmも*を使うようにできるが、そうすると今まで書いたメモがタイトル無しになって悲しいので、Howmは=のままにする。 ; outline-mode的には*と=の両方を見出しとして扱うようにする。Orgの中でoutline-modeの関数を呼んでいるところがあるため。 (setq outline-regexp "[*=]+") ; Dropboxでバックアップがあるので、バックアップファイルは作らなくてもいいだろう。 (set (make-local-variable 'backup-inhibited) t)))) (add-hook 'howm-after-save-hook (function (lambda () ; 内容が空の場合はファイルを削除する。 (if (= (point-min) (point-max)) (delete-file (buffer-file-name (current-buffer))))))) ; 完了済みのtodoを未完了に戻す。 (fset 'howm-revive-todo (lambda (&optional arg) "Keyboard macro." (interactive "p") (kmacro-exec-ring-item (quote ([1 19 46 13 6 23 19 58 13 backspace 2 2] 0 "%d")) arg))) ;; ORG ; .txtを全部org-modeにするのもアレなので、Dropbox/Howmの下の.howmか.txtのファイルのみorg-modeにする。 (add-to-list 'auto-mode-alist '("Dropbox/Howm/.+\\.howm$" . org-mode)) (add-to-list 'auto-mode-alist '("Dropbox/Howm/.+\\.txt$" . org-mode)) ; Dropbox/Howmの下でorg-modeで編集する場合はhowm-modeを追加。 (add-hook 'org-mode-hook (function (lambda () (if (string-match "Dropbox/Howm" buffer-file-name) (howm-mode)))))
MacでDocBook
テキストを書くのにSmartDocを使っていたが、長らく開発が停止しているようなので、次のような条件で別のものを探してみた。
どうもDocBookが条件を満たしているようである。XMLを手で書くのはアレだけど、Museを使えばWiki記法で書いてDocBookに変換できる。
ググッてみると情報が錯綜していてどうすればいいのかよく分からないが、MacPortsに必要なものは一通り揃っているようなので、とりあえずそれを入れてみる。
$ sudo port install docbook-xml-4.2 $ sudo port install docbook-xsl $ sudo port install libxslt
docbook-xml-4.2なのは、Museが生成するXMLのDTDがそうなっているから。
Saxonはchunk.xslがうまく動かなかったので、Xalanにする。Xalanはスタイルシートのパス名に日本語があると怒るので、xsltprocにする。
switch-to-bufferでanythingを使わないようにする
anything.elは便利なんだけど、switch-to-bufferで存在しないバッファ名を指定するとエラーになるので、新しいバッファを作ることができない。それにバッファはそんなにたくさんないので、anythingで補完するのは大げさな気もする。というわけで、バッファ名入力にanythingを使わないようにしてみた。
ミニバッファ入力でanythingを使うかどうかは M-x anything-read-string-mode
でトグルできるが、これだとすべての入力に対して使うか使わないかのどちらかになる。anythingを使う入力の種類を指定したい場合は次のようにする。
(anything-read-string-mode '(string variable command))
Lionでsshfsを使う
LionにしたらMacFuseが動かなくなってしまった。ググッてもよく分からないので、Fuse4xに乗り換えることにする。Macfusionを使うには、sshfsコマンドをfuse4x用のものに入れ替えることが必要。
SSHFS on Mac OS X 10.6.8 and 10.7.2 with Fuse4X – Philipp Klaus's Computing Blog
sudo port install fuse4x
sudo port install sshfs
- Macfusionをダウンロード
cd ~/Downloads/Macfusion.app/Contents/PlugIns/sshfs.mfplugin/Contents/Resources
mv sshfs-static sshfs-static.orig
ln -s /opt/local/bin/sshfs sshfs-static
EmacsのSESでCSVファイルを読み書きする
標準ではタブ区切りテキストしか対応していないので、rubyを通してCSVと変換できるようにしてみた。
;; ses-csv.el -- Read/Write CSV file for SES ;; Author: Takashi Hattori (hattori@sfc.keio.ac.jp) ;; Requires: Ruby (defun ses-read-from-csv-file (file) "Insert the contents of a CSV file named FILE into the current position." (interactive "fCSV file: ") (let ((buf (get-buffer-create "*ses-csv*")) text) (save-excursion (set-buffer buf) (erase-buffer) (process-file "ruby" file buf nil "-e" "require 'csv'; CSV::Reader.parse(STDIN) { |x| puts x.join(\"\\t\") }") (setq text (buffer-substring (point-min) (point-max)))) (ses-yank-tsf text nil))) (defun ses-write-to-csv-file (file) "Write the values of the current buffer into a CSV file named FILE." (interactive "FCSV file: ") (push-mark (point-min) t t) (goto-char (- (point-max) 1)) (ses-set-curcell) (ses-write-to-csv-file-region file)) (defun ses-write-to-csv-file-region (file) "Write the values of the region into a CSV file named FILE." (interactive "FCSV file: ") (ses-export-tab nil) (let ((buf (get-buffer-create "*ses-csv*"))) (save-excursion (set-buffer buf) (erase-buffer) (yank) (call-process-region (point-min) (point-max) "ruby" t buf nil "-e" "require 'csv'; w = CSV::Writer.create(STDOUT); STDIN.each { |x| w << x.chomp.split(/\\t/) }") (write-region (point-min) (point-max) file))))