From 301921cd45c27ad8bfae11646a54ce39940b47ed Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Thu, 11 Apr 2013 14:30:02 +0200 Subject: [PATCH] remove hooks when needed in rc files --- src/rc/clang.kak | 4 +++- src/rc/cpp.kak | 3 ++- src/rc/ctags.kak | 8 +++++--- src/rc/grep.kak | 4 ++-- src/rc/kakrc.kak | 2 +- src/rc/make.kak | 4 ++-- 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/rc/clang.kak b/src/rc/clang.kak index 72577990..2e712aee 100644 --- a/src/rc/clang.kak +++ b/src/rc/clang.kak @@ -29,8 +29,10 @@ def clang-complete %{ } def clang-enable-autocomplete %{ - hook window InsertIdle .* %{ eval -draft %{ + hook window -id clang-autocomplete InsertIdle .* %{ eval -draft %{ exec %sh{ [[ $kak_selection =~ .*(\.|->|::).$ ]] && echo "exec ; echo 'completing...'; clang-complete" } }} } + +def clang-disable-autocomplete %{ rmhooks window clang-autocomplete } diff --git a/src/rc/cpp.kak b/src/rc/cpp.kak index e6111b54..687b2583 100644 --- a/src/rc/cpp.kak +++ b/src/rc/cpp.kak @@ -22,12 +22,13 @@ hook global WinSetOption filetype=cpp %~ addfilter -group cpp-filters regex ^(\h+)([^\n]*[^([{]\h*|$) \n \n$1 addfilter -group cpp-filters regex ^(\h*)[^\n]*[([{]\h* \n '\n$1 ' addfilter -group cpp-filters cleanup_whitespaces - hook window InsertEnd .* %{ exec -draft s\h+$d } + hook window InsertEnd .* -id cpp-hooks %{ exec -draft s\h+$d } ~ hook global WinSetOption filetype=(?!cpp).* %{ rmhl cpp-highlight rmfilter cpp-filters + rmhooks window cpp-hooks } hook global BufNew .*\.(h|hh|hpp|hxx|H) %{ diff --git a/src/rc/ctags.kak b/src/rc/ctags.kak index 12e90cde..a761f0a1 100644 --- a/src/rc/ctags.kak +++ b/src/rc/ctags.kak @@ -42,7 +42,9 @@ def funcinfo %{ } def ctags-enable-autoinfo %{ - hook window NormalIdle .* funcinfo - hook window NormalEnd .* info - hook window InsertIdle .* funcinfo + hook window -id ctags-autoinfo NormalIdle .* funcinfo + hook window -id ctags-autoinfo NormalEnd .* info + hook window -id ctags-autoinfo InsertIdle .* funcinfo } + +def ctags-disable-autoinfo %{ rmhooks window ctags-autoinfo } diff --git a/src/rc/grep.kak b/src/rc/grep.kak index 67bd0f22..43252a43 100644 --- a/src/rc/grep.kak +++ b/src/rc/grep.kak @@ -22,9 +22,9 @@ def -shell-params -file-completion \ hook global WinSetOption filetype=grep %{ addhl group grep-highlight addhl -group grep-highlight regex "^([^:]+):(\d+):(\d+)?" 1:cyan 2:green 3:green - hook buffer NormalKey jump + hook buffer -id grep-hooks NormalKey jump } -hook global WinSetOption filetype=(?!grep).* %{ rmhl grep-highlight; } +hook global WinSetOption filetype=(?!grep).* %{ rmhl grep-highlight; rmhooks buffer grep-hooks } def jump %{ exec 'xs^([^:]+):(\d+):(\d+)?'; edit %reg{1} %reg{2} %reg{3} } diff --git a/src/rc/kakrc.kak b/src/rc/kakrc.kak index c132cd14..223ae638 100644 --- a/src/rc/kakrc.kak +++ b/src/rc/kakrc.kak @@ -4,7 +4,7 @@ hook global BufCreate (.*/)?(kakrc|.*.kak) %{ hook global WinSetOption filetype=kak %{ addhl group kak-highlight - addhl -group kak-highlight regex \<(hook|addhl|rmhl|addfilter|rmfilter|exec|eval|source|runtime|def|echo|edit|set[gbw])\> 0:keyword + addhl -group kak-highlight regex \<(hook|rmhooks|addhl|rmhl|addfilter|rmfilter|exec|eval|source|runtime|def|decl|echo|edit|set[gbw])\> 0:keyword addhl -group kak-highlight regex \<(default|black|red|green|yellow|blue|magenta|cyan|white)\> 0:value addhl -group kak-highlight regex (?<=\ errjump + hook buffer -id make-hooks NormalKey errjump } -hook global WinSetOption filetype=(?!make).* %{ rmhl make-highlight; } +hook global WinSetOption filetype=(?!make).* %{ rmhl make-highlight; rmhooks buffer make-hooks } def errjump %{ exec 'xs^([^:\n]+):(\d+)(?::(\d+))?:(.*?)$'; edit %reg{1} %reg{2} %reg{3}; echo %reg{4} }