;; -*- lisp -*- ;; ---------------------------------------- ;; Meadow 3.00 用設定 ;; ;;; Mule-UCS の設定 ;; ;; ftp://ftp.m17n.org/pub/mule/Mule-UCS/ が オフィシャルサイトですが、 ;; ;; http://www.meadowy.org/~shirai/elisp/mule-ucs.tar.gz に既知のパッチ ;; ;; をすべて適用したものがおいてあります。 ;; ;; (set-language-environment) の前に設定します ;; (require 'jisx0213) ;; ユーザ用の設定ファイル (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. '(case-fold-search t) '(current-language-environment "Japanese") '(default-input-method "japanese")) (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. ) ;;; 日本語環境設定 (set-language-environment "Japanese") ;; ---------------------------------------- ;;; IMEの設定 ;; http://www.bookshelf.jp/soft/meadow_15.html#SEC128 ;;ime の ON/OFF でカーソルの色を変える ;;ここから (add-hook 'mw32-ime-on-hook (function (lambda () (set-cursor-color "Red")))) (add-hook 'mw32-ime-off-hook (function (lambda () (set-cursor-color "Black")))) (setq-default mw32-ime-mode-line-state-indicator "[--]") ;;モードラインの表示も変更 (setq mw32-ime-mode-line-state-indicator-list '("[--]" "[あ]" "[--]")) ;;(setq mw32-ime-mode-line-state-indicator-list '("[--]" "[J]" "[--]")) ;;ここまでは mw32-ime-initialize の前に入れる (mw32-ime-initialize) ;; IME の初期化 (setq default-input-method "MW32-IME") ;; (add-hook 'mw32-ime-on-hook ;; (function (lambda () (set-cursor-height 2)))) ;; (add-hook 'mw32-ime-off-hook ;; (function (lambda () (set-cursor-height 4)))) ;; ;;; カーソルの設定 ;; ;; (set-cursor-type 'box) ; Meadow-1.10互換 (SKK等で色が変る設定) ;; ;; (set-cursor-type 'hairline-caret) ; 縦棒キャレット ;;; マウスカーソルを消す設定 (setq w32-hide-mouse-on-key t) (setq w32-hide-mouse-timeout 5000) ;;; font-lockの設定 (global-font-lock-mode t) ;; ---------------------------------------- ;; フォント設定 ;; TrueType フォント設定 (load-file "~/.emacs.d/fontset-tt16.el") (load-file "~/.emacs.d/fontset-msgothic.el") ;; ;;; BDF フォント設定 (load-file "~/.emacs.d/fontset-bdf.el") ;;(setq default-frame-alist ;; (append (list '(font . "MS Gothic 12")) ;; (append (list '(font . "private-fontset")) ;; (append (list '(font . "tt14")) ;; default-frame-alist)) ;; 初期フレームの設定 (setq default-frame-alist (append (list '(foreground-color . "black") ;; '(background-color . "LemonChiffon") ;; '(background-color . "gray") '(border-color . "black") '(mouse-color . "white") '(cursor-color . "black") '(font . "MS Gothic 12") '(ime-font . (w32-logfont "MS ゴシック" 0 -12 400 0 nil nil nil 128 1 3 49)) ;; '(font . "MS Gothic 12") ;; '(font . "ms-fontset-12") ;; '(ime-font . (w32-logfont "MS ゴシック" ;; 0 16 400 0 nil nil nil ;; 128 1 3 49)) ;; '(ime-font . "MS-Gothic-12") ;; '(ime-font . "imefont-japanese-jisx0208") ;; '(font . "bdf-fontset") ;; '(font . "private-fontset") ;; '(width . 80) ;; '(height . 40) ;; '(top . 0) ;; '(left . 100) ) default-frame-alist)) ;; ;;; shell の設定 ;; ;;; Cygwin の bash を使う場合 ;; (setq explicit-shell-file-name "bash") ;; (setq shell-file-name "sh") ;; (setq shell-command-switch "-c") ;; ;;; Virtually UN*X!にある tcsh.exe を使う場合 ;; (setq explicit-shell-file-name "tcsh.exe") ;; (setq shell-file-name "tcsh.exe") ;; (setq shell-command-switch "-c") ;; ;;; WindowsNT に付属の CMD.EXE を使う場合。 ;; (setq explicit-shell-file-name "CMD.EXE") ;; (setq shell-file-name "CMD.EXE") ;; (setq shell-command-switch "\\/c") (setq explicit-shell-file-name "CMDPROXY.EXE") (setq shell-file-name "CMDPROXY.EXE") ;(setq shell-command-switch "\\/c") ;;; argument-editing の設定 (require 'mw32script) (mw32script-init) ;; ;;; browse-url の設定 ;; (global-set-key [S-mouse-2] 'browse-url-at-mouse) ;; ;;; 印刷の設定 ;; ;; この設定で M-x print-buffer RET などでの印刷ができるようになります ;; ;; ;; ;; notepad に与えるパラメータの形式の設定 ;; (define-process-argument-editing "notepad" ;; (lambda (x) (general-process-argument-editing-function x nil t))) ;; ;; (defun w32-print-region (start end ;; &optional lpr-prog delete-text buf display ;; &rest rest) ;; (interactive) ;; (let ((tmpfile (convert-standard-filename (buffer-name))) ;; (w32-start-process-show-window t) ;; ;; もし、dos 窓が見えていやな人は上記の `t' を `nil' にします ;; ;; ただし、`nil' にすると Meadow が固まる環境もあるかもしれません ;; (coding-system-for-write w32-system-coding-system)) ;; (while (string-match "[/\\]" tmpfile) ;; (setq tmpfile (replace-match "_" t nil tmpfile))) ;; (setq tmpfile (expand-file-name (concat "_" tmpfile "_") ;; temporary-file-directory)) ;; (write-region start end tmpfile nil 'nomsg) ;; (call-process "notepad" nil nil nil "/p" tmpfile) ;; (and (file-readable-p tmpfile) (file-writable-p tmpfile) ;; (delete-file tmpfile)))) ;; ;; (setq print-region-function 'w32-print-region) ;; ;;; fakecygpty の設定 ;; ;; この設定で cygwin の仮想端末を要求するプログラムを Meadow から ;; ;; 扱えるようになります ;; (setq mw32-process-wrapper-alist ;; '(("/\\(bash\\|tcsh\\|svn\\|ssh\\|gpg[esvk]?\\)\\.exe" . ;; (nil . ("fakecygpty.exe" . set-process-connection-type-pty))))) ;; ---------------------------------------- ;; cperl-mode enable (autoload 'cperl-mode "cperl-mode" "alternate mode for editing Perl programs" t) (setq auto-mode-alist (append '(("\\.\\([pP][Llm]\\|al\\)$" . cperl-mode)) auto-mode-alist )) (setq interpreter-mode-alist (append interpreter-mode-alist '(("miniperl" . cperl-mode)))) (add-hook 'cperl-mode-hook (lambda () (set-face-bold-p 'cperl-array-face nil) (set-face-background 'cperl-array-face "black") (set-face-bold-p 'cperl-hash-face nil) (set-face-italic-p 'cperl-hash-face nil) (set-face-background 'cperl-hash-face "black") )) ;; ---------------------------------------- ;; 終了時のウインドウサイズを記録 ;; http://www.bookshelf.jp/soft/meadow_30.html#SEC408 (defun my-window-size-save () (let* ((rlist (frame-parameters (selected-frame))) (ilist initial-frame-alist) (nCHeight (frame-height)) (nCWidth (frame-width)) (tMargin (if (integerp (cdr (assoc 'top rlist))) (cdr (assoc 'top rlist)) 0)) (lMargin (if (integerp (cdr (assoc 'left rlist))) (cdr (assoc 'left rlist)) 0)) buf (file "~/.framesize.el")) (if (get-file-buffer (expand-file-name file)) (setq buf (get-file-buffer (expand-file-name file))) (setq buf (find-file-noselect file))) (set-buffer buf) (erase-buffer) (insert (concat ;; 初期値をいじるよりも modify-frame-parameters ;; で変えるだけの方がいい? "(delete 'width initial-frame-alist)\n" "(delete 'height initial-frame-alist)\n" "(delete 'top initial-frame-alist)\n" "(delete 'left initial-frame-alist)\n" "(setq initial-frame-alist (append (list\n" "'(width . " (int-to-string nCWidth) ")\n" "'(height . " (int-to-string nCHeight) ")\n" "'(top . " (int-to-string tMargin) ")\n" "'(left . " (int-to-string lMargin) "))\n" "initial-frame-alist))\n" ;;"(setq default-frame-alist initial-frame-alist)" )) (save-buffer) )) (defun my-window-size-load () (let* ((file "~/.framesize.el")) (if (file-exists-p file) (load file)))) (my-window-size-load) ;; Call the function above at C-x C-c. (defadvice save-buffers-kill-emacs (before save-frame-size activate) (my-window-size-save)) ;; ---------------------------------------- ;; window の横分割と縦分割を切り替え ;; M-x window-toggle-division (defun window-toggle-division () "ウィンドウ 2 分割時に、縦分割<->横分割" (interactive) (unless (= (count-windows 1) 2) (error "ウィンドウが 2 分割されていません。")) (let (before-height (other-buf (window-buffer (next-window)))) (setq before-height (window-height)) (delete-other-windows) (if (= (window-height) before-height) (split-window-vertically) (split-window-horizontally) ) (switch-to-buffer-other-window other-buf) (other-window -1))) ;; ---------------------------------------- ;; shift+カーソルキーでリージョン選択 (pc-selection-mode) ;; ---------------------------------------- ;; shift+カーソルキーでウインドウ間を移動 ;; (windmove-default-keybindings) ;; (setq windmove-wrap-around t) ;; ---------------------------------------- ;; 現在行もしくは region を複製 ;; M-カーソルキーで実行 (defun duplicate-line-backward () "Duplicate the current line backward." (interactive "*") (save-excursion (let ((contents (buffer-substring (line-beginning-position) (line-end-position)))) (beginning-of-line) (insert contents ?\n))) (previous-line 1)) (defun duplicate-region-backward () "If mark is active duplicates the region backward." (interactive "*") (if mark-active (let* ( (deactivate-mark nil) (start (region-beginning)) (end (region-end)) (contents (buffer-substring start end))) (save-excursion (goto-char start) (insert contents)) (goto-char end) (push-mark (+ end (- end start)))) (error "Mark is not active. Region not duplicated."))) (defun duplicate-line-forward () "Duplicate the current line forward." (interactive "*") (save-excursion (let ((contents (buffer-substring (line-beginning-position) (line-end-position)))) (end-of-line) (insert ?\n contents))) (next-line 1)) (defun duplicate-region-forward () "If mark is active duplicates the region forward." (interactive "*") (if mark-active (let* ( (deactivate-mark nil) (start (region-beginning)) (end (region-end)) (contents (buffer-substring start end))) (save-excursion (goto-char end) (insert contents)) (goto-char start) (push-mark end) (exchange-point-and-mark)) (error "Mark is not active. Region not duplicated."))) (global-set-key [M-up] 'duplicate-line-backward) (global-set-key [M-down] 'duplicate-line-forward) (global-set-key [M-right] 'duplicate-region-forward) (global-set-key [M-left] 'duplicate-region-backward) ;; ---------------------------------------- ;; gnuserv - 送るや関連付けでファイルを開く ;; ;; 環境変数を設定 ;; ;; SET GNUCLIENTW=-F ;; SET GNUDOITW=-F ;; SET EMACS=meadow ;; SET RUNEMACS=runmw32 (load "gnuserv") (gnuserv-start) (setq gnuserv-frame (selected-frame)) ;; ---------------------------------------- ;; 起動時の画面を非表示にする ;; (setq inhibit-startup-message t) ;; ---------------------------------------- ;; 文字折り返し ;; 折り返し無しを設定 ;; (setq truncate-lines t) ;; (setq truncate-partial-width-windows t) ;; 折り返し有りを設定 ;; (setq truncate-lines nil) ;; (setq truncate-partial-width-windows nil) ;; truncate-partial-width-windows は C-x 3 などで, ;; ウィンドウを縦に分割した時に折り返すかどうかを制御. ;; truncate-lines は通常時の折り返しを制御. ;;; 長い行でも折り返さない。 ;; (setq-default truncate-lines t) ;; ---------------------------------------- ;; カーソルキーの下で新しい行を作る ;; カーソルキーで新しい行を作らない ;; (setq next-line-add-newlines nil) ;; カーソルキーで新しい行を作る ;; (setq next-line-add-newlines t) ;; ---------------------------------------- ;; キーバインド変更の例 ;; (global-set-key "\C-h" 'backward-delete-char) ;; (global-set-key "\M-?" 'help-for-help) ;; (global-set-key [f1] 'help-for-help) ;; ;; ;; M-g で指定行へ移動 ;; (global-set-key "\M-g" 'goto-line) ;; ;; ;; 改行キーでオートインデント ;; (define-key global-map "\C-m" 'newline-and-indent) ;; ;;インデント方法. お好みで. . . ;; (setq indent-line-function 'indent-relative-maybe) ;; ---------------------------------------- ;; バッファ名にディレクトリ名を付随させる (require 'uniquify) (setq uniquify-buffer-name-style 'post-forward-angle-brackets) (setq uniquify-min-dir-content 1) ;; 不具合が起きる場合は以下を試す ;; (setq uniquify-ignore-buffers-re "*[^*]+*") ;; ---------------------------------------- ;; migemo ;; 起動時に off にする ;; (setq migemo-isearch-enable-p nil) ;; ---------------------------------------- ;; 表示関係 ;; 起動時のメッセージ表示を無効に (setq inhibit-startup-message t) ;; 起動時の scratch バッファ内メッセージを無効に (setq initial-scratch-message "") ;; タイトルバーにファイル名を表示 (setq frame-title-format "%b") ;; メニューバーを非表示にする ;; (menu-bar-mode -1) ;; ツールバーを非表示にする (tool-bar-mode 0) ;; カーソルの位置が何行目(L)かをモードラインに表示 (line-number-mode t) ;; カーソルの位置が何桁目(C)かをモードラインに表示 (column-number-mode t) ;; 時刻を24時間制でモードラインに表示 (setq display-time-24hr-format t) (display-time) ;; 対応括弧をハイライト表示 (show-paren-mode t) (setq show-paren-style 'mixed) (set-face-background 'show-paren-match-face "plum2") (set-face-foreground 'show-paren-match-face "Blue") ;; ファイル表示の余計な部分を暗くする (file-name-shadow-mode t) ;; region に色をつける (setq transient-mark-mode t) ;; ---------------------------------------- ;;; バックアップファイルを作成しない。 ;; (setq make-backup-files nil) ;; バックアップファイル保存場所を指定 (setq make-backup-files t) (setq backup-directory-alist (cons (cons "\\.*$" (expand-file-name "~/bak")) backup-directory-alist)) ;;; オートセーブファイルを作成しない。 ;; (setq auto-save-default nil) ;; ---------------------------------------- ;; iswitchb ;; C-x b ... バッファ一覧がミニバッファに表示 ;; C-s,C-r でバッファの選択を切り替え ;; さらにそのまま文字入力すると isearch に ;; 検索候補がないなら,C-x C-f で find-file へ移行 (cond ((and (featurep 'meadow) (eq emacs-major-version '20)) ;; ------------------------------ ;; Meadow 1.xx の設定 ) ((and (featurep 'meadow) (eq emacs-major-version '21)) ;; ------------------------------ ;; Meadow 2 の設定 (iswitchb-default-keybindings) ;; 左右のカーソルキーやSPC でバッファ切り替 (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) ) ;; iswitchb に候補がなければ find-file に ;; C-u C-x b で通常の C-x b と同じ動作に (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))) ) ((and (featurep 'meadow) (eq emacs-major-version '22)) ;; ------------------------------ ;; Meadow 3 の設定 (iswitchb-mode 1) (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) ) )) ;; ---------------------------------------- ;; icomplete - M-x の補完候補をミニバッファに表示 ;; (icomplete-mode 1) ;; ---------------------------------------- ;; mcomplete - M-x の補完を iswitchb のように ;; mcomplete.el が必要。site-lisp/ に入れる。 ;; mcomplete.el の foreground 指定を変更してることに注意。 ;; デフォルトでは文字が読めん (require 'mcomplete) (turn-on-mcomplete-mode) ;; ---------------------------------------- ;; 最近使ったファイルを記憶 ;; M-x recentf-open-files (recentf-mode 1) ;; ---------------------------------------- ;; カーソル付近のファイルを C-x C-f で開く (ffap-bindings) ;; スペースも含むpathの場合、region で選択 (defun my-find-file-at-point-or-region (&optional arg) "Find filename at point or selected by region. This function is useful, when filename contain spaces, and so can't be fully found by `find-file-at-point'. In this case user should manually select full filename and invoke this command. Also maps UNIX filenames to Window$ filenames." (interactive "P") (let ((filename (if (and transient-mark-mode mark-active) (buffer-substring-no-properties (mark) (point)) (ffap-string-at-point)))) (and (eq system-type 'windows-nt) filename (string-match "^/dos/\\([A-Za-z]\\)\\(.*\\)" filename) (setq filename (concat (match-string 1 filename) ":" (match-string 2 filename)))) (or (and filename (file-exists-p filename)) (setq filename (ffap-guesser))) (if (and filename (file-directory-p filename)) (setq filename (file-name-as-directory filename))) (find-file-at-point (ffap-prompter filename)))) (define-key global-map "\C-x\C-f" 'my-find-file-at-point-or-region) ;; ---------------------------------------- ;; ruby-mode (autoload 'ruby-mode "ruby-mode" "Mode for editing ruby source files" t) (setq auto-mode-alist (append '(("\\.rb$" . ruby-mode)) auto-mode-alist)) (setq interpreter-mode-alist (append '(("ruby" . ruby-mode)) interpreter-mode-alist)) ;; ---------------------------------------- ;; 独自のキー割り当て (define-key global-map [end] 'undo) (define-key global-map [home] 'next-buffer) (define-key global-map [\S-home] 'previous-buffer) (define-key global-map [?\C-/] 'recentf-open-files) (global-set-key [?\C-,] 'bs-cycle-next) (global-set-key [?\C-.] 'bs-cycle-previous) (global-set-key "\C-x\C-b" 'bs-show) (global-set-key [f12] 'other-window) ;; ---------------------------------------- ;; tab幅設定 (defun allset-tab-width (num) "タブ幅を指定します" (interactive "nTab Width: ") (setq tab-width num) (setq tab-stop-list ()) (while (< num 256) (setq tab-stop-list (append tab-stop-list (list num))) (setq num (+ num tab-width)) )) (allset-tab-width 4) ;; タブ入力時に空白で ;; (setq-default indent-tabs-mode nil) ;; タブと空白混在で (setq-default indent-tabs-mode t) ;; Enter キーで改行およびインデント (global-set-key "\C-m" 'newline-and-indent) (global-set-key "\C-j" 'newline) ;; ---------------------------------------- ;; カーソル行にラインを引く ;; (setq hl-line-face 'underline) ;; (global-hl-line-mode) ;; (defface hlline-face ;; '((((class color) ;; (background dark)) ;; (:background "blue" :foreground "white")) ;; (((class color) ;; (background light)) ;; (:background "ForestGreen")) ;; (t ;; ())) ;; "*Face used by hl-line.") ;; (setq hl-line-face 'hlline-face) ;; ---------------------------------------- ;; TAB、全角スペースを表示 ;;(defface my-face-r-1 '((t (:background "gray15"))) nil) (defface my-face-b-1 '((t (:background "gainsboro"))) nil) (defface my-face-b-2 '((t (:background "lavender"))) nil) (defface my-face-u-1 '((t (:background "pale green"))) nil) ;;(defvar my-face-r-1 'my-face-r-1) (defvar my-face-b-1 'my-face-b-1) (defvar my-face-b-2 'my-face-b-2) (defvar my-face-u-1 'my-face-u-1) (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-u-1 append) ;;("[\r]*\n" 0 my-face-r-1 append) ))) (ad-enable-advice 'font-lock-mode 'before 'my-font-lock-mode) (ad-activate 'font-lock-mode) ;; ---------------------------------------- ;; 行番号を表示 (setnu.el) ;; (load "setnu") ;; (load "setnu-plus") ;; (global-set-key [f11] 'setnu-mode) ;; ---------------------------------------- ;; 行番号を表示 (wb-line-number.el) (require 'wb-line-number) (setq truncate-partial-width-windows nil) (set-scroll-bar-mode nil) (setq wb-line-number-scroll-bar t) (global-set-key [f11] 'wb-line-number-toggle) ;; ---------------------------------------- ;; コメント行の色指定 (set-face-foreground 'font-lock-comment-delimiter-face "#008000") (set-face-foreground 'font-lock-comment-face "#008000") ;; 折り返し部分の色指定 (set-face-foreground 'fringe "navyblue") (set-face-background 'fringe "alice blue") ;; ---------------------------------------- ;; ファイル編集時刻自動更新 ;; (setq time-stamp-start "Last updated:[ \t]*<") ;; (setq time-stamp-end ">") ;; (setq time-stamp-format ;; '(time-stamp-yyyy/mm/dd time-stamp-hh:mm:ss)) ;; (if (not (memq 'time-stamp write-file-hooks)) ;; (setq write-file-hooks ;; (cons 'time-stamp write-file-hooks))) (defvar my-save-buffer-hook nil) (defun save-buffer-wrapper () (interactive) (let ((tostr (concat " Last updated: <" (format-time-string "%Y/%m/%d %02H:%02M:%02S") ">"))) (save-excursion (goto-char (point-min)) (while (re-search-forward " Last updated: <[0-9/: ]*>" nil t) (replace-match tostr nil t))) (run-hooks 'my-save-buffer-hook) (save-buffer))) (global-set-key "\C-x\C-s" 'save-buffer-wrapper) ;; フォーマット挿入 (defun my-insert-time () (interactive) (insert (concat "Last updated: <" (format-time-string "%Y/%m/%d %02H:%02M:%02S") ">"))) ;; ;; end of file ;;