Emacsの設定ファイル .emacs

Emacsの設定ファイルです。普通の環境ではこのままでは動かないと思います。過去の資産がいっぱいで僕もよくわかりません。
ファイル: .emacs

;; -*- emacs-lisp -*-
;; ===================
;;  Emacs config file
;; ===================
;; 
;;  $Id:$
;;

(defmacro eval-safe (&rest body)
  `(condition-case err
       (progn ,@body)
     (error (message "[eval-safe] %s" err))))

;; key binding...
(global-unset-key "\C-q") 
(global-set-key "\C-q\C-q" 'quoted-insert)
(global-set-key "\C-q\C-w" 'memo-tmp-open-today)
(global-set-key "\C-xn"	   'next-error)
(global-set-key "\C-xM"    'memo)
(global-set-key "\C-xm"    'memo-open)
(global-set-key "\C-h"	   'backward-delete-char-untabify)
(global-set-key "\C-u"	   'advertised-undo)
(global-set-key "\M-c"	   'compile)
(global-set-key "\M-u"	   'universal-argument)

;; misc settings...
(set-language-environment 'Japanese)
(set-terminal-coding-system 'euc-jp-unix)
(set-keyboard-coding-system 'euc-jp-unix)
(set-buffer-file-coding-system 'euc-jp-unix)

(setq compile-command "make")
;(setq compilation-window-height 8)
(setq fill-column -1)
(setq kill-whole-line t)
(setq scroll-step 1)
(setq blink-matching-delay 0.2)
(setq inhibit-startup-message t)
(transient-mark-mode t)
(menu-bar-mode 0)
(tool-bar-mode 0)
(scroll-bar-mode -1)
(fset 'yes-or-no-p 'y-or-n-p)
(setq mode-line-inverse-video t)
(setq mouse-yank-at-point t)
(setq visible-bell t)
(setq ring-bell-function '(lambda ()))

(setq font-lock-support-mode 'lazy-lock-mode)
(global-font-lock-mode t)

(if window-system
    (setq default-frame-alist
	  (append (list '(foreground-color . "white")
			'(background-color . "black")
			'(border-color     . "black")
			'(mouse-color      . "white")
			'(cursor-color     . "light green")
			'(width            .  116)
			'(height           .   45)
			'(top              .   20)
			'(left             .    1))
		  default-frame-alist)))

(set-face-foreground 'font-lock-builtin-face	   "red")
(set-face-foreground 'font-lock-comment-face	   "red")
(set-face-foreground 'font-lock-constant-face	   "green")
(set-face-foreground 'font-lock-function-name-face "red")
(set-face-foreground 'font-lock-keyword-face	   "cyan")
(set-face-foreground 'font-lock-string-face	   "yellow")
(set-face-foreground 'font-lock-type-face	   "cyan")
(set-face-foreground 'font-lock-variable-name-face "cyan")
(set-face-foreground 'font-lock-warning-face	   "red")
(if window-system
    (set-face-foreground 'modeline		   "yellow")
  (set-face-foreground 'modeline		   "blue"))

(set-face-background 'font-lock-builtin-face	   "black")
(set-face-background 'font-lock-comment-face	   "black")
(set-face-background 'font-lock-constant-face	   "black")
(set-face-background 'font-lock-function-name-face "black")
(set-face-background 'font-lock-keyword-face	   "black")
(set-face-background 'font-lock-string-face	   "black")
(set-face-background 'font-lock-type-face	   "black")
(set-face-background 'font-lock-variable-name-face "black")
(set-face-background 'font-lock-warning-face	   "black")
(if window-system
    (set-face-background 'modeline		   "blue")
  (set-face-background 'modeline		   "yellow"))

(set-face-bold-p     'font-lock-builtin-face	   t)
(set-face-bold-p     'font-lock-comment-face	   t)
(set-face-bold-p     'font-lock-constant-face	   t)
(set-face-bold-p     'font-lock-function-name-face t)
(set-face-bold-p     'font-lock-keyword-face	   t)
(set-face-bold-p     'font-lock-string-face	   t)
(set-face-bold-p     'font-lock-type-face	   t)
(set-face-bold-p     'font-lock-variable-name-face t)
(set-face-bold-p     'font-lock-warning-face	   t)
(set-face-bold-p     'modeline			   t)

(setq dabbrev-case-fold-search nil)
(setq dabbrev-abbrev-char-regexp "\\w\\|\\s_")

(setq auto-mode-alist      (append
       '(("\\.rb$"     . ruby-mode)
	 ("\\.cgi$"    . ruby-mode))
       auto-mode-alist))

(add-hook 'minibuffer-setup-hook
	  '(lambda ()
	     (local-set-key "\C-w" 'backward-kill-word)))

(server-start)

;; indent-and-next-line...
(global-set-key "\M-n" 'indent-and-next-line)
(defun indent-and-next-line ()
  (interactive)
  (indent-according-to-mode)
  (next-line 1))

;; insert-clip...
(global-set-key "\C-xi" 'insert-clip)
(defun insert-clip()
  (interactive)
  (insert-file "~/a"))

;; insert-arrow...
(global-set-key "\M-'" 'insert-arrow)
(defun insert-arrow ()
  (interactive)
  (insert "->"))

;; buffer-menu...
(add-hook
 'buffer-menu-mode-hook
 '(lambda ()
    (define-key Buffer-menu-mode-map "j" 'next-line)
    (define-key Buffer-menu-mode-map "k" 'previous-line)))
(iswitchb-default-keybindings)

;; dired...
(add-hook
 'dired-mode-hook
 '(lambda ()
    (define-key dired-mode-map "U" 'dired-up-directory)
    (define-key dired-mode-map "J" 'dired-next-line)
    (define-key dired-mode-map "K" 'dired-previous-line)
    (define-key dired-mode-map "j" 'dired-next-line-and-advertised-find-file)
    (define-key dired-mode-map "k" 'dired-previous-line-and-advertised-find-file)))
(setq dired-listing-switches "-l")

(defun dired-next-line-and-advertised-find-file ()
  (interactive)
  (dired-next-line 1)
  (dired-display-file))

(defun dired-previous-line-and-advertised-find-file ()
  (interactive)
  (dired-previous-line 1)
  (dired-display-file))

;; minibuffer...
(add-hook
 'minibuffer-setup-hook
 '(lambda ()
    (define-key minibuffer-local-completion-map "\C-p" 'switch-to-completions)
    (define-key completion-list-mode-map [tab] 'next-completion)
    (define-key completion-list-mode-map "j" 'next-line)
    (define-key completion-list-mode-map "k" 'previous-line)
    (define-key completion-list-mode-map "h" 'previous-completion)
    (define-key completion-list-mode-map "l" 'next-completion)))

;; cc-mode...
(add-hook
 'c-mode-common-hook
 '(lambda ()
    (c-set-style "CC-MODE")
    (setq tab-width 4)
    (define-key c-mode-map "\C-cp"  'c-insert-printf)
    (define-key c-mode-map "\C-cf"  'c-insert-for)
    (modify-syntax-entry ?_ "w")
    (font-lock-add-keywords 'c-mode '("\\<\\(TRUE\\|FALSE\\)\\>"))
    (setq c-font-lock-extra-types
	    '("FILE" "\\sw+_t"))))

;; ruby-mode...
(autoload 'ruby-mode "ruby-mode" "Mode for editing ruby source files")
(setq interpreter-mode-alist
      (append '(("^#!.*ruby" . ruby-mode)) interpreter-mode-alist))

;; refe
(require 'refe)

;; navi2ch
(require 'navi2ch)
(setq navi2ch-net-save-old-file-when-aborn nil)
(setq navi2ch-article-auto-range nil)

;; mwheel
(mwheel-install)

;; trim-buffer...
(eval-safe (load "trim-buffer"))

;; auto-save-buffers...
(autoload 'auto-save-buffers "auto-save-buffers")
(run-with-idle-timer 0.5 t 'auto-save-buffers)

;; chmod +x
(autoload 'make-file-executable "chmodx")
(add-hook 'after-save-hook 'make-file-executable)

;; dabbrev
(eval-safe 
 (require 'dabbrev-highlight)
 (load "dabbrev-ja"))

(define-key text-mode-map "\C-cb" 'hatena-insert-code-block)
(define-key text-mode-map "\C-cl" 'text-insert-line)

;; skk
(eval-safe 
 (require 'skk-setup)
 (global-set-key "\C-xj" 'skk-mode)
 (setq skk-server-host "localhost")
 (setq skk-large-jisyo nil)
 (setq skk-use-color-cursor nil)
 (load "skk-tiny-azik"))

;; memo
(setq user-full-name "TANAKA Shin-ya")
(setq user-mail-address "zstanaka@archer.livedoor.com")

(setq memo-tmp-dirname "~/memo/")
(setq memo-tmp-format "%Y/h%m-%d.txt")
(setq memo-filename "~/memo/ch2004.txt")

(add-hook 'change-log-mode-hook 
          (function 
	   (lambda ()
	     (set (make-local-variable 'add-log-time-format) 
		  'add-log-iso8601-time-string-with-weekday))))

;; misc function
(load "misc")

(put 'upcase-region 'disabled nil)
;; end

;; browse-url
(setq thing-at-point-url-path-regexp
  "[^]\t\n \"'()<>[^`{}]*[^]\t\n \"'()<>[^`{}.,;]+")

