.emacsの内容

最近大学の講義をきっかけにCygwin+Meadow環境をつくりました。
いろんなところから引っ張ってきてできた、いま現在のMeadowの設定を公開してみる。

;; 起動時のメッセージを表示しない
(setq inhibit-startup-message t)


;;; シェル設定
;; Cygwinのbashをつかう
(setq explicit-shell-file-name "bash.exe")
(setq shell-file-name "sh.exe")
(setq shell-command-switch "-c")
(modify-coding-system-alist 'process "shell" '(undecided-dos . utf-8))
;; argument-editing の設定
(require 'mw32script)
(mw32script-init)
(setq exec-suffix-list '(".exe" ".sh" ".pl"))
;; coding-systemの設定
(add-hook 'shell-mode-hook
	  (lambda ()
	    (set-buffer-process-coding-system 'undecided-dos 'sjis-unix)))

;; ^Mをとる
(add-hook 'commit-output-filter-functions 'shell-strip-ctrl-m nil t)

;; shell-modeでの補完 (for drive letter)
(setq shell-file-name-chars "~/A-Za-z0-9_^$!#%&{}@'`.,;()-")

;; homeディレクトリへの移動
(cd "~")

;;; 文字コード
;; unicode設定(mule-ucs)
(require 'un-define)
(require 'jisx0213)

;;; フォント
(create-fontset-from-request "private-fontset"
                             '((width . 7)
                               (height . 14)
                               (fixed . t)
                               (italic . nil))
                             '((family . "MS ゴシック")
                               (family . "Lucida Console")))
;;; フォント、背景・文字カラーとか
(setq default-frame-alist
      '((font . "private-fontset")
	(tool-bar-lines . 0)
	(background-color . "grey10")
	(foreground-color . "gray")
	(cursor-color . "gray")
	(width . 80)
	(height . 40)
	(alpha . (nil 70 50 30))))


;;; IME設定
;; Language Environment: Japanese
  (set-language-environment "Japanese")
;; Windows IME
  (mw32-ime-initialize)
  (setq default-input-method "MW32-IME")

;; IME ON/OFF mode-line
  (setq mw32-ime-show-mode-line t)
;; IME mode-line indicator
;; OFF : [--]
;; ON  : [あ]
  (setq-default mw32-ime-mode-line-state-indicator "[--]")
  (setq mw32-ime-mode-line-state-indicator "[--]")
  (setq mw32-ime-mode-line-state-indicator-list '("[--]" "[あ]" "[--]"))


;; 行番号・桁番号
  (line-number-mode 1)
  (column-number-mode 1)

;; ファイル名補完で大文字小文字を区別しない
(setq completion-ignore-case t)

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

;;; 終了時にオートセーブファイルを消す
(setq delete-auto-save-files t)

;;; 補完時に大文字小文字を区別しない
(setq completion-ignore-case t)

;; タイトルバーにファイル名を表示する
(setq frame-title-format (format "%%b" ))


;;; キー設定
;; C-hでBSする
(global-set-key "\C-h" 'delete-backward-char)


;;; カラー設定
;; 自動で色を付ける
(global-font-lock-mode t)

;; regionに色を付ける
(transient-mark-mode t)

;; 直前・直後の括弧に対応する括弧を光らせる
(show-paren-mode)

;; カーソルがある行にアンダーラインを表示
(global-hl-line-mode)
(setq hl-line-face 'underline)
(hl-line-mode 1)

;; Emacs-Lispのカラーリング
(defface my-face-elisp-macro
  '((t (:foreground "sea green"))) nil)
(defface my-face-elisp-subr
  '((t (:foreground "SlateBlue3"))) nil)
(defface my-face-elisp-func
  '((t (:foreground "SkyBlue1"))) nil)
(defun my-font-lock-elisp-macro (limit)
  (when (re-search-forward
         "['(]\\([^() \n]+\\)" limit t)
    (or (and (not (memq (get-text-property
                         0 'face (match-string 1))
                        '(font-lock-comment-face
                          font-lock-warning-face)))
             (condition-case nil
                 (symbol-function
                  (intern-soft
                   (match-string-no-properties 1)))
               (error nil)))
        (my-font-lock-elisp-macro limit))))
(defun my-font-lock-elisp-subr (limit)
  (when (re-search-forward
         "['(]\\([^() \n]+\\)" limit t)
    (or (and (not (memq (get-text-property
                         0 'face (match-string 1))
                        '(font-lock-comment-face
                          font-lock-warning-face)))
             (subrp
              (condition-case nil
                  (symbol-function
                   (intern-soft
                    (match-string-no-properties 1)))
                (error nil))))
        (my-font-lock-elisp-subr limit))))
(defun my-font-lock-elisp-func (limit)
  (when (re-search-forward
         "['(]\\([^() \n]+\\)" limit t)
    (or (and (not (memq
                   (get-text-property
                    0 'face (match-string 1))
                   '(font-lock-comment-face
                     font-lock-warning-face)))
             (byte-code-function-p
              (condition-case nil
                  (symbol-function
                   (intern-soft
                    (match-string-no-properties 1)))
                (error nil))))
        (my-font-lock-elisp-func limit))))
(font-lock-add-keywords
 'lisp-interaction-mode
 '((my-font-lock-elisp-macro 1 'my-face-elisp-macro t)) t)
(font-lock-add-keywords
 'lisp-interaction-mode
 '((my-font-lock-elisp-func 1 'my-face-elisp-func t)) t)
(font-lock-add-keywords
 'lisp-interaction-mode
 '((my-font-lock-elisp-subr 1 'my-face-elisp-subr t)) t)
(font-lock-add-keywords
 'emacs-lisp-mode
 '((my-font-lock-elisp-macro 1 'my-face-elisp-macro t)) t)
