emacsの設定メモ

自分のemacsの設定。使用しているemacsNTEmacs

;;; 日本語環境設定
(set-language-environment "Japanese")

;; IMEの設定
(setq default-input-method "MW32-IME")
(setq-default w32-ime-mode-line-state-indicator "[--]")
(setq w32-ime-mode-line-state-indicator-list '("[--]" "[あ]" "[--]"))
(add-hook 'w32-ime-on-hook
	  (function (lambda () (set-cursor-height 2))))
(add-hook 'w32-ime-off-hook
	  (function (lambda () (set-cursor-height 4))))

;; isearchで日本語を検索できるようにする
(defun w32-isearch-update ()
  (interactive)
  (isearch-update))
(define-key isearch-mode-map [compend] 'w32-isearch-update)
(define-key isearch-mode-map [kanji] 'isearch-toggle-input-method)

;; IMEの制御(yes/noをタイプするところでは IME をオフにする)
(wrap-function-to-control-ime 'universal-argument t nil)
(wrap-function-to-control-ime 'read-string nil nil)
(wrap-function-to-control-ime 'read-char nil nil)
(wrap-function-to-control-ime 'read-from-minibuffer nil nil)
(wrap-function-to-control-ime 'y-or-n-p nil nil)
(wrap-function-to-control-ime 'yes-or-no-p nil nil)
(wrap-function-to-control-ime 'map-y-or-n-p nil nil)

;;; font-lockの設定
(global-font-lock-mode t)

;;コメントの色
(set-face-foreground 'font-lock-comment-face "#008000")

;; リージョンをC-hで削除できるように変更
(delete-selection-mode t)

;;; *.~ とかのバックアップファイルを作らない
(setq make-backup-files nil)
;;; .#* とかのバックアップファイルを作らない
(setq auto-save-default nil)

;; 列番号を表示
(column-number-mode t)
;; 行番号を表示
(line-number-mode t)

;;フォント設定
(if (eq window-system 'w32) (require 'ntemacs-font))
(fixed-width-set-fontset "msgothic" 12)

;; 初期フレームの設定
(setq default-frame-alist
      (append (list '(foreground-color . "black")
		    '(background-color . "white")
		    '(background-color . "gray")
		    '(border-color . "black")
		    '(mouse-color . "white")
		    '(cursor-color . "black")
;;		    '(ime-font . (w32-logfont "MS ゴシック"
;;					      0 16 400 0 nil nil nil
;;					      128 1 3 49)) ; TrueType のみ
;;		    '(font . "bdf-fontset")    ; BDF
;;		    '(font . "private-fontset"); TrueType
		    '(width . 80)
		    '(height . 40)
		    '(top . 100)
		    '(left . 100))
	      default-frame-alist))


;; 折り返さないためにはこの変数をnilにする必要がある
(setq truncate-partial-width-windows t)
;; 折り返さない
(setq-default truncate-lines t)

;;タブ幅の設定
(setq-default tab-width 4)

;;対応括弧をハイライト
(show-paren-mode t)
;; (setq show-paren-style 'expression)

;; ;;; Cygwin の bash を使う場合
(setq explicit-shell-file-name "bash.exe") 
(setq shell-file-name "sh.exe") 
(setq shell-command-switch "-c")

;; /cygdrive/x をx: に置き換える
(defadvice expand-file-name (before strip-cygdrive (NAME &optional DEFAULT-DIRECTORY) activate)
"replace /cygdrive/x to x: in path string."
(if (string-match "^/cygdrive/\\([a-zA-Z]\\)/" NAME)
(setq NAME (replace-match "\\1:/" nil nil NAME))))

;;現在開いているファイルのフルパスの確認
(setq frame-title-format (format "%%f - Emacs@%s" (system-name)))

;;時間を表示する
(display-time)

;; 最近使ったファイルを保存(M-x recentf-open-filesで開く)
(recentf-mode)

;; C-hをBackSpaceキーに変更
(keyboard-translate ?\C-h ?\C-?)
(global-set-key "\C-h" nil)

;; バッファ間の移動をShift + カーソルキーで移動
(windmove-default-keybindings)
(setq windmove-wrap-around t)

;; 設定ファイルの読み込み
(load-file "~/.emacs.d/myconfig.el")