(setq thing-at-point-url-regexp
  (concat
   "\\<\\(h?t?tps?://\\|ftp://\\|gopher://\\|"
   "telnet://\\|wais://\\|file:/\\|s?news:\\|mailto:\\)"
   thing-at-point-url-path-regexp))

(setq browse-url-browser-function '(("." . browse-url-firefox)))
(setq browse-url-firefox-program "firefox-linux")
(defun browse-url-firefox (url &optional new-window)
  (interactive (browse-url-interactive-arg "URL: "))
  (if (string-match "^t?tp://" url)
      (setq url (concat "http://" (substring url (match-end 0)))))
  (if (string-match "^t?tps://" url)
      (setq url (concat "https://" (substring url (match-end 0)))))
  (start-process (concat browse-url-firefox-program url) nil 
		 browse-url-firefox-program "-remote" 
		 (concat "openurl(" url ", new-tab)")))

(put 'narrow-to-region 'disabled nil)

;; hatena
(defun hatena-convert-url-to-id ()
  "カーソル付近のURLをはてなID記法に変換する。"
  (interactive)
  (let ((bounds (bounds-of-thing-at-point 'url)))
    (if bounds
	(let* ((beg (car bounds))
	       (end (cdr bounds))
	       (urls (split-string (buffer-substring beg end) "/"))
	       (user (nth 3 urls))
	       (date (nth 4 urls))
	       (item (nth 5 urls))
	       (idstr (concat "id:" user)))
	  (if (and date (not (string-equal date "")))
	      (setq idstr (concat idstr ":" date)))
	  (if (and item (not (string-equal item "")))
	      (setq idstr (concat idstr ":" item)))
	  (delete-region beg end)
	  (insert idstr)))))

;; autoinsert
(setq  auto-insert-directory "~/.emacs.d/template/" )
(load "autoinsert" t)
(setq auto-insert-alist 
      (append '(("\\.rb" . "foo.rb")
		("[Mm]akefile" . "Makefile"))
	      auto-insert-alist ))
(add-hook 'find-file-hooks 'auto-insert)