;;;; -*- mode: lisp-interaction; syntax: elisp; coding: iso-2022-7bit -*- ;;; for emacs20(UNIX) ;; Time-stamp: <2003/12/26 18:42:23> ; Setting for Japanese (set-language-environment "Japanese") (set-frame-font "fontset-standard") ; load-path ;(setq load-path (cons (expand-file-name "~/lisp") load-path)) ;;; font-lock$B$N@_Dj(B (if window-system (progn (setq font-lock-support-mode 'lazy-lock-mode) (global-font-lock-mode t))) (setq font-lock-support-mode 'lazy-lock-mode) ;; $B=i4|%U%l!<%`$N@_Dj(B ; (setq default-frame-alist ; (append (list '(foreground-color . "black") ; '(background-color . "lemonchiffon") ; '(border-color . "black") ; '(mouse-color . "white") ; '(cursor-color . "black") ; '(width . 119) ; '(height . 59) ; '(top . 20) ; '(left . 200)) ; default-frame-alist)) ; display mode line (line-number-mode t) (column-number-mode t) (display-time) ; scroll steps (setq-default scroll-step 1) ; .txt $B$r<+F0E*$K(B text-mode $B$K$9$k!#(B (setq auto-mode-alist (cons (cons "\\.txt$" 'text-mode) auto-mode-alist)) ; .c $B$r<+F0E*$K(B c-mode $B$K$9$k!#(B (setq auto-mode-alist (cons (cons "\\.c$" 'c-mode) auto-mode-alist)) ; .cpp $B$r<+F0E*$K(B c++-mode $B$K$9$k!#(B (setq auto-mode-alist (cons (cons "\\.cpp$" 'c++-mode) auto-mode-alist)) ; .h $B$r<+F0E*$K(B c-mode $B$K$9$k!#(B (setq auto-mode-alist (cons (cons "\\.h$" 'c-mode) auto-mode-alist)) ; Makefile $B$r<+F0E*$K(B makefile-mode $B$K$9$k!#(B (setq auto-mode-alist (cons (cons "\\Makefile$" 'makefile-mode) auto-mode-alist)) ;; $B%P%C%/%"%C%W%U%!%$%k(B(filename~)$B$N@8@.(B (setq make-backup-files nil) ;; $B%*!<%H%;!<%V%U%!%$%k(B(#filename#)$B$N@8@.(B (setq auto-save-default nil) ;; $B%j!<%8%g%s$N%O%$%i%$%H(B (transient-mark-mode 1) ;; $B%?%V$NI}$N@_Dj(B (setq-default tab-width 8) ;; $B:G=*9T$G2~9TL58z(B (setq next-line-add-newlines nil) ; $B%V%C%/%^!<%/$N@_Dj(B ; $B%=!<%H%U%i%0$r(B nil $B$K$9$k$H!"%j%9%H$,:n$C$?=g$KI=<($5$l$k!#(B (setq bookmark-sort-flag nil) ; $B%-!<%P%$%s%I(B (global-set-key "\C-x<" 'bookmark-set) (global-set-key "\C-x>" 'bookmark-jump) (global-set-key "\C-x/" 'bookmark-delete) (global-set-key "\C-x\\" 'list-bookmarks) ; $B%V%C%/%^!<%/%U%!%$%kL>$N;XDj(B ;(setq bookmark-default-file "~/bookmark.bmk") ; XEmacs (setq bookmark-file "~/bookmark.bmk") ; Mule ;window$BJ,3d(B(C-x 2 , C-x 3)$B$7$?>l9g$K!"%&%#%s%I%&%5%$%:$r(BSHIFT + $B%+!<%=%k(B ;$B%-!<$GJQ99$G$-$k$h$&$K$9$k!#(B (define-key global-map [S-left] 'shrink-window-horizontally) (define-key global-map [S-right] 'enlarge-window-horizontally) (define-key global-map [S-up] 'shrink-window) (define-key global-map [S-down] 'enlarge-window) ;;; grep$B$N=i4|CM$rJQ99(B ;;; bash$B$r;HMQ;~!$0J2<$N$h$&$K$9$k$H!$;XDj%G%#%l%/%H%j(B(path)$B0J2<$N;XDj3HD%;R(B(*.$B2?$H$+(B)$B$KBP$7$F(Bgrep$B2DG=(B (setq grep-command "for i in *.asm *.inc *.[hc];do find path -name \"$i\" -print;done|xargs grep -n -i ") ; C-TAB$B$r%$%s%G%s%H$G$J$/!"(BTAB$B$H$7$FA^F~(B (global-unset-key [C-tab]) (global-set-key [C-tab] 'tab-to-tab-stop) ;; $BBP1~$9$k%+%C%3(B-$B%3%C%+$X%8%c%s%W(B ;; $B%+%C%3>e$G(B "%" $B$r2!$9$HBP1~$9$k%+%C%3$X%8%c%s%W$9$k!#(B (define-key emacs-lisp-mode-map "%" 'match-paren) (global-set-key "%" 'match-paren) (defun match-paren (arg) "Go to the matching parenthesis if on parenthesis otherwise insert %." (interactive "p") (cond ((looking-at "\\s\(") (forward-list 1) (backward-char 1)) ((looking-at "\\s\)") (forward-char 1) (backward-list 1)) (t (self-insert-command (or arg 1))))) ;;;;;$B8!:w$K$*$$$F!$BgJ8;z!&>.J8;z$N6hJL$7$J$$!%(B (setq-default case-fold-search t) ;; buffer list$BI=<(8e%+!<%=%k$r$=$3$K0\F0$9$k!#(B (define-key ctl-x-map "\C-b" 'buffer-menu) ; $B%U%!%$%kL>Ey$NJd40;~$KBgJ8;z>.J8;z$N6hJL$r(B don't care (setq-default completion-ignore-case t) ; comment/uncomment-regeon ; C-x ; $B$G%3%a%s%H%"%&%H(B ; C-x : $B$G%3%a%s%H$r$O$:$9(B (global-set-key "\C-x;" 'comment-region) (fset 'uncomment-region "\C-u\C-[xcomment-region\C-m") (global-set-key "\C-x:" 'uncomment-region) ;; c-macro-expand $B$G;HMQ$9$k%3%s%Q%$%i$r;XDj(B (setq c-macro-preprocessor "cpp -C -E -I./include") ;; $B%3%s%Q%$%k%&%#%s%I%&$N9T?t$r;XDj(B (setq compilation-window-height 10) (setq completion-base-size 10) ; $B4X?tL>I=<($rM-8z2=(B (which-function-mode 1) ; $BBP1~$9$k3g8L$r6/D4I=<((B (show-paren-mode) ; complete-symbol $B$N%-!<%P%$%s%I(B (global-set-key [S-tab] 'complete-symbol) ;;; ;;; $B%P%C%U%!@Z$jBX$($rJXMx$K(B ;;; $B%_%K%P%C%U%!$KI=<(!"Lp0u$GA*Br!"A*Br%P%C%U%!$rI=<((B ;;; $B$3$l$J$7$G$O!"@8$-$F$$$1$J$$(B ;;; (require 'iswitchb) (iswitchb-default-keybindings) (add-hook 'iswitchb-define-mode-map-hook 'iswitchb-my-keys) (defun iswitchb-my-keys () "Add my keybindings for iswitchb." (define-key iswitchb-mode-map [right] 'iswitchb-next-match) (define-key iswitchb-mode-map [left] 'iswitchb-prev-match) (define-key iswitchb-mode-map "\C-f" 'iswitchb-next-match) (define-key iswitchb-mode-map " " 'iswitchb-next-match) (define-key iswitchb-mode-map "\C-b" 'iswitchb-prev-match) ) (defadvice iswitchb-exhibit (after iswitchb-exhibit-with-display-buffer activate) ; "$BA*Br$7$F$$$k(B buffer $B$r(B window $B$KI=<($7$F$_$k!#(B" (when iswitchb-matches (select-window (get-buffer-window (cadr (buffer-list)))) (iswitchb-visit-buffer (get-buffer (car iswitchb-matches))) (select-window (minibuffer-window)))) ;;; ;;; $B%a%K%e!<$+$i%P%C%U%!$r@Z$jBX$($k(B ;;; (msb-mode 1) ;;;$B%?%$%`%9%?%s%W$N<+F099?7(B ;;; help-for-help v time-stamp-format$B$G%U%)!<%^%C%H3NG'2DG=(B (setq time-stamp-line-limit 10000) (setq write-file-hooks (cons 'time-stamp write-file-hooks)) (setq time-stamp-format "%04y/%02m/%02d %02H:%02M:%02S") (defun insert-date() "$B8=:_$N;~9o$r8=%+!<%=%k0LCV$KA^F~$9$k(B" (interactive) (insert (current-time-string))) (global-set-key "\C-xt" 'insert-date) (defvar format-time-string "%Y-%m-%d %T%Z") ;;; ;;; $B%_%K%P%C%U%!$r<+F03HD%(B ;;; (resize-minibuffer-mode 1) ;;; ;;; $B%b!<%IL>I=<($rC;$/(B ;;; ;; Encoded-kb $B$O$$$i$J$$(B (eval-after-load "encoded-kb" '(setcar (cdr (assq 'encoded-kbd-mode minor-mode-alist)) "")) ;; Isearch $B$OI=<($7$J$/$F$h$$(B (add-hook 'isearch-mode-hook '(lambda () (setcar (cdr (assq 'isearch-mode minor-mode-alist)) ""))) ;; Texinfo $B$bD9$$(B (add-hook 'texinfo-mode-hook '(lambda () (setq mode-name "Texi"))) ;; scratch $B%P%C%U%!$N(B Lisp Interaction $B$bD9$$(B (add-hook 'lisp-interaction-mode-hook '(lambda () (setq mode-name "Lisp-Int"))) ;; Emacs-Lisp $B$bD9$$(B (add-hook 'emacs-lisp-mode-hook '(lambda () (setq mode-name "Elisp"))) ;;; ;;; buffer-list$B$r9J$j9~$`(B ;;; (defun Buffer-menu-grep (str) (interactive "sregexp:") (goto-char (point-min)) (let (lines) (forward-line 2) (setq lines (buffer-substring (point-min) (point))) (while (re-search-forward str nil t) (let ((bol (progn (beginning-of-line) (point))) (eol (progn (forward-line) (point)))) (setq lines (concat lines (buffer-substring bol eol))))) (let ((buffer-read-only nil)) (erase-buffer) (insert lines)))) (define-key Buffer-menu-mode-map "G" 'Buffer-menu-grep) ;;; ;;; buffer-list$B$r%=!<%H(B ;;; (defun my-sort-buffer-by (cbuf slst) ;; bury-buffer $B$r;H$C$F!"%+%l%s%H%P%C%U%!$,@hF,$KMh$k$h$&$K%=!<%H$9$k(B (cond ((eq slst '()) '()) ((eq cbuf (car slst)) (my-sort-buffer-by cbuf (reverse (cdr slst)))) (t (bury-buffer (car slst)) (my-sort-buffer-by cbuf (cdr slst))))) (defun my-sort-buffer-by-name (x y) (if (or (buffer-file-name y) (buffer-file-name x)) ;; $B$I$A$i$+FC;XDj;~$N%R%9%H%j$r=i4|2=(B ;;; ;(setq file-name-history '("~/" )) ;;; $B%a%K%e!<%P!<$r>C$9(B ;(menu-bar-mode -1) ;;; Cation$B@_Dj(B($B%P%C%U%!L>$rI=<((B) (setq frame-title-format "%b") ;; $B%+!<%=%k0LCV$N%U%'!<%9$rD4$Y$k4X?t(B (defun describe-face-at-point () "Return face used at point." (interactive) (message "%s" (get-char-property (point) 'face))) ;; $B%U%'%$%9$N0lMw$O(I$$B0J2<$N$h$&$K$9$l$PI=<($G$-$k(B ;; M-x list-faces-display ;; $BJQ99$O0J2<$N$h$&$K$9$l$P$h$$(B ;; (set-face-foreground '$B%U%'%$%9L>(B "$B?'$NL>A0(B") ;;; M-x grep $B$GF|K\8l8!:w(B (require 'advice) (defadvice grep (around arg-conv (command-args) activate) (ad-activate 'start-process-shell-command) ad-do-it (ad-deactivate 'start-process-shell-command)) (defadvice start-process-shell-command (before arg-conv (name buffer &rest command-args)) (let (newargs) (setq newargs (mapcar '(lambda (x) (encode-coding-string x 'shift_jis)) command-args)) (if (equal newargs command-args) () (setq command-args newargs) (message "NOTE: start-process with argument coding conversion")) )) ;;; $B%Z!<%8%9%/%m!<%k;~$N=E$J$j$r;XDj(B (setq next-screen-context-lines 1) ;;; ; shell$B$N@_Dj(B ; (setq explicit-shell-file-name "/usr/local/bin/bash") (require 'shell-command) ;;; .save.. $B$C$F$J%U%!%$%k$r:n$i$J$$(B (setq auto-save-list-file-name nil) (setq auto-save-list-file-prefix nil) ;;; ; imenu ; (require 'imenu) (defcustom imenu-modes '(emacs-lisp-mode c-mode c++-mode makefile-mode) "List of major modes for which Imenu mode should be used." :group 'imenu :type '(choice (const :tag "All modes" t) (repeat (symbol :tag "Major mode")))) (defun my-imenu-ff-hook () "File find hook for Imenu mode." (if (member major-mode imenu-modes) (imenu-add-to-menubar "imenu"))) (add-hook 'find-file-hooks 'my-imenu-ff-hook t) (global-set-key "\C-cg" 'imenu) ;;; ; $B%P%C%U%!L>$r<+F0E*$KJQ99(B ; (require 'uniquify) (setq uniquify-buffer-name-style 'post-forward-angle-brackets) (setq uniquify-ignore-buffers-re "*[^*]+*") ;(setq uniquify-min-dir-content 1) ;;; ; emerge$B$N%&%#%s%I%&$rI=<($7$J$$(B ; (setq ediff-window-setup-function 'ediff-setup-windows-plain) ;;; ; compare-windows$B$N@_Dj(B ; (global-set-key "\C-cc" 'compare-windows) (fset 'icompare-windows "\C-u\C-[xcompare-windows\C-m") ; WhiteSpace$B$N0c$$$rL5;k$9$k(B (global-set-key "\C-cC" 'icompare-windows) ; nil$B0J30$K$9$k$HBgJ8;z;RJ8;z$N0c$$$rL5;k$9$k(B (setq compare-ignore-case 'nil) ;;; for dired ; $B%U%)%k%@$r3+$/;~(B, $B?7$7$$%P%C%U%!$r:n@.$7$J$$(B (defun dired-my-advertised-find-file () (interactive) (let ((kill-target (current-buffer)) (check-file (dired-get-filename))) (funcall 'dired-advertised-find-file) (if (file-directory-p check-file) (kill-buffer kill-target)))) (defun dired-my-up-directory (&optional other-window) "Run dired on parent directory of current directory. Find the parent directory either in this buffer or another buffer. Creates a buffer if necessary." (interactive "P") (let* ((dir (dired-current-directory)) (up (file-name-directory (directory-file-name dir)))) (or (dired-goto-file (directory-file-name dir)) ;; Only try dired-goto-subdir if buffer has more than one dir. (and (cdr dired-subdir-alist) (dired-goto-subdir up)) (progn (if other-window (dired-other-window up) (progn (kill-buffer (current-buffer)) (dired up)) (dired-goto-file dir)))))) (define-key dired-mode-map "\C-m" 'dired-my-advertised-find-file) (define-key dired-mode-map "^" 'dired-my-up-directory) ; $B:#F|JQ99$7$?%U%!%$%k$K?'$r$D$1$k(B (defface face-file-edited-today '((t (:foreground "red"))) nil) (defvar face-file-edited-today 'face-file-edited-today) (defun my-dired-today-search (arg) "Fontlock search function for dired." (search-forward-regexp (concat (format-time-string "%b %e" (current-time)) " [0-9]....") arg t)) (add-hook 'dired-mode-hook '(lambda () (font-lock-add-keywords major-mode (list '(my-dired-today-search . face-file-edited-today) )))) ; $B%G%#%l%/%H%j$r@h$KI=<($9$k(B (defun ls-lisp-handle-switches (file-alist switches) ;; FILE-ALIST's elements are (FILE . FILE-ATTRIBUTES). ;; Return new alist sorted according to SWITCHES which is a list of ;; characters. Default sorting is alphabetically. (let (index) (setq file-alist (sort file-alist (cond ((memq ?S switches) ; sorted on size (function (lambda (x y) ;; 7th file attribute is file size ;; Make largest file come first (if (equal (nth 0 (cdr y)) (nth 0 (cdr x))) (< (nth 7 (cdr y)) (nth 7 (cdr x))) (nth 0 (cdr x)))))) ((memq ?t switches) ; sorted on time (setq index (ls-lisp-time-index switches)) (function (lambda (x y) (if (equal (nth 0 (cdr y)) (nth 0 (cdr x))) (ls-lisp-time-lessp (nth index (cdr y)) (nth index (cdr x))) (nth 0 (cdr x)) )))) ((memq ?X switches) ; sorted on ext (function (lambda (x y) (if (equal (nth 0 (cdr y)) (nth 0 (cdr x))) (string-lessp (file-name-extension (upcase (car x))) (file-name-extension (upcase (car y)))) (nth 0 (cdr x)))))) (t ; sorted alphabetically (if ls-lisp-dired-ignore-case (function (lambda (x y) (if (equal (nth 0 (cdr y)) (nth 0 (cdr x))) (string-lessp (upcase (car x)) (upcase (car y))) (nth 0 (cdr x))))) (function (lambda (x y) (if (equal (nth 0 (cdr y)) (nth 0 (cdr x))) (string-lessp (car x) (car y)) (nth 0 (cdr x))))) ))))) ) (if (memq ?r switches) ; reverse sort order (setq file-alist (nreverse file-alist))) file-alist) ; dired $B$N%=!<%HJ}K!$rJ]B8(B (defadvice dired-advertised-find-file (around dired-sort activate) (let ((sw dired-actual-switches)) ad-do-it (if (string= major-mode 'dired-mode) (progn (setq dired-actual-switches sw) (dired-sort-other dired-actual-switches))) )) (defadvice dired-my-up-directory (around dired-sort activate) (let ((sw dired-actual-switches)) ad-do-it (if (string= major-mode 'dired-mode) (progn (setq dired-actual-switches sw) (dired-sort-other dired-actual-switches))) )) ;(load-library "ls-lisp") ;(setq ls-lisp-dirs-first t) ;(setq dired-listing-switches "-AFl") ;(setq find-ls-option '("-exec ls -AFGl {} \\;" . "-AFGl")) ; (defun dired-find-alternate-file () ; "In dired, visit this file or directory instead of the dired buffer." ; (interactive) ; (set-buffer-modified-p nil) ; (find-alternate-file (dired-get-filename))) ; (add-hook 'dired-load-hook ; '(lambda () ; (load-library "ls-lisp") ; (setq ls-lisp-dirs-first t) ; (setq dired-listing-switches "-AFl") ; (setq find-ls-option '("-exec ls -AFGl {} \\;" . "-AFGl")) ; (setq grep-find-command "find . -type f -print0 | xargs -0 -e grep -ns ") ; )) (defface my-face-f-2 '((t (:foreground "GreenYellow"))) nil) (defvar my-face-f-2 'my-face-f-2) (defun my-dired-today-search (arg) "Fontlock search function for dired." (search-forward-regexp (concat (format-time-string "%b %e" (current-time)) " [0-9]....") arg t)) (add-hook 'dired-mode-hook '(lambda () (font-lock-add-keywords major-mode (list '(my-dired-today-search . my-face-f-2) )))) (custom-set-variables '(c-default-style "linux") '(c-basic-offset 8)) (custom-set-faces)