2009年4月19日日曜日

NTEmacs 22BASE をインストール

自宅のマシンのEmacsは、公式サイトからダウンロードした22.3だったのだが、IMEパッチが適用されていないので不便だった。

普段使っている.emacsもロードできず、キーバインドになれていなくて用途が限られていた。

ようやく日本語インライン変換パッチ適用済みバージョンに差し替えたので、ついでに.emacsも書き換えてみた。
.emacs.el
;; [2009-04-19 01:25:04]

(setq inhibit-startup-message t)

(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.
'(display-time-mode t)
'(current-language-environment "Japanese")
'(tool-bar-mode nil)
'(line-number-mode t)
'(column-number-mode t)
'(show-paren-mode t)
'(transient-mark-mode t))

(fixed-width-set-fontset "msgothic" 14)

(setq default-frame-alist
(append '((foreground-color . "black")
(background-color . "LemonChiffon")
(border-color . "black")
(mouse-color . "white")
(cursor-color . "black")
(top . 0)
(left . 1040)
(width . 96)
(height . 77)
(line-spacing . 0)
(cursor-type . box))
default-frame-alist))

(setq-default tab-width 4 indent-tabs-mode nil)

;;(add-hook 'c++-mode-hook
;; '(lambda()
;; (c-set-style "cc-mode")
;; (c-set-offset 'innamespace 0)))

(defconst my-c-style
'((c-tab-always-indent . t)
(c-comment-only-line-offset . 4)
(c-hanging-braces-alist . ((substatement-open after)
(brace-list-open)))
(c-hanging-colons-alist . ((member-init-intro before)
(inher-intro)
(case-label after)
(label after)
(access-label after)))
(c-cleanup-list . (scope-operator
empty-defun-braces
defun-close-semi))
(c-offsets-alist . ((arglist-close . c-lineup-arglist)
(substatement-open . 0)
(case-label . 4)
(block-open . 0)
(innamespace . 0)
(knr-argdecl-intro . -)))
(c-echo-syntactic-information-p . t))
"My C Programming Style")

;; offset customizations not in my-c-style
(setq c-offsets-alist '((member-init-intro . ++)))

;; Customizations for all modes in CC Mode.
(defun my-c-mode-common-hook ()
;; add my personal style and set it for the current buffer
(c-add-style "PERSONAL" my-c-style t)
;; other customizations
(setq tab-width 8
;; this will make sure spaces are used instead of tabs
indent-tabs-mode nil)
;; we like auto-newline and hungry-delete
(c-toggle-auto-hungry-state 1)
;; key bindings for all supported languages. We can put these in
;; c-mode-base-map because c-mode-map, c++-mode-map, objc-mode-map,
;; java-mode-map, idl-mode-map, and pike-mode-map inherit from it.
(define-key c-mode-base-map "\C-m" 'c-context-line-break))

(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)

;;;; IME

(mw32-ime-initialize)
(setq default-input-method "MW32-IME")
(setq-default mw32-ime-mode-line-state-indicator "[--]")
(setq mw32-ime-mode-line-state-indicator-list '("[--]" "[あ]" "[--]"))
;; y/n, yes/no の問い合わせ時に IME をオフにする
(wrap-function-to-control-ime 'y-or-n-p nil nil)
(wrap-function-to-control-ime 'yes-or-no-p nil nil)

;;;; TAKUMAKEI

(defun kei-scroll-up ()
(interactive)
(scroll-up 1))

(defun kei-scroll-down ()
(interactive)
(scroll-down 1))

(defun kei-line-up ()
(interactive)
(let ((save-marker (point-marker)))
(kill-region (line-end-position) (point-marker))
(previous-line)
(yank)
(kill-region (line-end-position) (point-marker))
(goto-char (marker-position save-marker))
(yank '(nil))
(previous-line)))

(defun kei-line-down ()
(interactive)
(let ((save-marker (point-marker)))
(kill-region (line-end-position) (point-marker))
(next-line)
(yank)
(kill-region (line-end-position) (point-marker))
(goto-char (marker-position save-marker))
(yank '(nil))
(next-line)))

(load-library "time-stamp")
(defun kei-insert-date-string ()
(interactive)
(insert
(format "[%s %s]"
(time-stamp-yyyy-mm-dd)
(time-stamp-hh:mm:ss))))

(defun kei-load-memo (df)
(find-file
(expand-file-name
((lambda (today)
(format
"c:/Users/kei/Documents/memo/%s/%s(%s).txt"
(format-time-string "%Y" today)
(format-time-string "%Y-%m-%d" today)
(aref [ "日" "月" "火" "水" "木" "金" "土" ]
(string-to-number (format-time-string "%w" today)))))
((lambda (ts)
(let ((dt (decode-time ts)))
(encode-time 0 0 0
(+ (car (nthcdr 3 dt)) df)
(car (nthcdr 4 dt))
(car (nthcdr 5 dt)))))
(current-time))))))

(defun memo ()
(interactive)
(kei-load-memo 0))

(defun memox ()
(interactive)
(kei-load-memo (read-minibuffer "何日後?> " "")))

(defun kei-set-alpha1 ()
(interactive)
(set-alpha '(100 100)))

(defun kei-set-alpha2 ()
(interactive)
(set-alpha '(50 50)))

(defun kei-set-alpha3 ()
(interactive)
(set-alpha '(20 20)))

(global-set-key [(meta d)] 'kei-insert-date-string)
(global-set-key [(meta n)] 'kei-scroll-up)
(global-set-key [(meta p)] 'kei-scroll-down)
(global-set-key [(meta up)] 'kei-line-up)
(global-set-key [(meta down)] 'kei-line-down)
(global-set-key [(meta g)] 'goto-line)
(global-set-key [(meta o)] 'open-line)
(global-set-key [(ctrl h)] 'backward-delete-char-untabify)
(global-set-key [(ctrl o)] 'toggle-input-method)
(global-set-key [(ctrl \\)] 'kei-set-alpha1)
(global-set-key [(ctrl ,)] 'kei-set-alpha2)
(global-set-key [(ctrl .)] 'kei-set-alpha3)

0 件のコメント:

コメントを投稿