.emacs

.emacs

;; カラーテーマの設定
(load "color-theme")
(color-theme-initialize)
(color-theme-clarity)
;; リージョンをハイライト
(setq-default transient-mark-mode t)
;; 対応する括弧の強調表示
(show-paren-mode t)

;; js2-mode
;; (autoload 'js2-mode "js2" nil t)
;; (add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))

;; nusmv-mode
;; (autoload 'nusmv-mode "nusmv-mode" "Major mode for NuSMV specification files." t)
;; (setq auto-mode-alist
;;       (append  (list '("\\.smv$" . nusmv-mode))
;;                auto-mode-alist))

;;(defface my-face-r-1 '((t (:background "gray15"))) nil)
(defface my-face-b-1 '((t (:background "gray"))) nil)
(defface my-face-b-2 '((t (:background "gray26"))) nil)
(defface my-face-u-1 '((t (:foreground "SteelBlue" :underline t))) 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)

;;; ツールバーを消す
;; (tool-bar-mode 0)
;;; メニューバーも消す
(menu-bar-mode nil)
;;; タイトルバーにファイル名を表示する
(setq frame-title-format (format "%%f" (system-name)))

;; 指定行ジャンプ
(global-set-key "\M-g" 'goto-line)

;; iswitchtb
(iswitchb-mode 1)

;; C style
(add-hook 'c-mode-hook
          '(lambda()
             (c-set-style "stroustrup")
             (setq indent-tabs-mode nil)     ; インデントは空白文字で行う(TABコードを空白に変換)
             (c-set-offset 'arglist-close 0) ; 関数の引数リストの閉じ括弧はインデントしない
             ))

(add-hook 'c-mode-common-hook
          '(lambda ()
              (c-set-style "stroustrup")
              (setq c-basic-offset 4)
              (setq indent-tabs-mode nil)
              (c-set-offset 'arglist-close 0)
              (setq tab-width 4)))

(autoload 'markdown-mode "markdown-mode.el"
   "Major mode for editing Markdown files" t)
(setq auto-mode-alist
   (cons '("\\.text" . markdown-mode) auto-mode-alist))

;; php-mode
(require 'php-mode)
(add-hook 'php-mode-hook
          (lambda ()
            (c-set-offset 'case-label' 4)
            (c-set-offset 'arglist-intro' 4)
            (c-set-offset 'arglist-cont-nonempty' 4)
            (c-set-offset 'arglist-close' 0)
            (setq tab-width 4)
            (setq indent-tabs-mode nil)))


;; カレントバッファの強制再読込を行う
(defun revert-buffer-force ()
  (interactive)
  (revert-buffer t t))

(define-key global-map "\C-c\C-x\C-j" 'revert-buffer-force)
(define-key global-map "\C-c\C-x\ j" 'revert-buffer-force)
(define-key global-map "\C-x\C-j" 'revert-buffer)
(define-key global-map "\C-x\ j" 'revert-buffer)

;; なにもするな!!!
(global-set-key "\C-\\" 'ignore)
(global-set-key [M-kanji] 'ignore)

;; タブでなくスペースでインデント
(setq-default tab-width 4 indent-tabs-mode nil)

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

;; いちいち音を鳴らすな
(setq ring-bell-function 'ignore)

;; howm-mode
;; (setq howm-menu-lang 'ja)
;; (require 'howm)
;; (setq howm-file-name-format "%Y/%m/%Y_%m_%d.howm") ; 1 日 1 ファイル
;; ;; bhl
;; (autoload 'bhl-mode "bhl" "BHL Mode" t)
;; (add-to-list 'auto-mode-alist '("\\.howm$" . bhl-mode))
;; (setq bhl-sectioning-default-style 'equal-sign)

;; (add-hook 'calendar-load-hook
;;           (lambda ()
;;             (require 'japanese-holidays)
;;             (setq calendar-holidays
;;                   (append japanese-holidays local-holidays other-holidays))))

;; Emacs nav
(require 'nav)

;; 長い文章の折り返しで物理的に次の行に移動
(global-set-key "\C-p" 'previous-window-line)
(global-set-key "\C-n" 'next-window-line)
(global-set-key [up] 'previous-window-line)
(global-set-key [down] 'next-window-line)
(defun previous-window-line (n)
  (interactive "p")
  (let ((cur-col
         (- (current-column)
            (save-excursion (vertical-motion 0) (current-column)))))
    (vertical-motion (- n))
    (move-to-column (+ (current-column) cur-col)))
  (run-hooks 'auto-line-hook)
  )
(defun next-window-line (n)
  (interactive "p")
  (let ((cur-col
         (- (current-column)
            (save-excursion (vertical-motion 0) (current-column)))))
    (vertical-motion n)
    (move-to-column (+ (current-column) cur-col)))
  (run-hooks 'auto-line-hook)
  ) 

;; ウインドウ間をさくさく移動
(windmove-default-keybindings)
(setq windmove-wrap-around t)


;; (require 'calfw) ; 初回一度だけ