fnwiyaBlog

EmacsとかLispとか可視化とか

evil-modeでもkey-comboを使う

特定のキーの連続入力により挙動を変化させることのできるkey-comboですが、
evilの際はevil-***-state-mapに定義しないと/等のキーを設定していた場合に
normal-state時検索が行えなくなります。(おそらく設定した値を挿入する動きになっているため)

(use-package key-combo
  :config
  (global-key-combo-mode t)
  (key-combo-define evil-insert-state-map (kbd "=") '(" = " " == " "=" " === "))
  (key-combo-define evil-insert-state-map (kbd "+") '(" + " "+" " += " "++"))
  (key-combo-define evil-insert-state-map (kbd "-") '("-" " - " " -= " "--"))
  (key-combo-define evil-insert-state-map (kbd "*") '(" * " "*" " *= "))
  (key-combo-define evil-normal-state-map (kbd "/") 'key-combo-execute-orignal)
  (key-combo-define evil-insert-state-map (kbd "/") '("/" " / " " /= " "/* `!!' */" "//"))
  (key-combo-define evil-insert-state-map (kbd "%") '("%" " % " " %= "))
  (key-combo-define evil-insert-state-map (kbd "!") '("!" " != "))
  (key-combo-define evil-insert-state-map (kbd "&") '(" && " "&"))
  (key-combo-define evil-insert-state-map (kbd "|") '(" || " "|"))
  (key-combo-define evil-insert-state-map (kbd "?") '(" ? " "?"))
  (key-combo-define evil-insert-state-map (kbd ",") '(", " "," ",\n"))
  (key-combo-define evil-insert-state-map (kbd "{") '("{\n`!!'\n}" "{" "{`!!'}" "{}"))
  (key-combo-define evil-insert-state-map (kbd "(") '("(`!!')" "(" "()"))
  (key-combo-define evil-insert-state-map (kbd "[") '("[`!!']" "[" "[]"))
  (key-combo-define evil-insert-state-map (kbd "<")  '(" < " " <= " " < " " << " "<<" "<`!!'>"))
  (key-combo-define evil-insert-state-map (kbd ">")  '(" > " " >= " " > " " >> " ">>"))
  (key-combo-define evil-insert-state-map (kbd "\"") '("\"`!!'\""  "\""  "\"\"\"`!!'\"\"\""))
  (key-combo-define evil-insert-state-map (kbd ";") '(";\n" ";"))
  (add-hook 'web-mode-hook (lambda()
    (key-combo-define evil-insert-state-map (kbd "<")  '("<" "<`!!'>"))
    (key-combo-define evil-insert-state-map (kbd "/")  '("/" "</`!!'>"))
    (key-combo-define evil-insert-state-map (kbd ">")  '(">"))
    (key-combo-define evil-insert-state-map (kbd "=")  '("="))
    (key-combo-define evil-insert-state-map (kbd "*")  '("*"))
    (key-combo-define evil-insert-state-map (kbd "!")  '("!" "<!-- `!!' -->"))
  ))
  )