2010年6月8日火曜日

dot-emacs-example.el

Emacs Newbiesの為に.emacsの雛形を公開します。Emacs23以上対応です。

以前、UbuntuのEmacs22辺りまではUbuntu Japanese Team制作のdot.emacs.exampleが同梱されていたのですが、Emacs23からは完全UTF-8対応になった為か、無くなってしまいました。
そこで利便性を考え、オリジナル(GPLライセンス)のdot.emacs.exampleを改造したのが以下のdot-emacs-example.elです。

勝手に持って行って下さい(笑)。

;;=======================================================================
;; map-dir-list-into-load-path の定義
;;=======================================================================
;; rubikitch さん作のユーティリティ
;; http://d.hatena.ne.jp/rubikitch/20090609/1244484272
(defun add-to-load-path-recompile (dir)
(add-to-list 'load-path dir)
(let (save-abbrevs) (byte-recompile-directory dir)))
(defun map-dir-list-into-load-path (dir-lst)
(mapcar #'(lambda (x)
(add-to-load-path-recompile
(expand-file-name x)))
dir-lst))
;;
;;=======================================================================
;; パスを通す
;;=======================================================================
(defvar *dot-emacs-load-path-list*
'("~/.emacs.d/auto-install"
;; ここで文字列でパスを通したいディレクトリを指定する
;; 例: "/i/want/to/make/a/path/to/the/directory"
))
(map-dir-list-into-load-path *dot-emacs-load-path-list*)
;;
;;=======================================================================
;; dot-emacs-requirements-list
;;=======================================================================
(defvar *dot-emacs-requirements-list*
'(cl
session
;; 必要な機能があったらここに書き込む
;; 例: auto-install
))
(mapcar #'require *dot-emacs-requirements-list*)
;;
;;=======================================================================
;; フレームサイズ
;;=======================================================================
(defvar *dot-emacs-frame-setting-list*
'((width . 90) ; フレームの幅
(height . 49) ; フレームの高さ
(top . 0) ; Y 表示位置
(left . 340) ; X 表示位置
(alpha . (100 25)))) ; 透明度
(loop for i in *dot-emacs-frame-setting-list*
do (add-to-list 'initial-frame-alist i))
(setf default-frame-alist initial-frame-alist)
;;
;;=======================================================================
;; Misc
;;=======================================================================
(mouse-wheel-mode t) ;;ホイールマウス
(global-font-lock-mode t) ;;文字の色つけ
(setf line-number-mode t) ;;カーソルのある行番号を表示
(auto-compression-mode t) ;;日本語infoの文字化け防止
(set-scroll-bar-mode 'right) ;;スクロールバーを右に表示
(global-set-key "\C-z" 'undo) ;;UNDO
(setf frame-title-format ;;フレームのタイトル指定
(concat "%b - emacs@" system-name))
(display-time) ;;時計を表示
;; (global-set-key "\C-h" 'backward-delete-char) ;;Ctrl-Hでバックスペース
;; (setf make-backup-files nil) ;;バックアップファイルを作成しない
;; (setf visible-bell t) ;;警告音を消す
;; (setf kill-whole-line t) ;;カーソルが行頭にある場合も行全体を削除
;; (when (boundp 'show-trailing-whitespace)
;; (setq-default show-trailing-whitespace t)) ;;行末のスペースを強調表示
;;
;;=======================================================================
;; 履歴の保存
;;=======================================================================
(add-hook 'after-init-hook 'session-initialize)
;;
;;=======================================================================
;; 最近使ったファイル
;;=======================================================================
(recentf-mode)
;;
;;=======================================================================
;; リージョンに色を付ける
;;=======================================================================
(setf transient-mark-mode t)
;;
;;=======================================================================
;; 対応する括弧を光らせる
;;=======================================================================
(show-paren-mode)
;;
;;=======================================================================
;; C-c c で compile コマンドを呼び出す
;;=======================================================================
(define-key mode-specific-map "c" 'compile)
;;
;;=======================================================================
;; スクリプトを保存する時、自動的に chmod +x を行うようにする
;;=======================================================================
;; http://www.namazu.org/~tsuchiya/elisp/#chmod
;; を参照
(defun make-file-executable ()
"Make the file of this buffer executable, when it is a script source."
(save-restriction
(widen)
(if (string= "#!"
(buffer-substring-no-properties 1
(min 3 (point-max))))
(let ((name (buffer-file-name)))
(or (equal ?. (string-to-char
(file-name-nondirectory name)))
(let ((mode (file-modes name)))
(set-file-modes name (logior mode (logand
(/ mode 4) 73)))
(message (concat "Wrote " name " (+x)"))))))))
(add-hook 'after-save-hook 'make-file-executable)
;;
;;=======================================================================
;; End of File
;;=======================================================================

0 件のコメント:

コメントを投稿