Emacs > .emacs > .emacs(2011.10.20)

;; .emacs                                         
;; Last Updated : 2011/10/20 Thu 09:26:23       

(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)
 '(show-paren-mode t))
(custom-set-faces
  ;; custom-set-faces 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.
 '(default ((t (:inherit nil :stipple nil :background "gray7" :foreground "white" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 98 :width normal :foundry "unknown" :family "Takaoゴシック")))))

(if window-system (progn
    ;; 文字の色を設定
    (add-to-list 'default-frame-alist '(foreground-color . "white"))
    ;; 背景色を設定
    (add-to-list 'default-frame-alist '(background-color . "gray7"))
    ;; カーソルの色を設定
    (add-to-list 'default-frame-alist '(cursor-color . "SlateBlue2"))
    ;; ;; マウスポインタの色を設定
    ;; (add-to-list 'default-frame-alist '(mouse-color . "SlateBlue2"))
    ;; ;; モードラインの文字の色を設定
    ;; (set-face-foreground 'modeline "white")
    ;; ;; モードラインの背景色を設定
    ;; (set-face-background 'modeline "MediumPurple2")
    ;; ;; 選択中のリージョンの色を設定
    (set-face-background 'region "Dark Slate Grey")
    ;; ;; モードライン(アクティブでないバッファ)の文字色を設定
    ;; (set-face-foreground 'mode-line-inactive "gray30")
    ;; ;; モードライン(アクティブでないバッファ)の背景色を設定
    ;; (set-face-background 'mode-line-inactive "gray85")
    (set-face-foreground 'font-lock-comment-face "darkorange") ;; コメント
    (set-face-foreground 'font-lock-string-face  "hotpink") ;; ""で囲まれた文字
    (set-face-foreground 'font-lock-keyword-face "cyan") 
    (set-face-foreground 'font-lock-function-name-face "white")
    (set-face-foreground 'font-lock-variable-name-face "white")
    (set-face-foreground 'font-lock-type-face "skyblue1") 
    (set-face-foreground 'font-lock-warning-face "yellow")
    (set-face-foreground 'font-lock-builtin-face "lightsteelblue")
    ))
;;auto-install.elのインストール手順
;; $mkdir -p ~/.emacs.d/auto-install
;; cd ~/.emacs.d/auto-install
;; wget http://www.emacswiki.org/emacs/download/auto-install.el
;; emacs --batch -Q -f batch-byte-compile auto-install.el

;;;Emacs Lispインストーラを利用
(add-to-list 'load-path "~/.emacs.d/auto-install")
(add-to-list 'load-path "~/.emacs.d/plugins/yasnippet-0.6.1c/")
;;;>install-elisp-from-emacswiki "auto-install.el"
(require 'auto-install)
;;起動時にEmacswikiのページを補完候補に加える
;;(auto-install-update-emacswiki-package-name t)
;;install-elisp.el互換モード
(auto-install-compatibility-setup)
;;ediff関連のバッファを一つのフレームにまとめる
(setq ediff-window-setup-function 'ediff-setup-windows-plain)


;;================================================================================
;; 基本設定
;;================================================================================
;; スタートアップを非表示
(setq inhibit-startup-screen -1)

;; ビープ音を消す
(setq ring-bell-function 'ignore)

;; 現在行に色をつける
(global-hl-line-mode 1)
;;  その行の色
(set-face-background 'hl-line "black")

;; 履歴を次回Emacs起動時にも保存する
(savehist-mode 1)

;; 対応する括弧を光らせる
(show-paren-mode 1)

;; カーソルの位置が何文字目かを表示する
(column-number-mode t)

;; バックアップファイルを作らない
(setq backup-inhibited t)

;; Xでのクリップボードを共有
(setq x-select-enable-clipboard t)

;; yes-or-noをy-or-nに省略
(defalias 'yes-or-no-p 'y-or-n-p)

;; 行の先頭でC-kを一回押すだけで行全体を消去する
(setq kill-whole-line t)

;; ツールバーを非表示
(tool-bar-mode -1)

;; メニューバーを非表示
(menu-bar-mode -1)

;; 圧縮されたファイルも編集できるようにする
(auto-compression-mode t)

;; スクロールを一行ずつにする
(setq scroll-step 1)

;;; 現在の関数名をモードラインに表示
(which-function-mode 1)

;;; emacsclient
;; ファイルを現在のemacsで開く
;(server-start)

;;------------------------ キーバインドの変更 ----------------------------------
;;  指定の行に移る
(global-set-key "\M-g" 'goto-line)

;;  undo
(global-set-key "\C-z" 'undo)

;;  ウィンドウの移動をM-tに
(global-set-key "\M-t" 'other-window)

;;  C-hをBackSpaceに
(global-set-key "\C-h" 'delete-backward-char)

;;  M-x compile を f5 に
(global-set-key [f5] 'compile)

;;;-------------------  初期フレームの設定 ------------------------------------
(setq initial-frame-alist
      (append
       '((width . 45)    ; フレーム幅(文字数)
	  (height . 92))   ; フレーム高(文字数)
       initial-frame-alist))

;;; 新規フレームのデフォルト設定
(setq default-frame-alist
      (append
       '((width . 45)	; フレーム幅(文字数)
	 (height  . 92))	; フレーム高(文字数)	
       default-frame-alist))

;;; ファイル更新日を自動的に書き換える。
;;  ファイルの頭に "last updated : "をつけくわえればよい
(require 'time-stamp)

;; 日本語で日付を入れたくないのでlocaleをCにする
(defun time-stamp-with-locale-c ()
  (let ((system-time-locale "C"))
    (time-stamp)
    nil))

(if (not (memq 'time-stamp-with-locale-c write-file-hooks))
    (add-hook 'write-file-hooks 'time-stamp-with-locale-c))

(setq time-stamp-active t)
(setq time-stamp-start "Last Updated : ")
(setq time-stamp-format "%04y/%02m/%02d %3a %02H:%02M:%02S")
(setq time-stamp-end "  ") ;;;Last Updated : の後に空白2つ以上いれると置換

;;; タイトルバーにファイル名を表示する
(setq frame-title-format (format "emacs@%s : %%f" (system-name)))

;;; ファイルの自動挿入
(auto-insert-mode)
;;  自動挿入するファイルのあるディレクトリ
;;  最後の/は必須
(setq auto-insert-directory "~/.emacs.d/insert/")
;;  自動挿入するファイル
(define-auto-insert "\\.c" "c-template.c")

;;================================================================================
;;; viewer.el view-modeの設定
;;  M-x install-elisp-from-emacswiki viewer.el
;;
;;  C-x C-rでview-modeでファイルを開く 
(setq view-read-only t)
;;  書き込み不能な場合はview-modeを抜けないように
(require 'viewer)
(viewer-stay-in-setup)
;;  .log .out .datファイルをview-modeで開く
(setq view-mode-by-default-regexp "\\.log")
(setq view-mode-by-default-regexp "\\.out")
(setq view-mode-by-default-regexp "\\.dat")

;;; view-mode時にモードラインに色をつける
;;  色名を指定
(setq viewer-modeline-color-unwritable "tomato")
(setq viewer-modeline-color-view "orange")
(viewer-change-modeline-color-setup)

;;  view-mode時のキーバインド
(define-key view-mode-map "h" 'backward-char)
(define-key view-mode-map "j" 'next-line)
(define-key view-mode-map "k" 'previous-line)
(define-key view-mode-map "l" 'forward-char)
(define-key view-mode-map "J" 'View-scroll-line-forward)
(define-key view-mode-map "K" 'View-scroll-line-backward)
(define-key view-mode-map "b" 'scroll-down)
(define-key view-mode-map " " 'scroll-up)
;; ;;  bm.el
(define-key view-mode-map "m" 'bm-toggle)
(define-key view-mode-map "[" 'bm-previous)
(define-key view-mode-map "]" 'bm-next)

;;  view-modeを有効・無効にする
;;  0.04秒以内に jk を同時押しでview-modeに移行
(require 'key-chord)
(setq key-chord-two-keys-delay 0.04)
(key-chord-mode 1)
(key-chord-define-global "jk" 'view-mode)

;================================================================================
;;; redo+.el
(require 'redo+)
;;  M-zに設定
(global-set-key "\M-z" 'redo)
(setq undo-no-redo t); 過去のundoがredoされないようにする
;; 大量のundoに耐えられるようにする
(setq undo-limit 600000)
(setq undo-strong-limit 900000)

;;;fullscreen.el
(require 'fullscreen)

;;;-------------------- recentf-ext.el --------------------------
;; install-elisp-from-emacswiki recentf-ext.el
;; 保存しておく数
(setq recentf-max-saved-items 1000)
;; 最近使ったファイルに加えないファイルを正規表現で指定する
(setq recentf-exclude '("/TAGS$" "/var/tmp/"))
(require 'recentf-ext)
;; f8をショートカットキーに
(global-set-key [f8] 'recentf-open-files)

;;; auto-complete.el
;; install-elisp-from-emacswiki auto-complete.el
;;(require 'auto-complete)
;;(global-auto-complete-mode 1)

;;;col-highlight.el
;; auto-install-batch col-highlight.el
;(require 'col-highlight)
;(column-highlight-mode 1)
;;何もしないでいるとハイライトを始めるようにする場合
;(toggle-highlight-column-when-idle 1)
;(col-highlight-set-interval 3)

;;;=============================  hippie-expand ====================================
;;; 略語展開の順を設定
(setq hippie-expand-try-functions-list
      '(try-expand-dabbrev
        try-expand-dabbrev-all-buffers
        try-expand-dabbrev-from-kill
        try-complete-file-name-partially
        try-complete-file-name
        try-expand-all-abbrevs
        try-expand-list try-expand-line
        try-complete-lisp-symbol-partially
        try-complete-lisp-symbol))
;; キーバインドの変更 C-;
(global-set-key [?\C-\;] 'hippie-expand )
		 
;;; ipa.el
(require 'ipa)
;;; 背景色
(set-face-background 'highlight "Corn Flower Blue")
		 
;;;---------------------- sequential-command.el---------------------------------
;;; M-x auto-install-batch sequential-command
(require 'sequential-command-config)
(sequential-command-setup-keys)
		 
;;================================================================================
;;; smartchr.el 
;;  M-x install-elisp 
;;  https://github.com/imakado/emacs-smartchr/raw/master/smartchr.el
(require 'smartchr)
;;  once "", twice "
(global-set-key (kbd "\"") (smartchr '("\"`!!'\"" "\"")))

(add-hook 'c-mode-hook
	  '(lambda ()
	     (local-set-key ( kbd "(") (smartchr '("( `!!' )" "()" "(")))
	     (local-set-key ( kbd "\'") (smartchr '("\'`!!'\'" "\'")))
	     (local-set-key ( kbd "\,") (smartchr '("\, " "\,")))
	     (local-set-key (kbd "[") (smartchr '("[ `!!' ]" "[")))
	     (local-set-key (kbd "=") (smartchr '("= " "==" "=")))	     
	     ))
(add-hook 'c++-mode-hook
	  '(lambda ()
	     (local-set-key ( kbd "(") (smartchr '("( `!!' )" "()" "(")))
	     (local-set-key ( kbd "\'") (smartchr '("\'`!!'\'" "\'")))
	     (local-set-key ( kbd "\,") (smartchr '("\, " "\,")))
	     (local-set-key (kbd "[") (smartchr '("[ `!!' ]" "[")))
	     (local-set-key (kbd "=") (smartchr '("= " "== " "=")))	     
	     ))
(add-hook 'org-mode-hook
	  '(lambda ()
	     (local-set-key ( kbd "$" ) ( smartchr '("`!!'" "$" )))
	     (local-set-key ( kbd "\{" ) ( smartchr '("\{`!!'\}" "\{" )))
	     ))

;;;----------------------- auto-save-buffers.el ---------------------------------
;;  M-x install-elisp
;;  http://homepage3.nifty.com/oatu/emacs/archives/auto-save-buffers.el
(require 'auto-save-buffers)
;;  アイドル0.5秒で保存
(run-with-idle-timer 0.5 t 'auto-save-buffers)
(run-with-idle-timer 0.5 t 'auto-save-buffers ""   ".ipa$")

;;; open-junk-file.el
;;  M-x install-elisp-from-emacswiki open-junk-file.el
;;  Usage: M-x open-junk-file
(require 'open-junk-file)
(setq open-junk-file-format "~/junk/%Y-%m-%d-%H%M%S.")
(global-set-key "\C-x\C-j" 'open-junk-file)

;;; bm.el
;;  M-x install-elisp
;;  http://cvs.savannah.gnu.org/viewvc/*checkout*/bm/bm/bm.el
(setq-default bm-buffer-persistence nil)
(setq bm-restore-repository-on-load t)
(require 'bm)
(add-hook 'find-file-hooks 'bm-buffer-restore)
(add-hook 'kill-buffer-hook 'bm-buffer-save)
(add-hook 'after-save-hook 'bm-buffer-save)
(add-hook 'after-revert-hook 'bm-buffer-restore)
(add-hook 'vc-before-checkin-hook 'bm-buffer-save)
(global-set-key [f7] 'bm-toggle)
(global-set-key "\C-xp" 'bm-previous)
(global-set-key "\C-xn" 'bm-next)

;;; twittering-mode
(add-to-list 'load-path "~/.emacs.d/twittering-mode-1.0.0/")
(require 'twittering-mode)
;; Show icons
(setq twittering-icon-mode t)                
;; Update your timeline each 300 seconds (5 minutes)
(setq twittering-timer-interval 30)         
(add-hook 'twittering-mode-hook
	  (lambda ()
	    (mapc (lambda (pair)
		    (let ((key (car pair))
			  (func (cdr pair)))
		      (define-key twittering-mode-map
			(read-kbd-macro key) func)))
		  '(("F" . twittering-friends-timeline)
		    ("R" . twittering-replies-timeline)
		    ("U" . twittering-user-timeline)
		    ("W" . twittering-update-status-interactive)))))

;;;==================  Latex  ========================================
;;  日本語コードをeuc-japanに
(set-language-environment "Japanese")
(set-default-coding-systems 'euc-japan)
(set-terminal-coding-system 'euc-japan)

;;; Yatex
(setq YaTeX-inhibit-prefix-letter nil)
(setq dvi2-command "xdvi -geo +0+0 -s 7 -expert -watchfile 3")

;;;reftex
(add-hook 'latex-mode-hook 'turn-on-reftex) ; with Emacs latex mode
(add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; with AUCTeX LaTeX mode
(add-hook 'yatex-mode-hook 'turn-on-reftex) ; with YaTeX mode

;;------------------- 行番号の表示 ---------------------------------
(autoload 'setnu-mode "setnu" nil t)
(global-set-key [f12] 'setnu-mode)

;;==========================  kmacro-save ===============================
(defvar kmacro-save-file "~/.emacs" "キーボードマクロを保存するファイル")
(defun kmacro-save (symbol)
  (interactive "name for last kbd macro: ")
  (name-last-kbd-macro symbol)
  (with-current-buffer (find-file-noselect kmacro-save-file)
    (goto-char (point-max))
    (insert-kbd-macro symbol)
    (basic-save-buffer)))

;; 現在行をコピー
(fset 'select-this-line "\C-e\C-@\C-a\M-w")
(global-set-key [?\C-\,] 'select-this-line)

;; 文末に;を入力
(fset 'insert-statement-end "\C-e;\C-j")
(global-set-key [?\C-\.] 'insert-statement-end)

;; {}を改行してインデント
(fset 'parentheses-and-indent "\C-e{\C-j\C-j}\C-p")
(global-set-key [?\M-\[] 'parentheses-and-indent)

;; インデントして次の行へ
(fset 'indent-and-next "\C-i\C-n")
(global-set-key [?\M-i] 'indent-and-next)

;;------------- yasnippet.el -------------------------------
(require 'yasnippet-config)
(yas/setup "~/.emacs.d/plugins/yasnippet-0.6.1c")

;;-------------  iswitchb.el -------------------------------
;; バッファ切り替えを部分文字列で可能に
(iswitchb-mode 1)
(setq read-buffer-function 'iswitchb-read-buffer)
(setq iswitchb-regexp nil)
;; 新しいバッファ作成するときは聞かない
(setq iswitchb-prompt-newbuffer nil)

;; uniquify.el
(require 'uniquify)
;; filename<dir>の形式
(setq uniquify-buffer-name-style 'post-forward-angle-brackets)
;; *で囲まれたバッファ名は対象外にする
(setq uniquify-ignore-buffers-re "*[^*]+*")

;;---------------html-helper-mode------------------------------
(require 'html-helper-mode)
(require 'html-mode)
(require 'tempo)

;;--------------org-mode---------------------------------------
(require 'org)
(defun org-insert-upheading-dwim (arg)
  "1レベル上の見出しを入力する"
  (interactive "P")
  (org-insert-heading arg)
  (cond ((org-on-heading-p) (org-do-promote))
	((org-at-item-p) (org-indent-item -1))))
(defun org-insert-heading-dwim (arg)
  "現在と同じレベルの見出しを入力する。"
  "C-u:1レベル上"
  "C-u C-u:1レベル下"
  (interactive "p")
  (case arg
    (4  (org-insert-subheading nil)) ;C-u
    (16 (org-insert-upheading nil))  ;C-u C-u
    (t  (org-insert-heading nil))))
(define-key org-mode-map (kbd "<C-return>") 'org-insert-heading-dwim)

(org-remember-insinuate)
;; メモを格納するorgファイルの設定
(setq org-directory "~/Documents/memo")
(setq org-default-notes-file (expand-file-name "memo.org" org-directory))
;; テンプレートの設定
(setq org-remember-templates
      '(("Note" ?n "** %?\n %i\n %a\n %T" nil "Inbox")
	("Todo" ?t "** TODO %?\n %i\n %a\n %T" nil "Inbox")))
;; Select template: [n]ote [t]odo
(global-set-key [f1] 'org-remember)

;; TODOリストの設定
(setq org-use-fast-todo-selection t)
(setq org-todo-keywords
      '((sequence "TODO(t)" "STARTED(s)" "WAITING(w)" "|" "DONE(x)" "CANCEL(c)")
	(sequence "APPT(a)" "|" "DONE(x)" "CANCEL(c)" )))

;; ハイパーリンクの作成
(global-set-key (kbd "C-c l") 'org-store-link)

;; M-x org-rememberによるメモを集めるorgファイル
(setq org-default-notes-file "~/Documents/memo/plan.org")
;; 予定表に使うorgファイルのリスト
(setq org-agenda-files (list org-default-notes-file))
(global-set-key (kbd "C-c a") 'org-agenda)

;; w3m
(require 'w3m-load)
(setq w3m-home-page "www.google.co.jp/") ;起動時に開くページ
(setq w3m-use-cookies t) ;クッキーを使う
(setq w3m-bookmark- "~/.w3m/bookmark.html") ;ブックマークを保存する
(setq browse-url-browser-function 'w3m-browse-url)
(autoload 'w3m-browse-url "w3m" "Ask a  browser to show a URL." t)
(global-set-key "\C-xm" 'browse-url-at-point)
(autoload 'w3m-find-file "w3m" "w3m interface function for local file." t)

(autoload 'w3m-search "w3m-search" "Search QUERY using SEARCH-ENGIN." t)
(setq w3m-search-default-engin "google-ja")
(global-set-key "\C-cs" 'w3m-search)

(autoload 'w3m-weather "w3m-weather" "Display weather report." t)
(autoload 'w3m-antenna "w3m-antenna" "Report change of WEB ." t)
(autoload 'w3m- "w3m-namazu" "Search files with Namazu." t)

;; 折りたたみ
(require 'fold-dwim)

;; コンパイルでの*compilation*ウィンドウの文字コード調整
(add-hook 'set-language-environment-hook 
	  (lambda ()
	    (when (equal "ja_JP.UTF-8" (getenv "LANG"))
	      (setq default-process-coding-system '(utf-8 . utf-8))
	      (setq default-file-name-coding-system 'utf-8))
	    (when (equal "Japanese" current-language-environment)
	      (setq default-buffer-file-coding-system 'iso-2022-jp))))
(set-language-environment "Japanese")
最終更新:2011年10月20日 10:19