メモ

;;;
;;; automatically byte compile .emacs.el
;;;
(defvar init "~/.emacs.el")
(and (boundp 'init)
   (stringp init)
   (file-newer-than-file-p init "~/.emacs.elc")
   ;;(delete-file "~/.emacs.elc")
   (let ((mode-line-format "")
         (mode-line-inverse-video nil))
     (message "Wait! Your %s needs recompiling..." init)
     (sit-for 1)
     (byte-compile-file init)
     t)
   (kill-emacs))

;;;
;;; indent setting
;;;
(put 'if 'lisp-indent-function 2)
(put 'dotimes 'lisp-indent-function 1)
(put 'dolist 'lisp-indent-function 1)
(put 'instance 'lisp-indent-function 1)
(put 'send 'lisp-indent-function 1)
(put 'setq 'lisp-indent-function 1)

;;;
;;; display time, line, column in mode line
;;;
(display-time-mode 1)
(line-number-mode 1)
(column-number-mode 1)

;;;
;;; no use alarm
;;;
(setq visible-bell t)

;;;
;;; no use startup message
;;;
(setq inhibit-startup-message t)

;;;
;;; global-set-key
;;;
(global-set-key "\C-h" 'backward-delete-char)
(global-set-key "\M-g" 'goto-line)
(global-set-key "\C-c\C-c" 'comment-region)

(define-key ctl-x-map "p"
#'(lambda (arg) (interactive "p") (other-window (- arg))))

;;;
;;; always turn on syntax highlighting
;;;
(global-font-lock-mode t)

;;;
;;; Time Stamp
;;;
(if (not (memq 'time-stamp write-file-hooks))
  (setq write-file-hooks
        (cons 'time-stamp write-file-hooks)))
(defun timestamp-insert ()
(interactive)
(insert (current-time-string)))
(global-set-key "\C-c\C-d" 'timestamp-insert)

;;;
;;; japanese mode
;;;
;;(select-input-method "MW32-IME")
;(toggle-input-method)
;(inactivate-input-method)
(set-language-environment "Japanese")
(setq default-input-method "MW32-IME")
(mw32-ime-initialize)
(global-unset-key "\C-\\")
(global-set-key "\C-\\" 'toggle-input-method)
(setq-default mw32-ime-mode-line-state-indicator "[--]")
(setq mw32-ime-mode-line-state-indicator-list '("[--]" "[あ]" "[--]"))

;;;
;;; change cursor color when the imput language is changed
;;; (cursor-type box, bar )
;;;
(add-hook 'mw32-ime-on-hook
        (lambda () (set-cursor-color "cyan"))) ; ON
(add-hook 'mw32-ime-off-hook
        (lambda () (set-cursor-color "white"))) ; OFF

;;;
;;; turn off IME when y-or-n, yes-or-no
;;;
(wrap-function-to-control-ime 'y-or-n-p nil nil)
(wrap-function-to-control-ime 'yes-or-no-p nil nil)

;;;
;;; use Cygwin shell (bash)
;;;
(add-to-list 'exec-path (expand-file-name "c:/cygwin/bin"))
(setq shell-file-name "c:/cygwin/bin/bash.exe")
(setq explicit-shell-file-name shell-file-name)
(setq shell-command-option "-c")
(modify-coding-system-alist 'process ".*sh\\.exe" 'undecided-unix)

;(add-hook 'c-mode-common-hook (c-set-style '"stroustrup"))
;(add-hook 'c++-mode-common-hook (c-set-style '"stroustrup"))

;;;
;;; set color in shell mode
;;;
(autoload 'ansi-color-for-comint-mode-on "ansi-color"
"Set `ansi-color-for-comint-mode' to t." t)
(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)

;;;
;;; font setting
;;;
(create-fontset-from-request "private-fontset"
                           '((width . 8)
                             (height . 14)
                             (fixed . t)
                             (italic . nil))
;; '((family . "MS ゴシック")
;; (family . "OCRB")))
                           '((family . "Osaka-等幅")
                             (family . "Bitstream Vera Sans Mono")))
;;(family . "Courier New")))

;;;
;;; frame setting
;;;
;; (setq default-frame-alist
;; (append (list '(foreground-color . "black")
;; '(background-color . "LemonChiffon")
;; '(border-color . "black")
;; '(mouse-color . "white")
;; '(cursor-color . "black")
;; '(width . 80)
;; '(height . 67)
;; '(font . "private-fontset")
;; )
;; default-frame-alist))
(setq default-frame-alist
    (append (list '(foreground-color . "white")
                  '(background-color . "black")
                  '(border-color . "white")
                  '(mouse-color . "white")
                  '(cursor-color . "white")
                  '(width . 80)
                  '(height . 67)
                  '(font . "private-fontset")
                  )
            default-frame-alist))

;;;
;;; hide mouse cursor
;;;
(setq w32-hide-mouse-on-key t)

;;;
;;; high-speed buffer switching
;;;
(setq my-ignore-buffer-list
    '("*Help*" "*Compile-Log*" "*Mew completions*" "*Completions*" "*Shell Command Output*" "*Apropos*" "*Buffer List*" "*Backtrace*" "*Messages*"))
(defun my-visible-buffer (blst)
(let ((bufn (buffer-name (car blst))))
  (if (or (= (aref bufn 0) ? ) (member bufn my-ignore-buffer-list))
      (my-visible-buffer (cdr blst))(car blst))))
(defun my-grub-buffer ()
(interactive)
(switch-to-buffer (my-visible-buffer
                   (reverse (buffer-list)))))
(defun my-bury-buffer ()
(interactive)
(let ((nbuf (my-visible-buffer (cdr (buffer-list)))))
  (bury-buffer)
  (switch-to-buffer nbuf)))
(global-set-key "\C-xp" 'my-bury-buffer)
(global-set-key "\C-xn" 'my-grub-buffer)

;;;
;;; show match paren
;;;
(show-paren-mode t)
;(show-paren-match-face "")
;(show-paren-mismatch-face "")
(setq show-paren-style 'mixed)
(set-face-background 'show-paren-match-face "gray20")
(set-face-foreground 'show-paren-match-face "SkyBlue")

;;;
;;; go to the matching paren
;;;
(defun match-paren (arg)
"Go to the matching parenthesis if on parenthesis."
(interactive "p")
(cond ((looking-at "\\s\(") (forward-list 1) (backward-char 1))
      ((looking-at "\\s\)") (forward-char 1) (backward-list 1))
      )
)
(global-set-key "\C-q" 'match-paren)

;;;
;;; truncate lines in right end
;;;
(setq truncate-lines nil)
(setq truncate-partial-width-windows nil)

;;;
;;; hilight line
;;;
;;(setq hl-line-face 'underline)
(global-hl-line-mode t)
(defface my-hl-line-face
'((((class color)
    (background dark))
   ;;(:background "DarkSlateBlue" t))
   (:background "gray15" t))
  (((class color)
    (background light))
   (:background "ForestGreen" t))
  (t (:bold t)))
"*Face used by hl-line.")
(setq hl-line-face 'my-hl-line-face)

;;;
;;; tab width
;;;
;;(setq-default tab-width 4)

;;; Mule-UCS setting
(require 'un-define)
(require 'jisx0213)

;;;
;;; hide tool-bar
;;;
(tool-bar-mode nil)

;;;
;;; set color in selecting region
;;;
(setq-default transient-mark-mode t)

;;;
;;; w3m
;;;
(require 'w3m-load)

;;;
;;; mew ; setting file is .mew.el
;;;
(autoload 'mew-read "mew" nil t)
(autoload 'mew-send "mew" nil t)
(define-key ctl-x-map "r" 'mew)
(define-key ctl-x-map "m" 'mew-send)
(autoload 'mew "mew" nil t)
(autoload 'mew-send "mew" nil t)

;;;
;;; migemo
;;;
(setq migemo-directory "c:/cygwin/usr/local/share/migemo")
(setq migemo-options '("-S" "c:/cygwin/usr/local/bin/migemo" "-t" "emacs" "-i" "\a"))
(load-library "migemo")

;;;
;;; yatex
;;;
;; (setq auto-mode-alist
;; (cons (cons "\\.tex$" 'yatex-mode) auto-mode-alist))
;; (autoload 'yatex-mode "yatex" "Yet Another LaTeX mode" t)
;; (setq load-path (cons "c:/Meadow/site-lisp/yatex" load-path))

;;;
;;; EusLisp
;;;
(setq auto-mode-alist
(cons (cons "\\.l$" 'euslisp-mode) auto-mode-alist))
(setq interpreter-mode-alist
(cons (cons "euslisp" 'euslisp-mode) interpreter-mode-alist))
(autoload 'euslisp-mode "euslisp-mode" "EusLisp editing mode" t)

;;;
;;; Python mode
;;;
(setq auto-mode-alist
(cons (cons "\\.py$" 'python-mode) auto-mode-alist))
(setq interpreter-mode-alist
(cons (cons "python" 'python-mode) interpreter-mode-alist))
(autoload 'python-mode "python-mode" "Python editing mode" t)
最終更新:2009年11月19日 06:43