(font-lock-add-keywords
 'emacs-lisp-mode
 '((my-font-lock-elisp-func 1 'my-face-elisp-func t)) t)
(font-lock-add-keywords
 'emacs-lisp-mode
 '((my-font-lock-elisp-subr 1 'my-face-elisp-subr t)) t)

;; Scheme用:インデントの定義
(put 'and-let* 'scheme-indent-function 1)
(put 'begin0 'scheme-indent-function 0)
(put 'call-with-client-socket 'scheme-indent-function 1)
(put 'call-with-input-conversion 'scheme-indent-function 1)
(put 'call-with-input-file 'scheme-indent-function 1)
(put 'call-with-input-process 'scheme-indent-function 1)
(put 'call-with-input-string 'scheme-indent-function 1)
(put 'call-with-iterator 'scheme-indent-function 1)
(put 'call-with-output-conversion 'scheme-indent-function 1)
(put 'call-with-output-file 'scheme-indent-function 1)
(put 'call-with-output-string 'scheme-indent-function 0)
(put 'call-with-temporary-file 'scheme-indent-function 1)
(put 'call-with-values 'scheme-indent-function 1)
(put 'dolist 'scheme-indent-function 1)
(put 'dotimes 'scheme-indent-function 1)
(put 'if-match 'scheme-indent-function 2)
(put 'let*-values 'scheme-indent-function 1)
(put 'let-args 'scheme-indent-function 2)
(put 'let-keywords* 'scheme-indent-function 2)
(put 'let-match 'scheme-indent-function 2)
(put 'let-optionals* 'scheme-indent-function 2)
(put 'let-syntax 'scheme-indent-function 1)
(put 'let-values 'scheme-indent-function 1)
(put 'let/cc 'scheme-indent-function 1)
(put 'let1 'scheme-indent-function 2)
(put 'letrec-syntax 'scheme-indent-function 1)
(put 'make 'scheme-indent-function 1)
(put 'multiple-value-bind 'scheme-indent-function 2)
(put 'match 'scheme-indent-function 1)
(put 'parameterize 'scheme-indent-function 1)
(put 'parse-options 'scheme-indent-function 1)
(put 'receive 'scheme-indent-function 2)
(put 'rxmatch-case 'scheme-indent-function 1)
(put 'rxmatch-cond 'scheme-indent-function 0)
(put 'rxmatch-if  'scheme-indent-function 2)
(put 'rxmatch-let 'scheme-indent-function 2)
(put 'syntax-rules 'scheme-indent-function 1)
(put 'unless 'scheme-indent-function 1)
(put 'until 'scheme-indent-function 1)
(put 'when 'scheme-indent-function 1)
(put 'while 'scheme-indent-function 1)
(put 'with-builder 'scheme-indent-function 1)
(put 'with-error-handler 'scheme-indent-function 0)
(put 'with-error-to-port 'scheme-indent-function 1)
(put 'with-input-conversion 'scheme-indent-function 1)
(put 'with-input-from-port 'scheme-indent-function 1)
(put 'with-input-from-process 'scheme-indent-function 1)
(put 'with-input-from-string 'scheme-indent-function 1)
(put 'with-iterator 'scheme-indent-function 1)
(put 'with-module 'scheme-indent-function 1)
(put 'with-output-conversion 'scheme-indent-function 1)
(put 'with-output-to-port 'scheme-indent-function 1)
(put 'with-output-to-process 'scheme-indent-function 1)
(put 'with-output-to-string 'scheme-indent-function 1)
(put 'with-port-locking 'scheme-indent-function 1)
(put 'with-string-io 'scheme-indent-function 1)
(put 'with-time-counter 'scheme-indent-function 1)
(put 'with-signal-handlers 'scheme-indent-function 1)
(put 'with-locking-mutex 'scheme-indent-function 1)
(put 'guard 'scheme-indent-function 1)

;; .scmファイルの文字コードをeuc-jp-unixにする
(modify-coding-system-alist 'file "\\.scm$" 'euc-jp-unix)


配色はこんな感じ

で結構気に入っている。


これをきっかけにemacsをちゃんと使えるようになりたい。