;; NetInstaller
(require "ni/setup")
(ni-autoload)
; インクリメンタルサーチ (C-s, C-r)
(require "isearch")
; dynamic abbreviation
(require "dabbrev")
(global-set-key #\M-/ 'dabbrev-expand)
; write-file
; バッファーの名前や割り付けられているファイル名も新しく指定
; されたファイルに変える
(define-key ctl-x-map #\C-w 'emacs-write-file)
; C-x C-v
; 廃棄するバッファのファイル名がミニバッファに表示
(setq *find-other-file-requires-file-name* t)
; sort-lines
(defun sort-lines (start end)
(interactive "*r")
(filter-region "sort" start end))
; ウィンドウを左右に分割
(define-key ctl-x-map #\3 'split-window-vertically)
; ispell-word
(defun ispell-word()
(interactive "*")
(let ((end (progn
(skip-chars-forward "A-Za-z")
(point)))
(beg (progn
(skip-chars-backward "A-Za-z")
(point))))
(ispell-region beg end)))
(global-set-key #\M-$ 'ispell-word)
; frame
(global-set-key '(#\C-x #\5 #\o) 'other-pseudo-frame)
(global-set-key '(#\C-x #\5 #\0) 'delete-pseudo-frame)
(global-set-key '(#\C-x #\5 #\2) 'new-pseudo-frame)
; 文字コードの変更
(global-set-key '(#\C-x #\RET #\f) 'change-fileio-encoding)
;;;; emacs風
; C-x C-v
; 廃棄するバッファのファイル名がミニバッファに表示
(setq *find-other-file-requires-file-name* t)
; sort-lines
(defun sort-lines (start end)
(interactive "*r")
(filter-region "sort" start end))
; ウィンドウを左右に分割
(define-key ctl-x-map #\3 'split-window-vertically)
; ispell-word
(defun ispell-word()
(interactive "*")
(let ((end (progn
(skip-chars-forward "A-Za-z")
(point)))
(beg (progn
(skip-chars-backward "A-Za-z")
(point))))
(ispell-region beg end)))
(global-set-key #\M-$ 'ispell-word)
; frame
(global-set-key '(#\C-x #\5 #\o) 'other-pseudo-frame)
(global-set-key '(#\C-x #\5 #\0) 'delete-pseudo-frame)
(global-set-key '(#\C-x #\5 #\2) 'new-pseudo-frame)
; 文字コードの変更
(global-set-key '(#\C-x #\RET #\f) 'change-fileio-encoding)
;;; grepの強化
;;; grep 結果からダブルクリックでファイルを開く
;;; http://hie.s64.xrea.com/xyzzy/note/search.html#grep-mouse-left-press
;;; http://hie.s64.xrea.com/xyzzy/note/search.html#grep-mouse-left-press
(defun grep-mouse-left-press ()
(interactive)
(let ((click (mod *last-mouse-click-count* 6)))
(if (= click 2)
(first-error)
(mouse-left-press))))
(defvar *grep-map* nil)
(unless *grep-map*
(setq *grep-map* (make-sparse-keymap))
(define-key *grep-map* #\LBtnDown 'grep-mouse-left-press))
(add-hook 'ed::*grep-hook* #'(lambda () (use-keymap *grep-map*)))
(add-hook 'ed::*grepd-hook* #'(lambda () (use-keymap *grep-map*)))
(define-key *grep-map* #\RET 'first-error)
;; 操作を便利にするためにキーバインドの類を設定
;; 検索結果一覧(*compilation*バッファ)上の操作:
;; * [↑][↓]で、該当箇所を別ウィンドウに表示
;; * RETまたはダブルクリックで、該当箇所にジャンプ
;; 検索対象バッファ上での操作:
;; * C-M-Up([Ctrl]+[Alt]+[↑])で1つ前のマッチへジャンプ(F11と同じ)
;; * C-M-Down([Ctrl]+[Alt]+[↓])で1つ先のマッチへジャンプ(C-u F11と同じ)
(defun show-previous-error ()
(interactive)
(progn (next-line -1)(first-error)(other-window -1)))
(defun show-next-error ()
(interactive)
(progn (next-line)(first-error)(other-window -1)))
(define-key *grep-map* #\Up 'show-previous-error)
(define-key *grep-map* #\Down 'show-next-error)
(defun previous-error ()
(interactive)
(next-error -1))
(global-set-key #\C-M-^ 'previous-error)
(global-set-key #\C-^ 'next-error)
;;; grepの強化ここまで
;;マウスだけでコピー・ペースト
(defun mouse-right-press ()
(interactive)
(mouse-left-press)
(paste-from-clipboard))
(global-set-key #\LBtnUp 'copy-selection-to-clipboard)
;;(global-set-key #\RBtnUp 'mouse-right-press)
;;(global-set-key #\MBtnUp 'mouse-menu-popup)
;;;;;
;バックアップ - 外部 lisp は不要
(require "backup")
(setq *hierarchic-backup-directory* t)
;バックアップを取る場所を指定 in .xyzzy
(setq *backup-directory* "~/backup")
;; XML-MODE
(require "xml/xml-mode")
(use-package 'xml)
(pushnew '("\\.\\(xml\\|arxml\\|mcxml\\|xsl\\|html\\|sdoc\\|fo\\|rng\\|svg\\|xi\\)" . xml-mode) *auto-mode-alist* :test #'equal)
;; 色の変更
(setq *xml-tag-attribute* '(:bold t :foreground 9))
(setq *xml-tag-invalid-attribute* '(:bold t :foreground 1))
(setq *xml-cdata-attribute* '(:foreground 2))
;; リージョンに色をつける
(require "rv-region")
(setq *rv-region-stay-on* t)
;; TreeView
(require "treeview/setup")
;; buf2html
(require "buf2html")
;; OutlineTree
(require "outline-tree/outline-tree")
;; c-mode インデント設定
(setq *c-indent-tabs-mode* t)
(setq c-indent-level 4)
(setq c-continued-statement-offset 4)
(setq c-brace-offset -4)
(setq c-argdecl-indent 4)
(setq c-label-offset -4)
(setq c-brace-imaginary-offset 0)
(add-hook 'ed::*c-mode-hook*
#'(lambda () (set-tab-columns 4 (selected-buffer))))
; (setq *c++-tab-always-indent* nil)
;; c++-mode インデント設定
(setq *c++-indent-tabs-mode* t)
(setq c++-indent-level 4)
(setq c++-continued-statement-offset 4)
(setq c++-brace-offset -4)
(setq c++-argdecl-indent 4)
(setq c++-label-offset -4)
(setq c++-brace-imaginary-offset 0)
(add-hook 'ed::*c++-mode-hook*
#'(lambda () (set-tab-columns 4 (selected-buffer))))
; (setq *c++-tab-always-indent* nil)
;; コメントアウト
(autoload 'comment-out-region "comment" t nil)
(global-set-key #\M-\; 'comment-out-region)
;;Migemoの正規表現をキャッシュ
(require "migemo")
(defvar *migemo-cache-more-than* 3)
(defvar *migemo-cache-file* "~/etc/migemo.dat")
(in-package "editor")
(let (old-migemo-query cache)
(add-hook '*post-startup-hook*
#'(lambda ()
(when (file-exist-p user::*migemo-cache-file*)
(with-open-file (fp user::*migemo-cache-file*)
(let (line)
(while (setf line (read fp nil))
(pushnew line cache
:key 'car
:test 'equal)))))))
(add-hook '*kill-xyzzy-hook*
#'(lambda ()
(with-open-file (s user::*migemo-cache-file*
:direction :output
:if-exists :overwrite
:if-does-not-exist :create)
(mapc #'(lambda (x)
(format s "~S~%" x))
cache))))
(setf (symbol-function 'old-migemo-query)
(symbol-function 'migemo-query))
(defun migemo-query (query)
(setq *isearch-regexp* *migemo-on*)
(let ((val (assoc query cache :test 'equal)))
(if val
(cdr val)
(let ((regexp (old-migemo-query query)))
(when (<= (length query) user::*migemo-cache-more-than*)
(setf cache
(acons query regexp cache)))
regexp))))
(defun migemo-delete-cache ()
(interactive)
(setf cache nil)))
(in-package "user")
(migemo-toggle t)
;dabbrevでこれ以上の文字数の時にmigemo使う
(defvar *dabbrev-use-migemo-more-than* 4)
(let ((old #'ed::dabbrev-find-expansion)
(old-all #'ed::dabbrev-find-all-expansion))
(defun ed::dabbrev-find-all-expansion (abbrev case-fold match-table start matches)
(and (not (regexpp abbrev))
(<= *dabbrev-use-migemo-more-than* (length abbrev))
(setf abbrev (compile-regexp (ed::migemo-query abbrev) t)))
(funcall old-all abbrev case-fold match-table start matches))
(defun ed::dabbrev-find-expansion (abbrev count reverse no-dup case-fold match-table)
(and (not (regexpp abbrev))
(<= *dabbrev-use-migemo-more-than* (length abbrev))
(setf abbrev (compile-regexp (ed::migemo-query abbrev) t)))
(funcall old abbrev count reverse no-dup case-fold match-table)))
;; migemoのバグ対策
(in-package "editor")
(let ((migemo #'migemo-query))
(defun migemo-query (query)
(let ((regexp (funcall migemo query)))
(setf regexp (substitute-string regexp
"\\[\\\\)" "\\\\[\\\\)")
regexp (substitute-string regexp
"\\[\\\\|" "\\\\[\\\\|")
regexp (substitute-string regexp
"\\[\\[" "\\\\[\\[")))))
(in-package "user")
;; bat-mode
(in-package "editor")
(export 'bat-mode)
(export 'ini-mode)
(autoload 'bat-mode "bat-mode" t)
(autoload 'ini-mode "ini-mode" t)
(pushnew '("\\.bat$" . bat-mode) *auto-mode-alist* :test 'equal)
(pushnew '("\\.ini$" . ini-mode) *auto-mode-alist* :test 'equal)
(in-package "user")
;; バッファ名をコピー
;; 名前だけ
(defun clipboard-to-buffer-name() (interactive)
(copy-to-clipboard (buffer-name (selected-buffer))))
(define-key spec-map #\c 'my-buffer-name-copy)
;; フルパス
(defun clipboard-to-buffer-file-name ()
(interactive)
(unless (equal (get-buffer-file-name) nil)
(copy-to-clipboard
(map-slash-to-backslash (get-buffer-file-name)))))
(define-key spec-map #\n 'my-file-name-copy-backslash)
;; makefile-mode
(require "elisp")
(load-library "make-mode")
(push '("makefile\\|\\.mak$\\|\\.mk$" . elisp::makefile-mode) *auto-mode-alist*)
;; 行末まで削除する
(defun my-kill-line (&optional arg)
(interactive "*p")
(cond ((bolp)
(let ((point (point))
(lines (cond ((or (null arg)
(<= arg 1))
0)
(t
(- arg 1)))))
(kill-region point
(progn
(forward-line lines)
(goto-eol)
(forward-char)
(point)))))
(t
(kill-line arg))))
(define-key *global-keymap* #\C-k 'my-kill-line)
;; 括弧をハイライト
(require "paren")
(turn-on-global-paren)
;; emacs風キーバインド
; key bind
(global-set-key #\C-] 'redo)
(global-set-key #\M-h 'backward-kill-word)
(global-set-key #\C-/ 'undo)
(global-set-key #\M-v 'previous-page)
;(global-set-key #\M-% 'replace-string)
;(global-set-key #\C-M-% 'replace-regexp)
(global-set-key #\M-% 'query-replace)
(global-set-key #\C-M-% 'query-replace-regexp)
(global-set-key #\C-M-\\ 'indent-region)
(global-set-key '(#\C-x #\h) 'mark-page)
(global-set-key '(#\C-x #\u) 'undo)
(global-set-key '(#\C-x #\r #\d) 'delete-rectangle)
(global-set-key '(#\C-x #\r #\k) 'kill-rectangle)
(global-set-key '(#\C-x #\r #\o) 'open-rectangle)
(global-set-key '(#\C-x #\r #\t) 'string-rectangle)
(global-set-key '(#\C-x #\r #\y) 'yank-rectangle)
(global-set-key '(#\C-x #\r #\w) 'copy-rectangle)
(global-set-key #\Home 'beginning-of-buffer)
(global-set-key #\End 'end-of-buffer)
(global-set-key #\C-_ 'undo)
(global-set-key #\C-- 'negative-argument)
(global-set-key #\C-\\ 'toggle-ime)
(dolist (c '(#\C-0 #\C-1 #\C-2 #\C-3 #\C-4 #\C-5 #\C-6 #\C-7 #\C-8 #\C-9))
(global-set-key c 'digit-argument))
(global-set-key '(#\C-x #\n #\n) 'narrow-to-region)
(global-set-key '(#\C-x #\n #\w) 'widen)
(global-set-key #\M-: 'eval-expression)
(substitute-key-definition 'next-virtual-line 'next-line)
(substitute-key-definition 'previous-virtual-line 'previous-line)
(export 'ed::csv-mode "ed")
(autoload 'csv-mode "csv-mode" t)
;;(autoload 'tsv-mode "csv-mode" t)
(pushnew '("\\.csv$" . csv-mode) *auto-mode-alist* :test 'equal)
;;(pushnew '("\\.tsv$" . csv-mode) *auto-mode-alist* :test 'equal)
;; マウスホイールで画面をスクロールさせてもセレクションを解除されないようにする
;;(require "keep-selection")
;;
;;(in-package "editor")
;;
;;(defun mouse-wheel-scroll (window n lines)
;; (or lines
;; (setq lines (window-lines window)))
;; (with-selected-window
;; (set-window window)
;; (move-kept-selection #'scroll-window (* n lines))))
;;
;;(setq mouse-wheel-handler #'mouse-wheel-scroll)
;;
;;(defun previous-page-kept-selection ()
;; (interactive)
;; (move-kept-selection #'previous-page))
;;
;;(in-package "user")
;;
;;(global-set-key #\PageUp 'previous-page-kept-selection)
;;(global-set-key #\PageDown 'next-page-kept-selection)
;; bash-mode
(load-library "bash-mode")
;; python-mode
(load-library "py-mode")
(push '("\\.py$" . py-mode) *auto-mode-alist*)
;;Python-mode関連
(add-hook 'ed::*py-mode-hook*
#'(lambda ()
;c-jをオートインデント改行に
(define-key ed::*py-mode-map* #\c-m 'ed::py-newline-and-indent)
))
(require "complete+") ; ni-autoloadしている人は不要
(use-package "complete+"); ni-autoloadしている人は不要
(dolist (keymap (list minibuffer-local-completion-map
minibuffer-local-must-match-map))
(define-key keymap '#\C-n 'complete+-select-next-item) ; 次の候補
(define-key keymap '#\C-p 'complete+-select-prev-item) ; 前の候補
(define-key keymap '#\C-< 'complete+-substring-match-rotate) ; 部分一致
(define-key keymap '#\C-> 'complete+-skip-match-rotate) ; スキップマッチ
(define-key keymap '#\C-. 'complete+-toggle-incremental)) ; インクリメンタル
(setf *complete+-and-search* ";") ;AND検索
(setf *complete+-show-drive* t) ;ドライブを表示
(setf *complete+-current-item-attribute* '(:foreground 1)) ; *Completion*バッファ
(setf *complete+-highlight-color* '(:foreground 2)) ; ハイライト
(complete+-toggle-incremental t);最初からインクリメンタルに補完候補を表示
;; 罫線モードの拡張
(require "box-fixation-mode")
;; URL
(require "clickable-uri")
;; Explorer呼び出し
(require "explorer")
;; Grrep拡張
(require "ggrep")
;; iswitchb
(require "elisp")
(require "iswitchb")
(elisp::iswitchb-mode 1)
(elisp::iswitchb-substitute-global-map)
;; JavaScript
(require "jscript-mode")
;; markdown
(require "markdown")
;;Replace拡張
(require "multiple-replace")
;; 最近使ったファイル一覧
(defun list-recents ()
(interactive)
(let (hlist filename)
(setq hlist (mapcar #'(lambda (x)
(list (abbreviate-display-string x 60 t) x))
*minibuffer-file-name-history*))
(multiple-value-bind (result data)
(dialog-box
'(dialog 0 0 286 162
(:caption "最近使ったファイル")
(:font 9 "MS Pゴシック")
(:control
(:listbox flist nil #x50b10111 7 7 216 148)
(:button IDOK "OK" #x50010001 229 7 50 14)
(:button IDCANCEL "キャンセル" #x50010000 229 24 50 14)))
(list (cons 'flist hlist))
`((flist :must-match t :enable (IDOK))))
(when result
(setq filename (car (cddr (assoc 'flist data))))
(find-file filename)
(add-history filename '*minibuffer-file-name-history*)))))
;; URLデコード
;; 文字コードを指定して開き直す
(defvar *encoding-menu* nil)
(defun encoding-menu ()
(or *encoding-menu*
(let ((menu (create-popup-menu)))
(mapc #'(lambda (x)
(add-menu-item menu nil (car x)
#'(lambda ()
(interactive)
(revert-buffer (cdr x)))))
`(("utf-8n \t(&8)" . ,*encoding-utf8n*)
("utf-16 \t(&6)" . ,*encoding-utf16*)
("sjis \t(&S)" . ,*encoding-sjis*)
("auto \t(&A)" . ,*encoding-auto*)
("euc-jp \t(&E)" . ,*encoding-euc-jp*)
("jis \t(&J)" . ,*encoding-jis*)))
(add-menu-item menu :select "詳細指定\t(&_)"
#'(lambda (encoding)
(interactive "zEncoding: ")
(revert-buffer encoding)))
(setq *encoding-menu* menu))))
(defun revert-buffer-encoding-popup2 ()
(interactive)
(track-popup-menu (encoding-menu)))
(defun encoding-menu-in-file-autoload ()
(let ((filemenu (get-menu *app-menu* 'ed::file)))
(insert-popup-menu filemenu
(1- (get-menu-position (get-menu *app-menu* 'ed::file) :above-session))
(encoding-menu) "Reopen with Encoding (&G)\tC-c e")))
(add-hook '*init-app-menus-hook* 'encoding-menu-in-file-autoload)
(global-set-key '(#\C-x #\RET #\r) 'revert-buffer-encoding-popup2)
2012年2月6日月曜日
.emacs.elの設定(Linux)
;; -*- coding: utf-8 -*-
;;; Language
(set-language-environment "Japanese")
(set-terminal-coding-system 'utf-8)
(setq file-name-coding-system 'utf-8)
(set-clipboard-coding-system 'utf-8)
(setq default-buffer-file-coding-system 'utf-8)
(setq coding-system-for-read 'mule-utf-8)
(prefer-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
(set-keyboard-coding-system 'utf-8)
(set-buffer-file-coding-system 'utf-8)
(when window-system
(progn
(set-default-font "VL ゴシック-14")
(set-fontset-font (frame-parameter nil 'font)
'japanese-jisx0208
'("VL ゴシック" . "unicode-bmp"))))
(load-library "anthy")
(setq default-input-method "japanese-anthy")
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(column-number-mode t)
'(current-language-environment "Japanese")
'(eshell-ask-to-save-history (quote always))
'(eshell-history-size 1000)
'(eshell-ls-dired-initial-args (quote ("-h")))
'(eshell-ls-exclude-regexp "~\\'")
'(eshell-ls-initial-args "-h")
'(eshell-modules-list (quote (eshell-alias eshell-basic eshell-cmpl eshell-dirs eshell-glob eshell-hist eshell-ls eshell-pred eshell-prompt eshell-rebind eshell-script eshell-smart eshell-term eshell-unix eshell-xtra)))
'(eshell-prefer-to-shell t nil (eshell))
'(eshell-stringify-t nil)
'(eshell-term-name "ansi")
'(eshell-visual-commands (quote ("vi" "top" "screen" "less" "lynx" "ssh" "rlogin" "telnet")))
'(inhibit-startup-screen t)
'(kill-whole-line t)
'(partial-completion-mode t)
'(safe-local-variable-values (quote ((numbered-outline-begin-number . 1) (encoding . sjis) (bug-reference-url-format . "http://emacsbugs.donarmstrong.com/cgi-bin/bugreport.cgi?bug=%s") (encoding . sjis-unix) (encoding\. sjis-dos) (c-set-style . "stroustrup"))))
'(show-paren-mode t)
'(tab-width 4)
'(tool-bar-mode nil)
'(transient-mark-mode t)
)
;; emacs-server
(server-start)
;; =============================================================================
;; キーバインド
;; =============================================================================
(global-set-key "\C-h" 'backward-delete-char)
(global-set-key "\M-?" 'help-for-help)
(global-set-key [f1] 'help-for-help)
(global-set-key "\M-g" 'goto-line) ;; M-g で指定行へ移動
(global-set-key "\C-^" 'next-error)
(global-set-key "\M-h" 'backward-kill-word)
(global-set-key [hiragana-katakana] 'toggle-input-method)
(global-set-key [muhenkan] 'toggle-input-method)
;;(global-set-key "\M-." 'migemo-dabbrev-expand)
(define-key global-map "\C-m" 'newline-and-indent) ;; 改行キーでオートインデント
(setq indent-line-function 'indent-relative-maybe) ;;インデント方法. お好みで. .
;; C-x p で C-x oの逆の動作
(define-key ctl-x-map "p"
#'(lambda (arg) (interactive "p") (other-window (- arg))))
(defun eshell/clear ()
"Clear the current buffer, leaving one prompt at the top."
(interactive)
(let ((inhibit-read-only t))
(erase-buffer)))
;; =============================================================================
;; 編集
;; =============================================================================
;;iswitchb
(iswitchb-mode t)
(defun iswitchb-possible-new-buffer (buf)
"Possibly create and visit a new buffer called BUF."
(interactive)
(message (format
"No buffer matching `%s', "
buf))
(sit-for 1)
(call-interactively 'find-file buf))
(defun iswitchb-buffer (arg)
"Switch to another buffer.
The buffer name is selected interactively by typing a substring. The
buffer is displayed according to `iswitchb-default-method' -- the
default is to show it in the same window, unless it is already visible
in another frame.
For details of keybindings, do `\\[describe-function] iswitchb'."
(interactive "P")
(if arg
(call-interactively 'switch-to-buffer)
(setq iswitchb-method iswitchb-default-method)
(iswitchb)))
;; =============================================================================
;; バックアップ関連
;; =============================================================================
;; 番号つきバックアップファイル
;; Emacsが作るバックアップファイルをfilename~というのから
;; filename.~n~にする
(setq version-control t)
;; 古いものをいくつ残すか
(setq kept-old-versions 5)
;; 新しいものをいくつ残すか
(setq kept-new-versions 5)
;; バックアップファイルを上書きするときに警告を出す
(setq trim-versions-without-asking t)
;; #filename というバックアップファイルを作らない
(setq auto-save-default t)
;;;バックアップファイル「(ファイル名)~」を作成するか指定
(setq make-backup-files t)
;; バックアップファイルの設定
(setq backup-by-copying t)
;;;バックアップファイルを特定のディレクトリにセーブする
(setq backup-directory-alist
(cons (cons "\\.*$" (expand-file-name "~/.backup/"))
backup-directory-alist))
;; 古いものを消すときに聞かずに消す
(setq delete-old-versions t)
;; =============================================================================
;; scratch buffer 以外をまとめてタブに表示する
;; =============================================================================
(require 'cl)
(when (require 'tabbar nil t)
(setq tabbar-buffer-groups-function
(lambda (b) (list "All Buffers")))
(setq tabbar-buffer-list-function
(lambda ()
(remove-if
(lambda(buffer)
(find (aref (buffer-name buffer) 0) " *"))
(buffer-list))))
(tabbar-mode))
;;M-]で次のタブ、M-[で前のタブに移動
(global-set-key "\M-]" 'tabbar-forward)
(global-set-key "\M-[" 'tabbar-backward)
;; =============================================================================
;; 開発
;; =============================================================================
;; GDBの設定
(setq gdb-many-windows t)
(windmove-default-keybindings)
(setq windmove-wrap-around t)
;; Ini, batモード
(require 'generic-x)
;; moccur-edit
(require 'moccur-edit)
;; moccur-grep-findで.svnを無視する
(setq dmoccur-exclusion-mask
(append '("\\~$" "\\.svn\\/\*") dmoccur-exclusion-mask))
;; C#モード
;; (autoload 'csharp-mode "csharp-mode" "C# editing mode." t)
;; (add-to-list 'auto-mode-alist '("\\.cs$" . csharp-mode))
;; (add-hook 'csharp-mode-hook (lambda ()
;; (setq c-basic-offset 4
;; tab-width 4
;; indent-tabs-mode t)))
;; Makefile
(add-to-list 'auto-mode-alist '("\\.mak$" . makefile-mode))
;; Dotモード
;;(load "graphviz-dot-mode.el")
;; PHPモード
(autoload 'php-mode "php-mode")
(setq auto-mode-alist
(cons '("\\.php\\'" . php-mode) auto-mode-alist))
(setq php-mode-force-pear t)
;; xml
(add-to-list 'auto-mode-alist '("\\.\\(xml\\|mcxml\\|xsd\\|arxml\\|cmxml\\)\\'" . nxml-mode))
(add-hook 'nxml-mode-hook
(lambda ()
(setq nxml-slash-auto-complete-flag t)
(setq nxml-child-indent 2)
(setq indent-tabs-mode t)
(setq tab-width 2)))
;; Python
(autoload 'python-mode "python-mode" "Python Mode." t)
(add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode))
(add-to-list 'interpreter-mode-alist '("python" . python-mode))
(add-hook 'python-mode-hook
(lambda ()
(set (make-variable-buffer-local 'beginning-of-defun-function)
'py-beginning-of-def-or-class)
(setq outline-regexp "def\\|class ")
(setq indent-tabs-mode t)
))
;; GNU GLOBAL(gtags) gtags.el
;; (autoload 'gtags-mode "gtags" "" t)
;; (global-set-key "\M-t" 'gtags-find-tag) ;関数の定義元へ
;; (global-set-key "\M-r" 'gtags-find-rtag) ;関数の参照先へ
;; (global-set-key "\M-s" 'gtags-find-symbol) ;変数の定義元/参照先へ
;; (global-set-key "\C-t" 'gtags-pop-stack) ;前のバッファに戻る
;; ;;
;; (add-hook 'c-mode-hook
;; (function
;; (lambda ()
;; (gtags-mode 1)
;; (cygwin-mount-activate)
;; )))
;; CScope
(require 'xcscope)
;; =============================================================================
;; 表示
;; =============================================================================
;; タブ, 全角スペース、改行直前の半角スペースを表示する
(when (require 'jaspace nil t)
(when (boundp 'jaspace-modes)
(setq jaspace-modes (append jaspace-modes
(list 'php-mode
'yaml-mode
'javascript-mode
'ruby-mode
'text-mode
'fundamental-mode
'python-mode
'c-mode
'c++-mode
'dot-mode
'nxml-mode
'html-mode
)
)))
(when (boundp 'jaspace-alternate-jaspace-string)
(setq jaspace-alternate-jaspace-string "□"))
(when (boundp 'jaspace-highlight-tabs)
(setq jaspace-highlight-tabs ?^))
(add-hook 'jaspace-mode-off-hook
(lambda()
(when (boundp 'show-trailing-whitespace)
(setq show-trailing-whitespace nil))))
(add-hook 'jaspace-mode-hook
(lambda()
(progn
(when (boundp 'show-trailing-whitespace)
(setq show-trailing-whitespace t))
(face-spec-set 'jaspace-highlight-jaspace-face
'((((class color) (background light))
(:foreground "blue"))
(t (:foreground "green"))))
(face-spec-set 'jaspace-highlight-tab-face
'((((class color) (background light))
;; (:foreground "red"
:background "gray26"
:strike-through nil
:underline nil))
(t (:foreground "purple"
:background "unspecified"
:strike-through nil
:underline nil))))
(face-spec-set 'trailing-whitespace
'((((class color) (background light))
(:foreground "red"
:background "unspecified"
:strike-through nil
:underline nil))
(t (:foreground "purple"
:background "unspecified"
:strike-through nil
:underline nil)))))))
;; =============================================================================
;; 現在開いているファイルのファイル名を、Windows形式(「\」で区切る)
;; でクリップボードにコピーします。
;; =============================================================================
(defun clipboard-to-buffername ()
(interactive)
(unless (equal (buffer-file-name) nil)
(kill-new
(buffer-file-name))))
;; =============================================================================
;; 余分な空白を削除する
;; =============================================================================
(defun trim-buffer ()
"Delete excess white space."
(interactive)
(save-excursion
;; 行末の空白を削除する
(goto-char (point-min))
(while (re-search-forward "[ \t]+$" nil t)
(replace-match "" nil nil))
;; ファイルの終わりにある空白行を削除する
(goto-char (point-max))
(delete-blank-lines)
; ;; タブに変換できる空白は変換する
; (mark-whole-buffer)
; (tabify (region-beginning) (region-end))
))
;; =============================================================================
;; C-mode
;; =============================================================================
(add-hook 'c-mode-common-hook
'(lambda ()
(c-set-style "stroustrup")
(setq tab-width 4)
(setq c-basic-offset 4)
(setq indent-tabs-mode t)
(setq c-lineup-close-paren 8)
;;(c-set-offset 'arglist-intro c-lineup-arglist-intro-after-paren)
;;(c-set-offset 'arglist-close c-lineup-arglist)
;; (c-set-offset 'arglist-cont-nonempty +)
;; (c-set-offset 'arglist-cont 4)
;; (c-set-offset 'statement-cont 0)
;; (c-set-offset 'substatement-open 0)
;; (c-set-offset 'block-open 0)
;; (c-set-offset 'statement-case-open 0)
))
;; テーマ
(require 'color-theme)
(color-theme-initialize)
(color-theme-clarity)
;; ============================================================
;; use tramp
;; ============================================================
(require 'tramp)
(setq tramp-default-method "ssh")
;; Setting for working with remote host
(add-to-list 'tramp-default-proxies-alist
'("se-srv-nanami.*" "root" "/ssh:nanami@%h:"))
;; MarkdownMode
(autoload 'markdown-mode "markdown-mode.el"
"Major mode for editing Markdown files" t)
(setq auto-mode-alist
(cons '("\\.text" "\\.markdown" . markdown-mode) auto-mode-alist))
.emacsの設定(for NT)
;; keyset
(global-set-key "\C-h" 'backward-delete-char) ;C-h as BackSpace
(global-set-key "\M-?" 'help-for-help) ;M-? as help
;;(global-set-key "\C-q" 'dabbrev-expand)
(global-set-key "\C-m" 'newline-and-indent)
(global-set-key "\M-g" 'goto-line)
;;(global-set-key "\C-q" 'quoted-insert) ;C-q original
(defun buffer-menu-other-window-move ()
(interactive)
(buffer-menu-other-window)
(next-window))
(global-set-key "\C-x\C-b" 'buffer-menu-other-window-move)
(defun other-window-or-split ()
(interactive)
(when (one-window-p)
;;(split-window-horizontally)
(split-window-vertically)
)
(other-window 1))
;;(global-set-key "\C-t" 'other-window-or-split)
;; パスの設定
(let* ((cygwin-root "c:/cygwin")
(cygwin-bin (concat cygwin-root "/bin")))
;;(setenv "HOME" (concat cygwin-root "/home/eric"))
(setenv "PATH" (concat cygwin-bin ";" (getenv "PATH")))
(setq exec-path (cons cygwin-bin exec-path))
(setq shell-file-name "bash")
(setq explicit-shell-file-name "bash")
(add-hook 'comint-mode-hook 'ansi-color-for-comint-mode-on))
(cd "~") ;start on home directory
(setq-default indent-tabs-mode nil) ;When pushing [TAB], input WhiteSpaces.
;; 滑らかなスクロール
(setq redisplay-dont-pause t)
;; テーマ
;;(require 'color-theme)
;;(color-theme-initialize)
;;(color-theme-clarity)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; 日本語環境の設定
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(set-keyboard-coding-system 'japanese-shift-jis)
(setq default-input-method "W32-IME")
(w32-ime-initialize)
;; UTF-8⇔Legacy Encoding (EUC-JP や Shift_JIS など)をWindowsで変換
;; http://nijino.homelinux.net/emacs/emacs23-ja.html
(coding-system-put 'euc-jp :encode-translation-table
(get 'japanese-ucs-cp932-to-jis-map 'translation-table))
(coding-system-put 'iso-2022-jp :encode-translation-table
(get 'japanese-ucs-cp932-to-jis-map 'translation-table))
(coding-system-put 'cp932 :encode-translation-table
(get 'japanese-ucs-jis-to-cp932-map 'translation-table))
;; charset と coding-system の優先度設定
(set-charset-priority 'ascii 'japanese-jisx0208 'latin-jisx0201
'katakana-jisx0201 'iso-8859-1 'cp1252 'unicode)
(set-coding-system-priority 'utf-8 'euc-jp 'iso-2022-jp 'cp932)
;; East Asian Ambiguous
(defun set-east-asian-ambiguous-width (width)
(while (char-table-parent char-width-table)
(setq char-width-table (char-table-parent char-width-table)))
(let ((table (make-char-table nil)))
(dolist (range
'(#x00A1 #x00A4 (#x00A7 . #x00A8) #x00AA (#x00AD . #x00AE)
(#x00B0 . #x00B4) (#x00B6 . #x00BA) (#x00BC . #x00BF)
#x00C6 #x00D0 (#x00D7 . #x00D8) (#x00DE . #x00E1) #x00E6
(#x00E8 . #x00EA) (#x00EC . #x00ED) #x00F0
(#x00F2 . #x00F3) (#x00F7 . #x00FA) #x00FC #x00FE
#x0101 #x0111 #x0113 #x011B (#x0126 . #x0127) #x012B
(#x0131 . #x0133) #x0138 (#x013F . #x0142) #x0144
(#x0148 . #x014B) #x014D (#x0152 . #x0153)
(#x0166 . #x0167) #x016B #x01CE #x01D0 #x01D2 #x01D4
#x01D6 #x01D8 #x01DA #x01DC #x0251 #x0261 #x02C4 #x02C7
(#x02C9 . #x02CB) #x02CD #x02D0 (#x02D8 . #x02DB) #x02DD
#x02DF (#x0300 . #x036F) (#x0391 . #x03A9)
(#x03B1 . #x03C1) (#x03C3 . #x03C9) #x0401
(#x0410 . #x044F) #x0451 #x2010 (#x2013 . #x2016)
(#x2018 . #x2019) (#x201C . #x201D) (#x2020 . #x2022)
(#x2024 . #x2027) #x2030 (#x2032 . #x2033) #x2035 #x203B
#x203E #x2074 #x207F (#x2081 . #x2084) #x20AC #x2103
#x2105 #x2109 #x2113 #x2116 (#x2121 . #x2122) #x2126
#x212B (#x2153 . #x2154) (#x215B . #x215E)
(#x2160 . #x216B) (#x2170 . #x2179) (#x2190 . #x2199)
(#x21B8 . #x21B9) #x21D2 #x21D4 #x21E7 #x2200
(#x2202 . #x2203) (#x2207 . #x2208) #x220B #x220F #x2211
#x2215 #x221A (#x221D . #x2220) #x2223 #x2225
(#x2227 . #x222C) #x222E (#x2234 . #x2237)
(#x223C . #x223D) #x2248 #x224C #x2252 (#x2260 . #x2261)
(#x2264 . #x2267) (#x226A . #x226B) (#x226E . #x226F)
(#x2282 . #x2283) (#x2286 . #x2287) #x2295 #x2299 #x22A5
#x22BF #x2312 (#x2460 . #x24E9) (#x24EB . #x254B)
(#x2550 . #x2573) (#x2580 . #x258F) (#x2592 . #x2595)
(#x25A0 . #x25A1) (#x25A3 . #x25A9) (#x25B2 . #x25B3)
(#x25B6 . #x25B7) (#x25BC . #x25BD) (#x25C0 . #x25C1)
(#x25C6 . #x25C8) #x25CB (#x25CE . #x25D1)
(#x25E2 . #x25E5) #x25EF (#x2605 . #x2606) #x2609
(#x260E . #x260F) (#x2614 . #x2615) #x261C #x261E #x2640
#x2642 (#x2660 . #x2661) (#x2663 . #x2665)
(#x2667 . #x266A) (#x266C . #x266D) #x266F #x273D
(#x2776 . #x277F) (#xE000 . #xF8FF) (#xFE00 . #xFE0F)
#xFFFD
))
(set-char-table-range table range width))
(optimize-char-table table)
(set-char-table-parent table char-width-table)
(setq char-width-table table)))
(set-east-asian-ambiguous-width 2)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; 画面設定
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ウィンドウ(Emacs用語ではframe)設定
(setq default-frame-alist
(append (list
;; サイズ・位置
'(width . 80) ; 横幅(文字数)
'(height . 46) ; 高さ(行数)
'(top . 50) ; フレーム左上角 y 座標
'(left . 50) ; フレーム左上角 x 座標
)
default-frame-alist))
;; 背景色を黒、文字を白、カーソルをグレー
(set-background-color "Black")
(set-foreground-color "White")
;; シンタックスハイライト用
(set-face-bold-p 'font-lock-function-name-face t)
;; erase memubar, scrollbar
;;(menu-bar-mode -1) ;画面上に出るメニュー(文字)を消す
(tool-bar-mode -1) ;画面上に出るツールバー(アイコン画像)を消す
;(scroll-bar-mode -1) ;画面横に出るスクロールバーを消す
(setq inhibit-startup-message t) ;スプラッシュ(起動画面)抑止
(column-number-mode 1)
;; emacs-server
;;(server-start)
;; フォント設定
(set-default-font "Osaka-等幅-11")
;; (set-fontset-font "fontset-default"
;; 'japanese-jisx0208
;; '("Osaka-UI" . "iso10646-1"))
;; (set-fontset-font "fontset-default"
;; 'katakana-jisx0201
;; '("Osaka-UI" . "iso10646-1"))
;; (set-default-font "Courier New-10")
;; (set-fontset-font (frame-parameter nil 'font)
;; 'japanese-jisx0208
;; '("Osaka-UI" . "unicode-bmp"))
;;(set-default-font "MS ゴシック-10")
;; color
(global-font-lock-mode t) ;font-lock use-all
(transient-mark-mode t) ;選択したとき色がつくようにする
;; kill-ring はテキスト属性(色情報など)を保存しなくていい
;; http://www-tsujii.is.s.u-tokyo.ac.jp/~yoshinag/tips/elisp_tips.html#yankoff
(defadvice kill-new (around my-kill-ring-disable-text-property activate)
(let ((new (ad-get-arg 0)))
(set-text-properties 0 (length new) nil new)
ad-do-it))
;; タブ, 全角スペースを色つき表示する (色名は M-x list-color-displayで調べる)
;; http://homepage1.nifty.com/blankspace/emacs/color.html
(defface my-face-b-1 '((t (:background "LightGray"))) nil)
(defface my-face-b-2 '((t (:background "gray7"))) nil)
(defvar my-face-b-1 'my-face-b-1)
(defvar my-face-b-2 'my-face-b-2)
(defadvice font-lock-mode (before my-font-lock-mode ())
(font-lock-add-keywords
major-mode
'(("\t" 0 my-face-b-2 append)
(" " 0 my-face-b-1 append)
("[ \t]+$" 0 my-face-b-1 append)
)))
(ad-enable-advice 'font-lock-mode 'before 'my-font-lock-mode)
(ad-activate 'font-lock-mode)
;; IMEのON/OFFでカーソルの色を変える
(set-cursor-color "cyan")
(add-hook 'w32-ime-on-hook
(function (lambda () (set-cursor-color "LimeGreen"))))
(add-hook 'w32-ime-off-hook
(function (lambda () (set-cursor-color "cyan"))))
;; elisp変数表示のとき途中で省略しない
(setq eval-expression-print-level nil)
(setq eval-expression-print-length nil)
;; リンクの設定
(setq w32-symlinks-handle-shortcuts t)
(require 'w32-symlinks)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; 動作設定
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; tmp file saving directory
(setq auto-save-list-file-prefix "~/local/.emacs.d/.saves-")
;; backup.file~ location
(setq make-backup-files t)
(setq backup-directory-alist
(cons (cons "\\.*$" (expand-file-name "~/local/.emacs.d"))
backup-directory-alist))
;; 前回編集していた場所を記憶し,ファイルを開いた時にそこへカーソルを移動
(require 'saveplace)
(setq-default save-place t)
;; auto-insert LAST-MODIFIED-DATE
(if (not (memq 'time-stamp write-file-hooks))
(setq write-file-hooks
(cons 'time-stamp write-file-hooks)))
(setq time-stamp-line-limit 40)
(setq time-stamp-format "%3b %02d %:y")
(setq system-time-locale "C")
;; dabbrev for japanese
(setq case-replace nil) ;dabbrev exact (upper or lower)case
(setq dabbrev-case-fold-search nil) ;dabbrev exact case
;; http://www.ysnb.net/meadow/meadow-users-jp/2000/msg00788.html
(defadvice dabbrev-expand (around jword (arg) activate)
(interactive "*P")
(let* ((regexp dabbrev-abbrev-char-regexp)
(dabbrev-abbrev-char-regexp regexp)
char ch)
(if (bobp)
()
(setq char (char-before)
ch (char-to-string char))
(cond
((string-match "[ァ-ヶー]" ch)
(setq dabbrev-abbrev-char-regexp "[ァ-ヶー]"))
((string-match "[ぁ-んー]" ch)
(setq dabbrev-abbrev-char-regexp "[ぁ-んー]"))
((string-match "[亜-瑤]" ch)
(setq dabbrev-abbrev-char-regexp "[亜-瑤]"))
((string-match "[A-Za-z0-9]" ch)
(setq dabbrev-abbrev-char-regexp "[A-Za-z0-9]"))
((eq (char-charset char) 'japanese-jisx0208)
(setq dabbrev-abbrev-char-regexp
(concat "["
(char-to-string (make-char 'japanese-jisx0208 48 33))
"-"
(char-to-string (make-char 'japanese-jisx0208 126 126))
"]")))))
ad-do-it))
;; "*Buffer List*" から動的補完する。
;; Javaのclass名をファイルに付けたらファイルの中でも補完できるように。
(setq dabbrev-ignored-buffer-names '("*Messages*"))
;; beep
(setq visible-bell nil)
;; diff
(setq diff-switches "-u")
;; elisp load-path
(add-to-list 'load-path "~/.emacs.d")
;; cc-mode
(defun my-c-mode-common-hook ()
(c-set-style "java")
)
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
(add-to-list 'auto-mode-alist '("\\.c\\'" . c++-mode))
(add-to-list 'auto-mode-alist '("\\.cpp\\'" . c++-mode))
(add-to-list 'auto-mode-alist '("\\.h\\'" . c++-mode))
(add-to-list 'auto-mode-alist '("\\.pl\\'" . perl-mode))
(add-to-list 'auto-mode-alist '("\\.rb\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode))
;;; js2-mode for JavaScript
;;(autoload 'js2-mode "js2" nil t)
;;(add-to-list 'auto-mode-alist '("\.js$" . js2-mode))
;;; actionscript-mode
;;(autoload 'actionscript-mode "actionscript-mode" "Major mode for actionscript." t)
;;(add-to-list 'auto-mode-alist '("\\.as$" . actionscript-mode))
;;; php-mode
;;(autoload 'php-mode "php-mode" nil t)
;;(add-hook 'php-mode-hook
;; '(lambda () (define-abbrev php-mode-abbrev-table "ex" "extends")))
;;(add-to-list 'auto-mode-alist '("\.php$" . php-mode))
;; Ini, batモード
(require 'generic-x)
;; moccur-edit
(require 'moccur-edit)
;; moccur-grep-findで.svnを無視する
(setq dmoccur-exclusion-mask
(append
'("\\~$" "\\.svn\\/\*" "bin\\/\*" "\\.jar$")
dmoccur-exclusion-mask))
;; scratchのメッセージ表示をしない
(setq initial-scratch-message "")
;; sessionの設定
(require 'session)
(setq inhibit-startup-message t)
(setq session-initialize '(de-saveplace session keys menus places)
session-globals-include '((kill-ring 50)
(session-file-alist nil)
(file-name-history 10000)))
;; これがないと file-name-history に500個保存する前に max-string に達する
(setq session-globals-max-string 100000000)
;; デフォルトでは30!
(setq history-length t)
(add-hook 'after-init-hook 'session-initialize)
;; 前回閉じたときの位置にカーソルを復帰
(setq session-undo-check -1)
;; wdired
(require 'wdired)
(define-key dired-mode-map "r" 'wdired-change-to-wdired-mode)
;; 行番号表示
(require 'linum)
;; タブ化
;;(require 'tabbar-extension)
;;(tabbar-mode)
(global-set-key [f9] 'linum-mode)
;; メージャーモード/マイナーモードでの指定
(defvar my-linum-hook-name nil)
(global-linum-mode t)
;; textile
(require 'textile-mode)
(add-to-list 'auto-mode-alist '("\.textile$" . textile-mode))
;; Dot-mode
(autoload 'graphviz-dot-mode "graphviz-dot-mode" "GraphViz DOT format" t)
(add-to-list 'auto-mode-alist '("\\.dot$" . graphviz-dot-mode))
;; uniq
(defun uniq-region (beg end)
"Remove duplicate lines, a` la Unix uniq.
If tempted, you can just do <<C-x h C-u M-| uniq RET>> on Unix."
(interactive "r")
(let ((ref-line nil))
(uniq beg end
(lambda (line) (string= line ref-line))
(lambda (line) (setq ref-line line)))))
(defun uniq-remove-dup-lines (beg end)
"Remove all duplicate lines wherever found in a file, rather than
just contiguous lines."
(interactive "r")
(let ((lines '()))
(uniq beg end
(lambda (line) (assoc line lines))
(lambda (line) (add-to-list 'lines (cons line t))))))
(defun uniq (beg end test-line add-line)
(save-restriction
(save-excursion
(narrow-to-region beg end)
(goto-char (point-min))
(while (not (eobp))
(if (funcall test-line (thing-at-point 'line))
(kill-line 1)
(progn
(funcall add-line (thing-at-point 'line))
(forward-line))))
(widen))))
(defun clipboard-to-buffer-file-name ()
"Put the current file name on the clipboard"
(interactive)
(let ((filename (if (equal major-mode 'dired-mode)
default-directory
(buffer-file-name))))
(when filename
(with-temp-buffer
(insert filename)
(clipboard-kill-region (point-min) (point-max)))
(message filename))))
;;; use groovy-mode when file ends in .groovy or has #!/bin/groovy at start
(autoload 'groovy-mode "groovy-mode" "Groovy editing mode." t)
(add-to-list 'auto-mode-alist '("\.groovy$" . groovy-mode))
(add-to-list 'interpreter-mode-alist '("groovy" . groovy-mode));;; Local Variables:
;; テンポラリバッファを作成し、それをウィンドウに表示します。
(defun create-temporary-buffer ()
"テンポラリバッファを作成し、それをウィンドウに表示します。"
(interactive)
;; *temp* なバッファを作成し、それをウィンドウに表示します。
(switch-to-buffer (generate-new-buffer "*temp*"))
;; セーブが必要ないことを示します?
(setq buffer-offer-save nil))
;; C-c t でテンポラリバッファを作成します。
(global-set-key "\C-ct" 'create-temporary-buffer)
(global-set-key "\C-h" 'backward-delete-char) ;C-h as BackSpace
(global-set-key "\M-?" 'help-for-help) ;M-? as help
;;(global-set-key "\C-q" 'dabbrev-expand)
(global-set-key "\C-m" 'newline-and-indent)
(global-set-key "\M-g" 'goto-line)
;;(global-set-key "\C-q" 'quoted-insert) ;C-q original
(defun buffer-menu-other-window-move ()
(interactive)
(buffer-menu-other-window)
(next-window))
(global-set-key "\C-x\C-b" 'buffer-menu-other-window-move)
(defun other-window-or-split ()
(interactive)
(when (one-window-p)
;;(split-window-horizontally)
(split-window-vertically)
)
(other-window 1))
;;(global-set-key "\C-t" 'other-window-or-split)
;; パスの設定
(let* ((cygwin-root "c:/cygwin")
(cygwin-bin (concat cygwin-root "/bin")))
;;(setenv "HOME" (concat cygwin-root "/home/eric"))
(setenv "PATH" (concat cygwin-bin ";" (getenv "PATH")))
(setq exec-path (cons cygwin-bin exec-path))
(setq shell-file-name "bash")
(setq explicit-shell-file-name "bash")
(add-hook 'comint-mode-hook 'ansi-color-for-comint-mode-on))
(cd "~") ;start on home directory
(setq-default indent-tabs-mode nil) ;When pushing [TAB], input WhiteSpaces.
;; 滑らかなスクロール
(setq redisplay-dont-pause t)
;; テーマ
;;(require 'color-theme)
;;(color-theme-initialize)
;;(color-theme-clarity)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; 日本語環境の設定
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(set-keyboard-coding-system 'japanese-shift-jis)
(setq default-input-method "W32-IME")
(w32-ime-initialize)
;; UTF-8⇔Legacy Encoding (EUC-JP や Shift_JIS など)をWindowsで変換
;; http://nijino.homelinux.net/emacs/emacs23-ja.html
(coding-system-put 'euc-jp :encode-translation-table
(get 'japanese-ucs-cp932-to-jis-map 'translation-table))
(coding-system-put 'iso-2022-jp :encode-translation-table
(get 'japanese-ucs-cp932-to-jis-map 'translation-table))
(coding-system-put 'cp932 :encode-translation-table
(get 'japanese-ucs-jis-to-cp932-map 'translation-table))
;; charset と coding-system の優先度設定
(set-charset-priority 'ascii 'japanese-jisx0208 'latin-jisx0201
'katakana-jisx0201 'iso-8859-1 'cp1252 'unicode)
(set-coding-system-priority 'utf-8 'euc-jp 'iso-2022-jp 'cp932)
;; East Asian Ambiguous
(defun set-east-asian-ambiguous-width (width)
(while (char-table-parent char-width-table)
(setq char-width-table (char-table-parent char-width-table)))
(let ((table (make-char-table nil)))
(dolist (range
'(#x00A1 #x00A4 (#x00A7 . #x00A8) #x00AA (#x00AD . #x00AE)
(#x00B0 . #x00B4) (#x00B6 . #x00BA) (#x00BC . #x00BF)
#x00C6 #x00D0 (#x00D7 . #x00D8) (#x00DE . #x00E1) #x00E6
(#x00E8 . #x00EA) (#x00EC . #x00ED) #x00F0
(#x00F2 . #x00F3) (#x00F7 . #x00FA) #x00FC #x00FE
#x0101 #x0111 #x0113 #x011B (#x0126 . #x0127) #x012B
(#x0131 . #x0133) #x0138 (#x013F . #x0142) #x0144
(#x0148 . #x014B) #x014D (#x0152 . #x0153)
(#x0166 . #x0167) #x016B #x01CE #x01D0 #x01D2 #x01D4
#x01D6 #x01D8 #x01DA #x01DC #x0251 #x0261 #x02C4 #x02C7
(#x02C9 . #x02CB) #x02CD #x02D0 (#x02D8 . #x02DB) #x02DD
#x02DF (#x0300 . #x036F) (#x0391 . #x03A9)
(#x03B1 . #x03C1) (#x03C3 . #x03C9) #x0401
(#x0410 . #x044F) #x0451 #x2010 (#x2013 . #x2016)
(#x2018 . #x2019) (#x201C . #x201D) (#x2020 . #x2022)
(#x2024 . #x2027) #x2030 (#x2032 . #x2033) #x2035 #x203B
#x203E #x2074 #x207F (#x2081 . #x2084) #x20AC #x2103
#x2105 #x2109 #x2113 #x2116 (#x2121 . #x2122) #x2126
#x212B (#x2153 . #x2154) (#x215B . #x215E)
(#x2160 . #x216B) (#x2170 . #x2179) (#x2190 . #x2199)
(#x21B8 . #x21B9) #x21D2 #x21D4 #x21E7 #x2200
(#x2202 . #x2203) (#x2207 . #x2208) #x220B #x220F #x2211
#x2215 #x221A (#x221D . #x2220) #x2223 #x2225
(#x2227 . #x222C) #x222E (#x2234 . #x2237)
(#x223C . #x223D) #x2248 #x224C #x2252 (#x2260 . #x2261)
(#x2264 . #x2267) (#x226A . #x226B) (#x226E . #x226F)
(#x2282 . #x2283) (#x2286 . #x2287) #x2295 #x2299 #x22A5
#x22BF #x2312 (#x2460 . #x24E9) (#x24EB . #x254B)
(#x2550 . #x2573) (#x2580 . #x258F) (#x2592 . #x2595)
(#x25A0 . #x25A1) (#x25A3 . #x25A9) (#x25B2 . #x25B3)
(#x25B6 . #x25B7) (#x25BC . #x25BD) (#x25C0 . #x25C1)
(#x25C6 . #x25C8) #x25CB (#x25CE . #x25D1)
(#x25E2 . #x25E5) #x25EF (#x2605 . #x2606) #x2609
(#x260E . #x260F) (#x2614 . #x2615) #x261C #x261E #x2640
#x2642 (#x2660 . #x2661) (#x2663 . #x2665)
(#x2667 . #x266A) (#x266C . #x266D) #x266F #x273D
(#x2776 . #x277F) (#xE000 . #xF8FF) (#xFE00 . #xFE0F)
#xFFFD
))
(set-char-table-range table range width))
(optimize-char-table table)
(set-char-table-parent table char-width-table)
(setq char-width-table table)))
(set-east-asian-ambiguous-width 2)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; 画面設定
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ウィンドウ(Emacs用語ではframe)設定
(setq default-frame-alist
(append (list
;; サイズ・位置
'(width . 80) ; 横幅(文字数)
'(height . 46) ; 高さ(行数)
'(top . 50) ; フレーム左上角 y 座標
'(left . 50) ; フレーム左上角 x 座標
)
default-frame-alist))
;; 背景色を黒、文字を白、カーソルをグレー
(set-background-color "Black")
(set-foreground-color "White")
;; シンタックスハイライト用
(set-face-bold-p 'font-lock-function-name-face t)
;; erase memubar, scrollbar
;;(menu-bar-mode -1) ;画面上に出るメニュー(文字)を消す
(tool-bar-mode -1) ;画面上に出るツールバー(アイコン画像)を消す
;(scroll-bar-mode -1) ;画面横に出るスクロールバーを消す
(setq inhibit-startup-message t) ;スプラッシュ(起動画面)抑止
(column-number-mode 1)
;; emacs-server
;;(server-start)
;; フォント設定
(set-default-font "Osaka-等幅-11")
;; (set-fontset-font "fontset-default"
;; 'japanese-jisx0208
;; '("Osaka-UI" . "iso10646-1"))
;; (set-fontset-font "fontset-default"
;; 'katakana-jisx0201
;; '("Osaka-UI" . "iso10646-1"))
;; (set-default-font "Courier New-10")
;; (set-fontset-font (frame-parameter nil 'font)
;; 'japanese-jisx0208
;; '("Osaka-UI" . "unicode-bmp"))
;;(set-default-font "MS ゴシック-10")
;; color
(global-font-lock-mode t) ;font-lock use-all
(transient-mark-mode t) ;選択したとき色がつくようにする
;; kill-ring はテキスト属性(色情報など)を保存しなくていい
;; http://www-tsujii.is.s.u-tokyo.ac.jp/~yoshinag/tips/elisp_tips.html#yankoff
(defadvice kill-new (around my-kill-ring-disable-text-property activate)
(let ((new (ad-get-arg 0)))
(set-text-properties 0 (length new) nil new)
ad-do-it))
;; タブ, 全角スペースを色つき表示する (色名は M-x list-color-displayで調べる)
;; http://homepage1.nifty.com/blankspace/emacs/color.html
(defface my-face-b-1 '((t (:background "LightGray"))) nil)
(defface my-face-b-2 '((t (:background "gray7"))) nil)
(defvar my-face-b-1 'my-face-b-1)
(defvar my-face-b-2 'my-face-b-2)
(defadvice font-lock-mode (before my-font-lock-mode ())
(font-lock-add-keywords
major-mode
'(("\t" 0 my-face-b-2 append)
(" " 0 my-face-b-1 append)
("[ \t]+$" 0 my-face-b-1 append)
)))
(ad-enable-advice 'font-lock-mode 'before 'my-font-lock-mode)
(ad-activate 'font-lock-mode)
;; IMEのON/OFFでカーソルの色を変える
(set-cursor-color "cyan")
(add-hook 'w32-ime-on-hook
(function (lambda () (set-cursor-color "LimeGreen"))))
(add-hook 'w32-ime-off-hook
(function (lambda () (set-cursor-color "cyan"))))
;; elisp変数表示のとき途中で省略しない
(setq eval-expression-print-level nil)
(setq eval-expression-print-length nil)
;; リンクの設定
(setq w32-symlinks-handle-shortcuts t)
(require 'w32-symlinks)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; 動作設定
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; tmp file saving directory
(setq auto-save-list-file-prefix "~/local/.emacs.d/.saves-")
;; backup.file~ location
(setq make-backup-files t)
(setq backup-directory-alist
(cons (cons "\\.*$" (expand-file-name "~/local/.emacs.d"))
backup-directory-alist))
;; 前回編集していた場所を記憶し,ファイルを開いた時にそこへカーソルを移動
(require 'saveplace)
(setq-default save-place t)
;; auto-insert LAST-MODIFIED-DATE
(if (not (memq 'time-stamp write-file-hooks))
(setq write-file-hooks
(cons 'time-stamp write-file-hooks)))
(setq time-stamp-line-limit 40)
(setq time-stamp-format "%3b %02d %:y")
(setq system-time-locale "C")
;; dabbrev for japanese
(setq case-replace nil) ;dabbrev exact (upper or lower)case
(setq dabbrev-case-fold-search nil) ;dabbrev exact case
;; http://www.ysnb.net/meadow/meadow-users-jp/2000/msg00788.html
(defadvice dabbrev-expand (around jword (arg) activate)
(interactive "*P")
(let* ((regexp dabbrev-abbrev-char-regexp)
(dabbrev-abbrev-char-regexp regexp)
char ch)
(if (bobp)
()
(setq char (char-before)
ch (char-to-string char))
(cond
((string-match "[ァ-ヶー]" ch)
(setq dabbrev-abbrev-char-regexp "[ァ-ヶー]"))
((string-match "[ぁ-んー]" ch)
(setq dabbrev-abbrev-char-regexp "[ぁ-んー]"))
((string-match "[亜-瑤]" ch)
(setq dabbrev-abbrev-char-regexp "[亜-瑤]"))
((string-match "[A-Za-z0-9]" ch)
(setq dabbrev-abbrev-char-regexp "[A-Za-z0-9]"))
((eq (char-charset char) 'japanese-jisx0208)
(setq dabbrev-abbrev-char-regexp
(concat "["
(char-to-string (make-char 'japanese-jisx0208 48 33))
"-"
(char-to-string (make-char 'japanese-jisx0208 126 126))
"]")))))
ad-do-it))
;; "*Buffer List*" から動的補完する。
;; Javaのclass名をファイルに付けたらファイルの中でも補完できるように。
(setq dabbrev-ignored-buffer-names '("*Messages*"))
;; beep
(setq visible-bell nil)
;; diff
(setq diff-switches "-u")
;; elisp load-path
(add-to-list 'load-path "~/.emacs.d")
;; cc-mode
(defun my-c-mode-common-hook ()
(c-set-style "java")
)
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
(add-to-list 'auto-mode-alist '("\\.c\\'" . c++-mode))
(add-to-list 'auto-mode-alist '("\\.cpp\\'" . c++-mode))
(add-to-list 'auto-mode-alist '("\\.h\\'" . c++-mode))
(add-to-list 'auto-mode-alist '("\\.pl\\'" . perl-mode))
(add-to-list 'auto-mode-alist '("\\.rb\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode))
;;; js2-mode for JavaScript
;;(autoload 'js2-mode "js2" nil t)
;;(add-to-list 'auto-mode-alist '("\.js$" . js2-mode))
;;; actionscript-mode
;;(autoload 'actionscript-mode "actionscript-mode" "Major mode for actionscript." t)
;;(add-to-list 'auto-mode-alist '("\\.as$" . actionscript-mode))
;;; php-mode
;;(autoload 'php-mode "php-mode" nil t)
;;(add-hook 'php-mode-hook
;; '(lambda () (define-abbrev php-mode-abbrev-table "ex" "extends")))
;;(add-to-list 'auto-mode-alist '("\.php$" . php-mode))
;; Ini, batモード
(require 'generic-x)
;; moccur-edit
(require 'moccur-edit)
;; moccur-grep-findで.svnを無視する
(setq dmoccur-exclusion-mask
(append
'("\\~$" "\\.svn\\/\*" "bin\\/\*" "\\.jar$")
dmoccur-exclusion-mask))
;; scratchのメッセージ表示をしない
(setq initial-scratch-message "")
;; sessionの設定
(require 'session)
(setq inhibit-startup-message t)
(setq session-initialize '(de-saveplace session keys menus places)
session-globals-include '((kill-ring 50)
(session-file-alist nil)
(file-name-history 10000)))
;; これがないと file-name-history に500個保存する前に max-string に達する
(setq session-globals-max-string 100000000)
;; デフォルトでは30!
(setq history-length t)
(add-hook 'after-init-hook 'session-initialize)
;; 前回閉じたときの位置にカーソルを復帰
(setq session-undo-check -1)
;; wdired
(require 'wdired)
(define-key dired-mode-map "r" 'wdired-change-to-wdired-mode)
;; 行番号表示
(require 'linum)
;; タブ化
;;(require 'tabbar-extension)
;;(tabbar-mode)
(global-set-key [f9] 'linum-mode)
;; メージャーモード/マイナーモードでの指定
(defvar my-linum-hook-name nil)
(global-linum-mode t)
;; textile
(require 'textile-mode)
(add-to-list 'auto-mode-alist '("\.textile$" . textile-mode))
;; Dot-mode
(autoload 'graphviz-dot-mode "graphviz-dot-mode" "GraphViz DOT format" t)
(add-to-list 'auto-mode-alist '("\\.dot$" . graphviz-dot-mode))
;; uniq
(defun uniq-region (beg end)
"Remove duplicate lines, a` la Unix uniq.
If tempted, you can just do <<C-x h C-u M-| uniq RET>> on Unix."
(interactive "r")
(let ((ref-line nil))
(uniq beg end
(lambda (line) (string= line ref-line))
(lambda (line) (setq ref-line line)))))
(defun uniq-remove-dup-lines (beg end)
"Remove all duplicate lines wherever found in a file, rather than
just contiguous lines."
(interactive "r")
(let ((lines '()))
(uniq beg end
(lambda (line) (assoc line lines))
(lambda (line) (add-to-list 'lines (cons line t))))))
(defun uniq (beg end test-line add-line)
(save-restriction
(save-excursion
(narrow-to-region beg end)
(goto-char (point-min))
(while (not (eobp))
(if (funcall test-line (thing-at-point 'line))
(kill-line 1)
(progn
(funcall add-line (thing-at-point 'line))
(forward-line))))
(widen))))
(defun clipboard-to-buffer-file-name ()
"Put the current file name on the clipboard"
(interactive)
(let ((filename (if (equal major-mode 'dired-mode)
default-directory
(buffer-file-name))))
(when filename
(with-temp-buffer
(insert filename)
(clipboard-kill-region (point-min) (point-max)))
(message filename))))
;;; use groovy-mode when file ends in .groovy or has #!/bin/groovy at start
(autoload 'groovy-mode "groovy-mode" "Groovy editing mode." t)
(add-to-list 'auto-mode-alist '("\.groovy$" . groovy-mode))
(add-to-list 'interpreter-mode-alist '("groovy" . groovy-mode));;; Local Variables:
;; テンポラリバッファを作成し、それをウィンドウに表示します。
(defun create-temporary-buffer ()
"テンポラリバッファを作成し、それをウィンドウに表示します。"
(interactive)
;; *temp* なバッファを作成し、それをウィンドウに表示します。
(switch-to-buffer (generate-new-buffer "*temp*"))
;; セーブが必要ないことを示します?
(setq buffer-offer-save nil))
;; C-c t でテンポラリバッファを作成します。
(global-set-key "\C-ct" 'create-temporary-buffer)
登録:
投稿 (Atom)