私の.emacs(抜粋)

Emacs21用です。ぱくってもいいですが、できたらしらせてください。こうするといいよ〜なども歓迎。
;;;; -*- coding: euc-japan -*-
;;;; .emacs Emacs customize file by Hiroshi Takekawa
;;;; Last Modified: Thu Feb 26 23:03:10 2004.

;;;;          *** ATTENTION!! ***
;;;; If you wanna copy a part or whole of this file,
;;;; you MUST use it at your own risk.
;;;; But please send me your opinion to sian@big.or.jp.

;;; Mule-UCS
(when (locate-library "un-define")
  (require 'un-define)
  (require 'jisx0213)
  (setq mule-version (concat mule-version " / Mule-UCS " mucs-version))
  (when window-system
    (set-fontset-font "fontset-14" 'japanese-jisx0213-1 "-misc-fixed-medium-r-normal--14-130-75-75-c-140-jisx0213.2000-1")
    (set-fontset-font "fontset-14" 'japanese-jisx0213-2 "-misc-fixed-medium-r-normal--14-130-75-75-c-140-jisx0213.2000-2"))
  )


;;; Language Environment and Coding Systems
(set-language-environment "Japanese")
(set-default-coding-systems 'euc-japan-unix)
(set-terminal-coding-system 'euc-japan-unix)
(set-keyboard-coding-system 'euc-japan-unix)
(set-buffer-file-coding-system 'euc-japan-unix)
;;; speed up
(setq default-file-name-coding-system nil)
(setq file-name-coding-system nil)


;;; X上でなければメニューバーを消す。X上ならばツールバーを消してfont等の設定
(if window-system
    (progn
      (and (fboundp 'tool-bar-mode) (tool-bar-mode 0))
      (setq initial-frame-alist
	    (append
	     '((width . 98) (height . 53)
	       (left-fringe . 0) (right-fringe . 0)
	       (line-space . "0") (font . "fontset-14"))
	     initial-frame-alist))
      (setq default-frame-alist
	    (append
	     '((width . 98) (height . 53)
	       (left-fringe . 0) (right-fringe . 0)
	       (line-space . "0") (font . "fontset-14"))
	     default-frame-alist))
      ; ホイールマウスを有効にする
      (and (fboundp 'mouse-wheel-mode) (mouse-wheel-mode))
      )
  (menu-bar-mode 0)
  (load "term/bobcat"))

;;; font-lockの設定
(global-font-lock-mode t)
(setq font-lock-maximum-decoration
      '((c-mode . 3)
	(sgml-mode . 3)
	(perl-mode . 3)
	(cperl-mode . 3)
	(asm-mode . 2)
	(sh-mode . 3)
	(emacs-lisp-mode . 3)
	(t . t)))


;;; 起動直後の*scratch* buffer に入る文字列をなくす
(setq initial-scratch-message nil)

;;; ファイルの末尾にあるlocal変数を読んだ時には確認する
(setq enable-local-variables 'query)

;;; カーソルが行頭にあるときに、C-k 1回だけで その行全体が削除されるようにする
(setq kill-whole-line t)

;;; Do not show startup message
;;(setq inhibit-startup-message t)

;;; カーソルの位置が何行何桁目かを表示する
(line-number-mode 1)
(column-number-mode 1)

;;; .save.. というファイルを作らない
(setq auto-save-list-file-name nil)
(setq auto-save-list-file-prefix nil)

;;; 最下行で↓を押しても勝手に行を増やさない
(setq next-line-add-newlines nil)

;;; Eval文を評価する
(put 'eval-expression 'disabled nil)

;;; options-toggle
(and (locate-library "options-toggle") (load "options-toggle"))
;;; filladapt
(and (locate-library "filladapt") (require 'filladapt))

;;; ファイルを書きこむ時のフック
(add-hook 'write-file-hooks
	  (function
	   (lambda ()
	     (trim-eob)
	     (set-lastmodified-tag)
	     ;;(trim-buffer)
	     )))

(defun trim-region (start end)
  "リージョン中の行末の無駄な空白を消去"
  (interactive "r")
  (save-excursion
    (save-restriction
      (narrow-to-region start end)
      (goto-char start)
      (replace-regexp "[ \t]+$" ""))))

(defun trim-eob ()
  "バッファの最後に溜った空行を消去"
  (interactive)
  (save-excursion
    (progn
      (goto-char (point-max))
      (delete-blank-lines)
      nil)))

(defun trim-buffer ()
  "バッファ中の行末の無駄な空白を消去"
  (interactive)
  (save-excursion
    (mark-whole-buffer)
    (trim-region (region-beginning) (region-end))))

(defun set-lastmodified-tag ()
  "Last Modified: という文字列を見付けると新しい日付を挿入する"
  (interactive)
  (let ((tostr (concat "Last Modified: " (current-time-string) ".")))
    (save-excursion
      (goto-char (point-min))
      (while (re-search-forward
	      "\\Last Modified:\\([A-Za-z0-9: ]*\\)?\\." nil t)
	(replace-match tostr nil t)))))

(defun previous-line (arg)
  "bufferの先頭でカーソルを戻そうとしても音をならなくする"
  (interactive "p")
  (condition-case nil
      (line-move (- arg))
    (beginning-of-buffer)))

(defun next-line (arg)
  "bufferの最後でカーソルを動かそうとしても音をならなくする"
  (interactive "p")
  (condition-case nil
      (line-move arg)
    (end-of-buffer)))
;;ただし新規の時をのぞく(^^;;

(defun compile-newer-file (file)
  ".elcがない、あるいは.elより新しい時にcompileする"
  (let* ((el (expand-file-name file))
	 (elc (concat el (if (string-match "\\.el$" el) "c" ".elc"))))
    (when (and (file-exists-p el)
	       (or (not (file-exists-p elc))
		   (file-newer-than-file-p el elc)))
      (save-window-excursion
	(message "Byte-compile %s" el)
	(sit-for 1)
	(byte-compile-file el)))))


;;; auto-mode
(setq auto-mode-alist
      (nconc '(("\\.\\([pP][Llm]\\|al\\)$" . cperl-mode)
	       ("\\.sh$" . sh-mode)
	       ("\\.[ps]?html?$" . html-helper-mode)
	       ("\\.ja$" . html-helper-mode)
	       ("\\.en$" . html-helper-mode)
	       ("\\.sgml$" . sgml-mode)
	       ("\\.xml$" . xml-mode)
	       ("\\.tex$" . yatex-mode)
	       ("\\.sty$" . yatex-mode)
	       ("\\.dtx$" . yatex-mode)
	       ("\\.java$" . java-mode)
	       ("\\.cc$" . c++-mode)
	       ("\\.[ch]$" . c-mode)
	       ("\\.potx?$\\|\\.po$" . po-mode)
	       )
	     auto-mode-alist))


;;; po-mode for Emacs20
(autoload 'po-find-file-coding-system "po-mode")
(modify-coding-system-alist 'file "\\.potx?\\'\\|\\.po\\." 'po-find-file-coding-system)


;;; advices
(defadvice switch-to-buffer (before existing-buffer activate compile)
  "When interactive, switch to existing buffers only, unless given a prefix argument."
  (interactive
   (list (read-buffer "Switch to buffer: "
		      (other-buffer)
		      (null current-prefix-arg)))))


;;; 日付/時刻表示
(setq display-time-24hr-format t)
(setq display-time-format "%m/%d(%a) %R")
(setq display-time-day-and-date t)
(display-time)


;;; saveplace.el
(load "saveplace")
(setq-default save-place t)


;;; dmacro.el - キー操作の繰返し検出 & 実行
(defconst *dmacro-key* "\C-z" "繰返し指定キー")
(global-set-key *dmacro-key* 'dmacro-exec)
(autoload 'dmacro-exec "dmacro" nil t)


;;; text-adjust
(autoload 'text-adjust-codecheck "text-adjust")
(autoload 'text-adjust-hankaku "text-adjust")
(autoload 'text-adjust-kutouten "text-adjust")
(autoload 'text-adjust-space "text-adjust")
(autoload 'text-adjust "text-adjust")
(autoload 'text-adjust-fill-region "text-adjust")
(setq text-adjust-touten-from nil)
(setq text-adjust-kuten-from nil)


;;; lookup
(autoload 'lookup "lookup" nil t)
(autoload 'lookup-region "lookup" nil t)
(autoload 'lookup-pattern "lookup" nil t)

(define-key help-map "o" 'lookup-pattern)
(define-key help-map "l" 'lookup)


;;; Add HTML-helper
(autoload 'html-helper-mode "html-helper-mode" "Yay HTML" t)
(add-hook 'html-helper-mode-hook
          (function (lambda () (set-buffer-file-coding-system 'euc-jp))))
;(setq html-helper-bold-face 'bold)
;(setq html-helper-italic-face 'italic)
;(setq html-helper-underline-face 'underline)
; html-helper-address-string html-helper-new-buffer-template などが入る


;;; w3m
(autoload 'w3m "w3m" "Interface for w3m on Emacs." t)

;;; pcl-cvs
(global-set-key "\C-cu" 'cvs-update)


;;; po-mode
(autoload 'po-mode "po-mode" nil t)
(setq po-auto-replace-revision-date t)
;(setq po-auto-edit-with-msgid t)
; po-default-file-header が入る


;;; C-mode の設定
(setq c-indent-level 4
      c-continued-brace-offset -2
      c-continued-statement-offset 4
      c-argdecl-indent 0
      c-brace-offset -4
      c-label-offset -4)
;; c-basic-offset 2


;;; Add cc-mode
(autoload 'c++-mode  "cc-mode" "C++ Editing Mode" t)
(autoload 'c-mode    "cc-mode" "C Editing Mode" t)
(autoload 'objc-mode "cc-mode" "Objective-C Editing Mode" t)
(and (fboundp 'turn-on-filladapt-mode) (add-hook 'c-mode-hook 'turn-on-filladapt-mode))


;;; Add sh-mode
(autoload 'sh-mode "sh-script" "sh mode" t)


;;; Add sgml-mode
(autoload 'sgml-mode "psgml" "Major mode to edit SGML files." t)
(autoload 'xml-mode "psgml" "Major mode to edit XML files." t)
(setq sgml-catalog-files '("CATALOG" "/usr/local/share/sgml/catalog"))

(setq sgml-set-face t)
(setq sgml-auto-insert-required-elements nil)
(setq sgml-general-insert-case 'lower)
;;; psgml-xpointer
;;(autoload 'sgml-xpointer "psgml-xpointer" nil t)
(setq sgml-markup-faces '((start-tag  . function-name-face)
                          (end-tag    . function-name-face)
                          (comment    . comment-face)
                          (ignored    . comment-face)
                          (pi         . keyword-face)
                          (sgml       . keyword-face)
                          (doctype    . type-face)
                          (entity     . string-face)
                          (shortref   . bold)))


;;; For asm-mode
(setq font-lock-maximum-size
      '((asm-mode . 512000) (t . 256000)))


;;; Add global gtags-mode
(autoload 'gtags-mode "gtags" "" t)


;;; Add java-mode
(autoload 'java-mode "cc-mode" "Java Mode" t)


;;; yatex-modeを起動させる設定
(autoload 'yatex-mode "yatex" "Yet Another LaTeX mode" t)

;;; キーバインド変更
(add-hook 'yatex-mode-load-hook
	  (function
	   (lambda ()
	     (YaTeX-define-begend-key "ba" "align")
	     (YaTeX-define-begend-key "bC" "cases"))))

;; ;;; yatex-modeでだけ句読点を変える
(add-hook 'yatex-mode-hook
	  (lambda ()
	    (require 'skk)
	    (setq skk-kutouten-type 'en)))
;; old setting
;; (add-hook 'yatex-mode-hook
;; 	  (function
;; 	   (lambda ()
;; 	     ;; 野鳥起動時にskkが起動されてなければ起動してしまう
;; 	     (or (boundp 'skk-rom-kana-rule-list) (skk-mode))
;; 	     ;; 一応確認
;; 	     (if (and (boundp 'skk-rom-kana-rule-list)
;; 		      (boundp 'skk-rule-tree)
;; 		      (fboundp 'skk-compile-rule-list))
;; 		 ;; 変換テーブル、木をbuffer localにして変更
;; 		 (progn
;; 		   (make-local-variable 'skk-rom-kana-rule-list)
;; 		   (setq skk-rom-kana-rule-list
;; 			 (append skk-rom-kana-rule-list
;; 				 '(("z=" nil ("≠" . "≠"))
;; 				   (","  nil ("," . ","))  
;; 				   ("."  nil ("." . "."))
;; 				   ("h," nil ("、" . "、"))  
;; 				   ("h." nil ("。" . "。"))
;; 				   )))
;; 		   (make-local-variable 'skk-rule-tree)
;; 		   (setq skk-rule-tree
;; 			 (skk-compile-rule-list
;; 			  skk-rom-kana-base-rule-list skk-rom-kana-rule-list)))
;; 	       (message "Unsupported skk version")))))

;;; 関数補完
(setq YaTeX-math-funcs-list
      '(("s" "sin")
	("as" "arcsin")
	("c" "cos")
	("ac" "arccos")
	("t" "tan")
	("at" "arctan")
	("sh" "sinh")
	("ch" "cosh")
	("th" "tanh")
	("ln" "ln")
	("lo" "log")))
(setq YaTeX-math-key-list-private
      '(("'" . YaTeX-math-funcs-list)))

;;; 漢字コードの設定
;;; 1 = Shift JIS, 2 = JIS, 3 = EUC
;;; defaultはそれぞれ2
(setq YaTeX-kanji-code 3)
;;(setq yahtml-kanji-code 3)

;;; printer の設定
;;(setq dviprint-command-format "jdvi2kps %f %t %s | lpr -v -Plp -#1")
(setq dviprint-command-format "dvips %s")

(setq tex-command "platex")
;;; プレビューワ、プリンタの設定
(setq dvi2-command "xdvi -geometry 900x1000+200+0 -s 6")


;;; mgp-mode
(setq auto-mode-alist
      (cons '("\\.mgp?\\'" . mgp-mode) 
	    auto-mode-alist))
(autoload 'mgp-mode "mgp-mode")
(setq mgp-options "-g 800x600")
(setq mgp-window-height 6)
(cond 
 ((= emacs-major-version 19)     ;; Emacs 19, Mule 2.3
  (setq mgp-mode-hook
	(function (lambda () 
		    (set-file-coding-system '*iso-2022-jp*unix)))))
 ((= emacs-major-version 20)     ;; Emacs 20
  (setq mgp-mode-hook
	(function (lambda ()
		    (set-buffer-file-coding-system 'iso-2022-jp-unix))))))


;;; Enable liece (Initial file is ~/.liece/init.el)
(autoload 'liece "liece" "liece" t)


;;; Enable namazu client
(autoload 'namazu "namazu" nil t) 


;;; browse-url の設定
(autoload 'browse-url-at-point "browse-url" nil t)
(autoload 'browse-url-at-mouse "browse-url" nil t)
(autoload 'browse-url-of-buffer "browse-url" nil t)
(autoload 'browse-url-of-file "browse-url" nil t)
(autoload 'browse-url-of-dired-file "browse-url" nil t)

(setq browse-url-browser-function 'browse-url-gnome-moz)
(autoload 'w3m-browse-url "w3m" "Ask a WWW browser to show a URL." t)
(defun w3m-browse-url-at-point (&optional arg)
  (interactive)
  (let ((browse-url-browser-function
	 (if (eq major-mode 'w3m-mode)
	     'browse-url-gnome-moz
	   'w3m-browse-url)))
    (browse-url-at-point arg)))
(global-set-key "\C-x\C-m" 'w3m-browse-url-at-point)


;;; Enable x-face
(cond
 ((eq emacs-major-version 21)
  ;; You may have no need to use the following one line if you
  ;; always use T-gnus 6.14.5 revision 07 and later.
  (autoload 'x-face-decode-message-header "x-face-e21")
  ;;
  (autoload 'x-face-insert "x-face-e21" nil t)
  (autoload 'x-face-save "x-face-e21" nil t)
  (autoload 'x-face-show "x-face-e21" nil t)
  (autoload 'x-face-turn-off "x-face-e21")
  ;;
  ;; Show X-Face images when `x-face-insert' is done.
  (setq x-face-auto-image t)
  (setq x-face-image-file-directory "~/images/x-faces")
  ;;
  ;; If a file name has no directory component, it should be
  ;; found in the directory which is specified by the option
  ;; `x-face-image-file-directory'.
  (setq x-face-default-xbm-file "e.xbm")
  (setq x-face-add-x-face-version-header t))
 (t
  (autoload 'x-face-encode "x-face" "Generate X-Face string(s) from xbm file." t)
  (autoload 'x-face-insert "x-face" "Insert X-Face fields." t)
  (autoload 'x-face-save "x-face" "Save X-Face fields to files." t)
  (autoload 'x-face-view "x-face" "View X-Face fields." t)
  (autoload 'x-face-ascii-view "x-face" "View X-Face fields as ascii pictures." t)
  ;;(setq x-face-inhibit-loadup-splash nil)
  (setq x-face-image-file-directory "~/images/x-faces")
  ;;(setq x-face-image-file-directory-for-save "~/images/x-faces")
  (setq x-face-add-x-face-version-header t)))


;;; Enable Mew
(autoload 'mew "mew" nil t)
(autoload 'mew-send "mew" nil t)
(setq mew-icon-directory "/usr/share/emacs/21.2.50/etc/Mew")
(compile-newer-file (expand-file-name "~/.mew.el"))


;;; Set shortcut keys
(global-set-key "\C-x\C-g" 'goto-line)
(global-set-key "\C-xc" 'compile)
(global-set-key "\C-t" 'scroll-down)
;;; assign transpose-chars C-,  hmm...
(global-set-key [67108908] 'transpose-chars)
(global-set-key "\C-cl" 'font-lock-fontify-buffer)
(global-set-key "\C-c>" 'comment-region)
(define-key help-map "g" 'apropos)
(global-set-key "\C-xm" 'mew)
(global-set-key "\C-c\C-i" 'liece)


;;; c-sigシステム用の設定
(autoload 'add-signature "c-sig" "c-sig" t)
(autoload 'delete-signature "c-sig" "c-sig" t)
(autoload 'insert-signature-eref "c-sig" "c-sig" t)
(autoload 'insert-signature-automatically "c-sig" "c-sig" t)
(autoload 'insert-signature-randomly "c-sig" "c-sig" t)
(random t)
;;(setq sig-insert-end t)
(setq sig-separator "\n")
(setq sig-make-backup-files nil)
;;; signature内の文字列の自動変換を有効にする
(setq sig-replace-string t)

;;; shortcut for c-sig
(global-set-key "\C-c\C-a" 'add-signature)


;;; Enable SKK
;(require 'skk-setup)
(setq skk-byte-compile-init-file t)
(add-hook 'isearch-mode-hook
          (function (lambda ()
                      (and (boundp 'skk-mode) skk-mode
			   (skk-isearch-mode-setup)))))
(add-hook 'isearch-mode-end-hook
          (function (lambda ()
            (and (featurep 'skk-isearch) (skk-isearch-mode-cleanup)))))

;;;; End of .emacs

(C)Copyright 2002 by Sian <sian@big.or.jp>
Last modified: Thu Feb 26 23:03:10 JST 2004