Emacsの設定方法のうんたらかんたら
Emacsの基本的なキーバインドは
こちら
こちらにキーバインドをまとめたチートシート(早見表)があるので、
Emacsを使いこなしたい人は見ておくといいかも(PDFファイルもあるので、DLして印刷もできます)。
ホームディレクトリの「.emacs」に以下の内容を記述すれば色々便利になります。
枠内の内容をそのままコピペして試してみてくださいねー
外部のEmacs Lispを使った拡張は
別ページで解説
;; ファイルの先頭が#!で始まるファイルは実行権をつけて保存(PerlとかRubyとか)
(add-hook 'after-save-hook
'executable-make-buffer-file-executable-if-script-p)
;; 色をつける
(auto-image-file-mode t)
;; Emacsのカラー設定(一例)
(set-cursor-color "light blue")
(set-background-color "gray30")
(set-foreground-color "white")
(set-face-background 'modeline "gainsboro")
(set-face-background 'region "light blue")
(set-face-foreground 'region "gray80")
M-x list-colors-display で使うことができる色を見ることができます。
;;終了時にオートセーブファイル(ファイル名の最後に~がついたファイル)を消す
(setq delete-auto-save-files t)
;;ビープ音を鳴らさない
(setq visible-bell t)
;;ビープ音の代わりの画面の反転さえもさせない
(setq ring-bell-function '(lambda ()))
;; tab を半角スペースに展開する
(setq-default indent-tabs-mode nil)
;; モードラインにカラム数を表示
(column-number-mode 1)
;; emacsの起動画面を消す
(setq inhibit-startup-message t)
;;ツールバー消去
(tool-bar-mode nil)
;; メニュー消去
(menu-bar-mode nil)
;; 1行全て(改行含めて)消す
(setq kill-whole-line t)
;;スクロールバーを右に
(set-scroll-bar-mode 'right)
;; 圧縮されたファイルを読めるようにする
(auto-compression-mode t)
;; y-or-n-p(yes、noではなくy、nだけで答える)
(fset 'yes-or-no-p 'y-or-n-p)
;; -nwオプションでメニューバーが出ないように
(if window-system (menu-bar-mode 1) (menu-bar-mode -1))
;; 折り返し有りを設定
(setq truncate-lines nil)
(setq truncate-partial-width-windows nil)
;; 初期フレームの設定
;; (Emacsが起動する位置と大きさ お好きなようにどうぞ)
(setq default-frame-alist
(append (list '(width . 80)
'(height . 63)
'(top . 50)
'(left . 700))
default-frame-alist))
;; スクロールを1行毎に
(defun sane-next-line (arg)
"Goto next line by ARG steps with scrolling sanely if needed."
(interactive "p")
(let ((newpt (save-excursion (next-line arg) (point))))
(while (null (pos-visible-in-window-p newpt))
(if (< arg 0) (scroll-down 1) (scroll-up 1)))
(goto-char newpt)
(setq this-command 'next-line)
())
)
(defun sane-previous-line (arg)
"Goto previous line by ARG steps with scrolling back sanely if needed."
(interactive "p")
(sane-next-line ( - arg))
(setq this-command 'previous-line)
()
)
(defun sane-newline (arg)
"Put newline\(s\) by ARG with scrolling sanely if needed."
(interactive "p")
(let ((newpt (save-excursion (newline arg) (indent-according-to-mode) (point))))
(while (null (pos-visible-in-window-p newpt)) (scroll-up 1))
(goto-char newpt)
(setq this-command 'newline)
()))
(global-set-key [up] 'sane-previous-line)
(global-set-key [down] 'sane-next-line)
(global-set-key "\C-m" 'sane-newline)
(define-key global-map "\C-n" 'sane-next-line)
(define-key global-map "\C-p" 'sane-previous-line)
;; 改行キーでオートインデント
(define-key global-map "\C-m" 'newline-and-indent)
;; 常にカッコの対応をハイライトする
(show-paren-mode 1)
(setq show-paren-style 'mixed)
最終更新:2010年12月07日 13:27