*iroi*

mechairoi の Blog

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

どこかで見つけて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))

anything-git-grep

anything-grep は合わなかったので、anything-git-grep を作ってみました.

anythingは複数sourceとか, 遅延とかがとても使やすいので早くemacsに移行したい.

追記

リンクを最新版に差し替えたり

追記

magitには依存しないように.

追記

anything-configの(type . fileline)を使うように. 画像差し替え.

追記

リポジトリ移動

anything.el で (processp candidates)のときmultilineにならない?

anything.el で source が (processp candidates)のときmultilineにならない気がしたので..

--- a/.emacs.d/auto-install/anything.el
+++ b/.emacs.d/auto-install/anything.el
@@ -2265,7 +2265,12 @@ the real value in a text property."
                        (split-string string "\n")
                        (assoc 'incomplete-line source))
                       source t))
-    (anything-insert-match candidate 'insert-before-markers source)
+    (if (not (assq 'multiline source))
+        (anything-insert-match candidate 'insert-before-markers source)
+      (lexical-let ((start (point)))
+        (anything-insert-candidate-separator)
+        (anything-insert-match candidate 'insert-before-markers source)
+        (put-text-property start (point) 'anything-multiline t)))
     (incf (cdr (assoc 'item-count source)))
     (when (>= (assoc-default 'item-count source) limit)
       (anything-kill-async-process process)

追記
取り込んでいただきました!ありがとうございます。

vimpulse-define-keyできないことがある?

  • emacs23.1.1
  • gitのmasterのvimpulse
(vimpulse-define-key 'emacs-lisp-mode 'vi-state "\  e" 'eval-last-sexp)
(vimpulse-define-key 'emacs-lisp-mode 'visual-state "\  e" 'eval-region)

とかしたいが動かなかったのでnilになるとこを消してみたら動いた.

--- a/vimpulse-viper-function-redefinitions.el
+++ b/vimpulse-viper-function-redefinitions.el
@@ -414,8 +414,9 @@ and remove duplicates."
                    (add-to-list 'result (cons aux toggle) t))))
              (when (memq major-mode vimpulse-auxiliary-modes)
                (setq aux (cdr (assq major-mode entry)))
-               (unless (assq aux result)
-                 (add-to-list 'result (cons aux toggle) t)))
+               (when aux
+                 (unless (assq aux result)
+                   (add-to-list 'result (cons aux toggle) t))))
              result))
           ;; regular mode
           (t