読者です 読者をやめる 読者になる 読者になる

*iroi*

mechairoi の Blog

vimpulse で stateごとにモードラインの色を変える

emacs vimpulse

どこかで見つけてvimに設定していたら、これが無いと妙に落ち着かなくなってしまった.
mode-lineの色がinsert-stateだと黄色, vi-stateだと白, emacs-stateは危険な(何が起こるかよくわからない)ので赤とかになる.
(current-buffer)が変わった後に呼ばれるhookが見つけられなかったので適当にdefadviceした.

(defun vimpulse-set-mode-line-face ()
  (unless (minibufferp (current-buffer))
    (set-face-background 'mode-line
                         (cdr (assq viper-current-state
                                    '((vi-state       . "White")
                                      (insert-state   . "Yellow")
                                      (emacs-state    . "Red")
                                      (operator-state . "Green")
                                      (visual-state   . "Blue")))))))
(add-hook 'viper-vi-state-hook          'vimpulse-set-mode-line-face)
(add-hook 'viper-insert-state-hook      'vimpulse-set-mode-line-face)
(add-hook 'viper-emacs-state-hook       'vimpulse-set-mode-line-face)
(add-hook 'vimpulse-operator-state-hook 'vimpulse-set-mode-line-face)
(add-hook 'vimpulse-visual-state-hook   'vimpulse-set-mode-line-face)
(defadvice set-buffer (after vimpulse-mode-line-face activate)
  (vimpulse-set-mode-line-face))
(defadvice find-file (after vimpulse-mode-line-face activate)
  (vimpulse-set-mode-line-face))
(defadvice kill-buffer (after vimpulse-mode-line-face activate)
  (vimpulse-set-mode-line-face))
(defadvice switch-to-buffer (after vimpulse-mode-line-face activate)
  (vimpulse-set-mode-line-face))
(defadvice select-window (after vimpulse-mode-line-face activate)
  (vimpulse-set-mode-line-face))
(defadvice delete-window (after vimpulse-mode-line-face activate)
  (vimpulse-set-mode-line-face))