何か書いてるといつのまにかファイルの末尾に改行がたくさんできてることが多い。
残ったままpushすると恥ずかしいし汚い感じがして気分がよくない。
改行に比べるとあまりないけど行末にスペースが残ってたりもしてそれもイライラする。
こういうので目立つようにして気づくようにしてたけど、自動で消すのを書けばいいことに気づいた。
Markdownとか、行末のスペースに意味があるファイルもあるので、そういうのは消さないように設定できるようにした。
バッファ名がdelete-trailing-whitespace-exclude-patternsのパターンのどれかにマッチしたら消さない。
今まではコピペしてきたのを勘で読んで勘で直してたけど、今回はわりと自分で書いた感じがする。
ファイル末尾の改行を消す奴は拾って来ました。
;; 行末のwhitespaceを削除 (setq delete-trailing-whitespace-exclude-patterns (list "\\.md$" "\\.markdown$")) (require 'cl) (defun delete-trailing-whitespace-with-exclude-pattern () (interactive) (cond ((equal nil (loop for pattern in delete-trailing-whitespace-exclude-patterns thereis (string-match pattern buffer-file-name))) (delete-trailing-whitespace)))) (add-hook 'before-save-hook 'delete-trailing-whitespace-with-exclude-pattern) ;; ファイル末尾の改行を削除 ;; http://www.emacswiki.org/emacs/DeletingWhitespace (defun my-delete-trailing-blank-lines () "Deletes all blank lines at the end of the file." (interactive) (save-excursion (save-restriction (widen) (goto-char (point-max)) (delete-blank-lines)))) (add-hook 'before-save-hook 'my-delete-trailing-blank-lines)
参考にした
http://d.hatena.ne.jp/rubikitch/20100201/elispsyntax
http://www.emacswiki.org/emacs/DeletingWhitespace
僕の最近のイーマックスについて
さっき見つけたjaunte.el、超いい
http://kawaguchi.posterous.com/emacshit-a-hint
Lionをクリーンインストールしてemacs入れなおしてから、時々emacsが5秒ぐらい固まることがあってVimに入門しようかと思うぐらい不快だった。
なんとなくauto-complete.elをv1.3.1からGithub最新のを使うようにしたら起こらなくなって大変快適になりましたことをご報告申し上げます。
dotfilesはgitで管理してるんだけど、リポジトリがあるやつはsubmoduleとして管理したらいい感じ。