summaryrefslogtreecommitdiff
path: root/rc/core/python.kak
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2018-12-11 10:39:24 +1100
committerMaxime Coste <mawww@kakoune.org>2018-12-11 10:39:24 +1100
commit527e28539e7f05d49a3cbfddc168b1890d6f922b (patch)
tree970aeed47dcd8fff2d2c5e58ad532696038e4c08 /rc/core/python.kak
parent8498fe497dd3ccb07c2f24be3872eb41d4263c37 (diff)
parent27f951638c6086b6dbb6f467d607d628a188a67d (diff)
Merge remote-tracking branch 'occivink/cleanup-hook-once'
Diffstat (limited to 'rc/core/python.kak')
-rw-r--r--rc/core/python.kak12
1 files changed, 5 insertions, 7 deletions
diff --git a/rc/core/python.kak b/rc/core/python.kak
index a91f0364..fac94ae1 100644
--- a/rc/core/python.kak
+++ b/rc/core/python.kak
@@ -135,16 +135,14 @@ define-command -hidden python-indent-on-new-line %{
# Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
-hook -group python-highlight global WinSetOption filetype=python %{ add-highlighter window/python ref python }
+hook -group python-highlight global WinSetOption filetype=python %{
+ add-highlighter window/python ref python
+ hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/python }
+}
hook global WinSetOption filetype=python %{
hook window InsertChar \n -group python-indent python-indent-on-new-line
# cleanup trailing whitespaces on current line insert end
hook window ModeChange insert:.* -group python-indent %{ try %{ execute-keys -draft \; <a-x> s ^\h+$ <ret> d } }
-}
-
-hook -group python-highlight global WinSetOption filetype=(?!python).* %{ remove-highlighter window/python }
-
-hook global WinSetOption filetype=(?!python).* %{
- remove-hooks window python-indent
+ hook -once -always window WinSetOption filetype=.* %{ remove-hooks window python-.+ }
}