summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2019-10-16 20:19:43 +1100
committerMaxime Coste <mawww@kakoune.org>2019-10-16 20:45:53 +1100
commite4fb70ebec80edcd17f0e00823780e4798a3fb1a (patch)
tree8e45c2e340a63ca05aa73f8a44bf3c9d59494c0b
parent3a36a2486e12be9150e28fa81ac707d65c425d45 (diff)
Replace ModeChange hooks by ModePush and ModePop
Remove deprecated InsertBegin, InsertEnd, NormalBegin, NormalEnd hooks. Closes #2545
-rw-r--r--doc/pages/changelog.asciidoc4
-rw-r--r--doc/pages/hooks.asciidoc16
-rw-r--r--rc/filetype/awk.kak2
-rw-r--r--rc/filetype/c-family.kak2
-rw-r--r--rc/filetype/cabal.kak2
-rw-r--r--rc/filetype/clojure.kak2
-rw-r--r--rc/filetype/coffee.kak2
-rw-r--r--rc/filetype/css.kak2
-rw-r--r--rc/filetype/cucumber.kak2
-rw-r--r--rc/filetype/d.kak4
-rw-r--r--rc/filetype/dart.kak2
-rw-r--r--rc/filetype/elixir.kak2
-rw-r--r--rc/filetype/elm.kak2
-rw-r--r--rc/filetype/go.kak2
-rw-r--r--rc/filetype/haml.kak2
-rw-r--r--rc/filetype/haskell.kak2
-rw-r--r--rc/filetype/hbs.kak2
-rw-r--r--rc/filetype/html.kak2
-rw-r--r--rc/filetype/i3.kak2
-rw-r--r--rc/filetype/java.kak2
-rw-r--r--rc/filetype/javascript.kak2
-rw-r--r--rc/filetype/json.kak2
-rw-r--r--rc/filetype/kakrc.kak2
-rw-r--r--rc/filetype/latex.kak2
-rw-r--r--rc/filetype/ledger.kak2
-rw-r--r--rc/filetype/lisp.kak2
-rw-r--r--rc/filetype/moon.kak2
-rw-r--r--rc/filetype/nim.kak2
-rw-r--r--rc/filetype/nix.kak2
-rw-r--r--rc/filetype/perl.kak2
-rw-r--r--rc/filetype/php.kak2
-rw-r--r--rc/filetype/pony.kak2
-rw-r--r--rc/filetype/pug.kak2
-rw-r--r--rc/filetype/python.kak2
-rw-r--r--rc/filetype/r.kak2
-rw-r--r--rc/filetype/ragel.kak2
-rw-r--r--rc/filetype/rust.kak2
-rw-r--r--rc/filetype/sass.kak2
-rw-r--r--rc/filetype/scala.kak2
-rw-r--r--rc/filetype/scheme.kak2
-rw-r--r--rc/filetype/scss.kak2
-rw-r--r--rc/filetype/sh.kak2
-rw-r--r--rc/filetype/toml.kak2
-rw-r--r--rc/filetype/yaml.kak2
-rw-r--r--src/hook_manager.hh10
-rw-r--r--src/input_handler.cc23
-rw-r--r--src/main.cc4
47 files changed, 58 insertions, 85 deletions
diff --git a/doc/pages/changelog.asciidoc b/doc/pages/changelog.asciidoc
index 0c8fd7d4..d30d3016 100644
--- a/doc/pages/changelog.asciidoc
+++ b/doc/pages/changelog.asciidoc
@@ -7,6 +7,10 @@ released versions.
* Arrow keys and `<home>`, `<end>` are not normal mode commands
anymore but default key mappings.
+
+* `ModeChange` hook parameter now takes `push:` or `pop:` prefix,
+ `InsertBegin`, `InsertEnd`, `NormalBegin` and `NormalEnd`
+ were removed.
== Kakoune 2019.07.01
diff --git a/doc/pages/hooks.asciidoc b/doc/pages/hooks.asciidoc
index 67058ecd..361d94d4 100644
--- a/doc/pages/hooks.asciidoc
+++ b/doc/pages/hooks.asciidoc
@@ -48,24 +48,12 @@ name. Hooks with no description will always use an empty string.
*NormalIdle*::
a certain duration has passed since the last keypress in normal mode
-*NormalBegin*::
- entering normal mode
-
-*NormalEnd*::
- leaving normal mode
-
*NormalKey* `key`::
a key is received in normal mode
*InsertIdle*::
a certain duration has passed since the last keypress in insert mode
-*InsertBegin*::
- entering insert mode
-
-*InsertEnd*::
- leaving insert mode
-
*InsertKey* `key`::
a key is received in insert mode
@@ -150,8 +138,8 @@ name. Hooks with no description will always use an empty string.
*RuntimeError* `error message`::
an error was encountered while executing a user command
-*ModeChange* `<old mode>:<new mode>`::
- Triggered whenever the current input mode changes
+*ModeChange* `[push|pop]:<old mode>:<new mode>`::
+ Triggered whenever a mode is pushed or removed from the mode stack.
*KakBegin* `session name`::
kakoune has started, this hook is called just after reading the user
diff --git a/rc/filetype/awk.kak b/rc/filetype/awk.kak
index 12d852ba..af9d4492 100644
--- a/rc/filetype/awk.kak
+++ b/rc/filetype/awk.kak
@@ -12,7 +12,7 @@ hook global WinSetOption filetype=awk %{
require-module awk
hook window InsertChar \n -group awk-indent awk-indent-on-new-line
- hook window ModeChange insert:.* -group awk-trim-indent awk-trim-indent
+ hook window ModeChange pop:insert:.* -group awk-trim-indent awk-trim-indent
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window awk-.+ }
}
diff --git a/rc/filetype/c-family.kak b/rc/filetype/c-family.kak
index 6181fc8e..dbf342a4 100644
--- a/rc/filetype/c-family.kak
+++ b/rc/filetype/c-family.kak
@@ -29,7 +29,7 @@ hook global WinSetOption filetype=(c|cpp|objc) %[
evaluate-commands "set-option window static_words %%opt{%val{hook_param_capture_1}_static_words}"
- hook -group "%val{hook_param_capture_1}-trim-indent" window ModeChange insert:.* c-family-trim-indent
+ hook -group "%val{hook_param_capture_1}-trim-indent" window ModeChange pop:insert:.* c-family-trim-indent
hook -group "%val{hook_param_capture_1}-insert" window InsertChar \n c-family-insert-on-newline
hook -group "%val{hook_param_capture_1}-indent" window InsertChar \n c-family-indent-on-newline
hook -group "%val{hook_param_capture_1}-indent" window InsertChar \{ c-family-indent-on-opening-curly-brace
diff --git a/rc/filetype/cabal.kak b/rc/filetype/cabal.kak
index a376a2f7..6250350f 100644
--- a/rc/filetype/cabal.kak
+++ b/rc/filetype/cabal.kak
@@ -14,7 +14,7 @@ hook global BufCreate .*[.](cabal) %{
hook global WinSetOption filetype=cabal %[
require-module cabal
- hook window ModeChange insert:.* -group cabal-trim-indent cabal-trim-indent
+ hook window ModeChange pop:insert:.* -group cabal-trim-indent cabal-trim-indent
hook window InsertChar \n -group cabal-indent cabal-indent-on-new-line
hook window InsertChar \{ -group cabal-indent cabal-indent-on-opening-curly-brace
hook window InsertChar \} -group cabal-indent cabal-indent-on-closing-curly-brace
diff --git a/rc/filetype/clojure.kak b/rc/filetype/clojure.kak
index 9dc8c0a0..68b79eca 100644
--- a/rc/filetype/clojure.kak
+++ b/rc/filetype/clojure.kak
@@ -181,7 +181,7 @@ EOF
define-command -hidden clojure-configure-window %{
set-option window static_words %opt{clojure_static_words}
- hook window ModeChange insert:.* -group clojure-trim-indent clojure-trim-indent
+ hook window ModeChange pop:insert:.* -group clojure-trim-indent clojure-trim-indent
hook window InsertChar \n -group clojure-indent clojure-indent-on-new-line
set-option buffer extra_word_chars '_' . / * ? + - < > ! : "'"
diff --git a/rc/filetype/coffee.kak b/rc/filetype/coffee.kak
index a4b2fab6..ecd80403 100644
--- a/rc/filetype/coffee.kak
+++ b/rc/filetype/coffee.kak
@@ -14,7 +14,7 @@ hook global BufCreate .*[.](coffee) %{
hook global WinSetOption filetype=coffee %{
require-module coffee
- hook window ModeChange insert:.* -group coffee-trim-indent coffee-trim-indent
+ hook window ModeChange pop:insert:.* -group coffee-trim-indent coffee-trim-indent
hook window InsertChar \n -group coffee-indent coffee-indent-on-new-line
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window coffee-.+ }
diff --git a/rc/filetype/css.kak b/rc/filetype/css.kak
index edb1a36b..451fa8af 100644
--- a/rc/filetype/css.kak
+++ b/rc/filetype/css.kak
@@ -14,7 +14,7 @@ hook global BufCreate .*[.](css) %{
hook global WinSetOption filetype=css %[
require-module css
- hook window ModeChange insert:.* -group css-trim-indent css-trim-indent
+ hook window ModeChange pop:insert:.* -group css-trim-indent css-trim-indent
hook window InsertChar \n -group css-indent css-indent-on-new-line
hook window InsertChar \} -group css-indent css-indent-on-closing-curly-brace
set-option buffer extra_word_chars '_' '-'
diff --git a/rc/filetype/cucumber.kak b/rc/filetype/cucumber.kak
index aa24423c..f8db989e 100644
--- a/rc/filetype/cucumber.kak
+++ b/rc/filetype/cucumber.kak
@@ -14,7 +14,7 @@ hook global BufCreate .*[.](feature|story) %{
hook global WinSetOption filetype=cucumber %{
require-module cucumber
- hook window ModeChange insert:.* -group cucumber-trim-indent cucumber-trim-indent
+ hook window ModeChange pop:insert:.* -group cucumber-trim-indent cucumber-trim-indent
hook window InsertChar \n -group cucumber-indent cucumber-indent-on-new-line
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window cucumber-.+ }
diff --git a/rc/filetype/d.kak b/rc/filetype/d.kak
index ccc841d7..666f39b0 100644
--- a/rc/filetype/d.kak
+++ b/rc/filetype/d.kak
@@ -17,7 +17,7 @@ hook global WinSetOption filetype=d %{
set-option window static_words %opt{d_static_words}
# cleanup trailing whitespaces when exiting insert mode
- hook window ModeChange insert:.* -group d-trim-indent %{ try %{ execute-keys -draft <a-x>s^\h+$<ret>d } }
+ hook window ModeChange pop:insert:.* -group d-trim-indent %{ try %{ execute-keys -draft <a-x>s^\h+$<ret>d } }
hook window InsertChar \n -group d-indent d-indent-on-new-line
hook window InsertChar \{ -group d-indent d-indent-on-opening-curly-brace
hook window InsertChar \} -group d-indent d-indent-on-closing-curly-brace
@@ -77,7 +77,7 @@ evaluate-commands %sh{
types="${types}|string|ubyte|ucent|uint|ulong|ushort|void|wchar|wstring"
values="true|false|null"
tokens="__FILE__|__MODULE__|__LINE__|__FUNCTION__"
- tokens="${tokens}|__PRETTY_FUNCTION__|__DATE__|__EOF__|__TIME__"
+ tokens="${tokens}|__Change|pop:__DATE__|__EOF__|__TIME__"
tokens="${tokens}|__TIMESTAMP__|__VENDOR__|__VERSION__|#line"
properties="this|init|sizeof|alignof|mangleof|stringof|infinity|nan|dig|epsilon|mant_dig"
properties="${properties}|max_10_exp|min_exp|max|min_normal|re|im|classinfo"
diff --git a/rc/filetype/dart.kak b/rc/filetype/dart.kak
index 0c5913d9..6bb40fa3 100644
--- a/rc/filetype/dart.kak
+++ b/rc/filetype/dart.kak
@@ -17,7 +17,7 @@ hook global WinSetOption filetype=dart %{
set-option window static_words %opt{dart_static_words}
# cleanup trailing whitespaces when exiting insert mode
- hook window ModeChange insert:.* -group dart-trim-indent %{ try %{ execute-keys -draft <a-x>s^\h+$<ret>d } }
+ hook window ModeChange pop:insert:.* -group dart-trim-indent %{ try %{ execute-keys -draft <a-x>s^\h+$<ret>d } }
hook window InsertChar \n -group dart-indent dart-indent-on-new-line
hook window InsertChar \{ -group dart-indent dart-indent-on-opening-curly-brace
hook window InsertChar \} -group dart-indent dart-indent-on-closing-curly-brace
diff --git a/rc/filetype/elixir.kak b/rc/filetype/elixir.kak
index 56c3681e..c439880f 100644
--- a/rc/filetype/elixir.kak
+++ b/rc/filetype/elixir.kak
@@ -14,7 +14,7 @@ hook global BufCreate .*[.](ex|exs) %{
hook global WinSetOption filetype=elixir %{
require-module elixir
- hook window ModeChange insert:.* -group elixir-trim-indent elixir-trim-indent
+ hook window ModeChange pop:insert:.* -group elixir-trim-indent elixir-trim-indent
hook window InsertChar \n -group elixir-indent elixir-indent-on-new-line
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window elixir-.+ }
diff --git a/rc/filetype/elm.kak b/rc/filetype/elm.kak
index 0365c6e7..b0c1b214 100644
--- a/rc/filetype/elm.kak
+++ b/rc/filetype/elm.kak
@@ -14,7 +14,7 @@ hook global BufCreate .*[.](elm) %{
hook global WinSetOption filetype=elm %{
require-module elm
- hook window ModeChange insert:.* -group elm-trim-indent elm-trim-indent
+ hook window ModeChange pop:insert:.* -group elm-trim-indent elm-trim-indent
hook window InsertChar \n -group elm-indent elm-indent-on-new-line
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window elm-.+ }
diff --git a/rc/filetype/go.kak b/rc/filetype/go.kak
index fccb563b..79df696b 100644
--- a/rc/filetype/go.kak
+++ b/rc/filetype/go.kak
@@ -17,7 +17,7 @@ hook global WinSetOption filetype=go %{
set-option window static_words %opt{go_static_words}
# cleanup trailing whitespaces when exiting insert mode
- hook window ModeChange insert:.* -group go-trim-indent %{ try %{ execute-keys -draft <a-x>s^\h+$<ret>d } }
+ hook window ModeChange pop:insert:.* -group go-trim-indent %{ try %{ execute-keys -draft <a-x>s^\h+$<ret>d } }
hook window InsertChar \n -group go-indent go-indent-on-new-line
hook window InsertChar \{ -group go-indent go-indent-on-opening-curly-brace
hook window InsertChar \} -group go-indent go-indent-on-closing-curly-brace
diff --git a/rc/filetype/haml.kak b/rc/filetype/haml.kak
index f13c8764..e307363a 100644
--- a/rc/filetype/haml.kak
+++ b/rc/filetype/haml.kak
@@ -14,7 +14,7 @@ hook global BufCreate .*[.](haml) %{
hook global WinSetOption filetype=haml %{
require-module haml
- hook window ModeChange insert:.* -group haml-trim-indent haml-trim-indent
+ hook window ModeChange pop:insert:.* -group haml-trim-indent haml-trim-indent
hook window InsertChar \n -group haml-indent haml-indent-on-new-line
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window haml-.+ }
diff --git a/rc/filetype/haskell.kak b/rc/filetype/haskell.kak
index dd744f87..703084cb 100644
--- a/rc/filetype/haskell.kak
+++ b/rc/filetype/haskell.kak
@@ -15,7 +15,7 @@ hook global WinSetOption filetype=haskell %{
require-module haskell
set-option buffer extra_word_chars '_' "'"
- hook window ModeChange insert:.* -group haskell-trim-indent haskell-trim-indent
+ hook window ModeChange pop:insert:.* -group haskell-trim-indent haskell-trim-indent
hook window InsertChar \n -group haskell-indent haskell-indent-on-new-line
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window haskell-.+ }
diff --git a/rc/filetype/hbs.kak b/rc/filetype/hbs.kak
index 2474baf3..4b1b6b2e 100644
--- a/rc/filetype/hbs.kak
+++ b/rc/filetype/hbs.kak
@@ -11,7 +11,7 @@ hook global BufCreate .*[.](hbs) %{
hook global WinSetOption filetype=hbs %{
require-module hbs
- hook window ModeChange insert:.* -group hbs-trim-indent hbs-trim-indent
+ hook window ModeChange pop:insert:.* -group hbs-trim-indent hbs-trim-indent
hook window InsertChar \n -group hbs-indent hbs-indent-on-new-line
hook window InsertChar .* -group hbs-indent hbs-indent-on-char
hook window InsertChar '>' -group hbs-indent html-indent-on-greater-than
diff --git a/rc/filetype/html.kak b/rc/filetype/html.kak
index 57d1ee6e..d6385d10 100644
--- a/rc/filetype/html.kak
+++ b/rc/filetype/html.kak
@@ -18,7 +18,7 @@ hook global BufCreate .*\.xml %{
hook global WinSetOption filetype=(html|xml) %{
require-module html
- hook window ModeChange insert:.* -group "%val{hook_param_capture_1}-trim-indent" html-trim-indent
+ hook window ModeChange pop:insert:.* -group "%val{hook_param_capture_1}-trim-indent" html-trim-indent
hook window InsertChar '>' -group "%val{hook_param_capture_1}-indent" html-indent-on-greater-than
hook window InsertChar \n -group "%val{hook_param_capture_1}-indent" html-indent-on-new-line
diff --git a/rc/filetype/i3.kak b/rc/filetype/i3.kak
index b46a2388..91dc6d5e 100644
--- a/rc/filetype/i3.kak
+++ b/rc/filetype/i3.kak
@@ -9,7 +9,7 @@ hook global WinSetOption filetype=i3 %[
require-module i3
# cleanup trailing whitespaces when exiting insert mode
- hook window ModeChange insert:.* -group i3-trim-indent %{ try %{ execute-keys -draft <a-x>s^\h+$<ret>d } }
+ hook window ModeChange pop:insert:.* -group i3-trim-indent %{ try %{ execute-keys -draft <a-x>s^\h+$<ret>d } }
hook window InsertChar \n -group i3-indent i3-indent-on-new-line
hook window InsertChar \} -group i3-indent i3-indent-on-closing-curly-brace
diff --git a/rc/filetype/java.kak b/rc/filetype/java.kak
index 0fd2bec9..9db24740 100644
--- a/rc/filetype/java.kak
+++ b/rc/filetype/java.kak
@@ -9,7 +9,7 @@ hook global WinSetOption filetype=java %{
require-module java
# cleanup trailing whitespaces when exiting insert mode
- hook window ModeChange insert:.* -group java-trim-indent %{ try %{ execute-keys -draft <a-x>s^\h+$<ret>d } }
+ hook window ModeChange pop:insert:.* -group java-trim-indent %{ try %{ execute-keys -draft <a-x>s^\h+$<ret>d } }
hook window InsertChar \n -group java-indent java-indent-on-new-line
hook window InsertChar \{ -group java-indent java-indent-on-opening-curly-brace
hook window InsertChar \} -group java-indent java-indent-on-closing-curly-brace
diff --git a/rc/filetype/javascript.kak b/rc/filetype/javascript.kak
index d18aec24..73894ab3 100644
--- a/rc/filetype/javascript.kak
+++ b/rc/filetype/javascript.kak
@@ -15,7 +15,7 @@ hook global BufCreate .*[.](ts)x? %{
hook global WinSetOption filetype=(javascript|typescript) %{
require-module javascript
- hook window ModeChange insert:.* -group "%val{hook_param_capture_1}-trim-indent" javascript-trim-indent
+ hook window ModeChange pop:insert:.* -group "%val{hook_param_capture_1}-trim-indent" javascript-trim-indent
hook window InsertChar .* -group "%val{hook_param_capture_1}-indent" javascript-indent-on-char
hook window InsertChar \n -group "%val{hook_param_capture_1}-indent" javascript-indent-on-new-line
diff --git a/rc/filetype/json.kak b/rc/filetype/json.kak
index 094c3652..4ea31777 100644
--- a/rc/filetype/json.kak
+++ b/rc/filetype/json.kak
@@ -14,7 +14,7 @@ hook global BufCreate .*[.](json) %{
hook global WinSetOption filetype=json %{
require-module json
- hook window ModeChange insert:.* -group json-trim-indent json-trim-indent
+ hook window ModeChange pop:insert:.* -group json-trim-indent json-trim-indent
hook window InsertChar .* -group json-indent json-indent-on-char
hook window InsertChar \n -group json-indent json-indent-on-new-line
diff --git a/rc/filetype/kakrc.kak b/rc/filetype/kakrc.kak
index 4e473fcc..1c558f53 100644
--- a/rc/filetype/kakrc.kak
+++ b/rc/filetype/kakrc.kak
@@ -20,7 +20,7 @@ hook global WinSetOption filetype=kak %~
hook window InsertChar [>)}\]] -group kak-indent kak-indent-on-closing-matching
hook window InsertChar (?![[{(<>)}\]])[^\s\w] -group kak-indent kak-indent-on-closing-char
# cleanup trailing whitespaces on current line insert end
- hook window ModeChange insert:.* -group kak-trim-indent %{ try %{ execute-keys -draft \; <a-x> s ^\h+$ <ret> d } }
+ hook window ModeChange pop:insert:.* -group kak-trim-indent %{ try %{ execute-keys -draft \; <a-x> s ^\h+$ <ret> d } }
set-option buffer extra_word_chars '_' '-'
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window kak-.+ }
diff --git a/rc/filetype/latex.kak b/rc/filetype/latex.kak
index 2be1351f..e87e641f 100644
--- a/rc/filetype/latex.kak
+++ b/rc/filetype/latex.kak
@@ -16,7 +16,7 @@ hook global WinSetOption filetype=latex %(
hook window InsertChar \n -group latex-indent %{ latex-indent-newline }
hook window InsertChar \} -group latex-indent %{ latex-indent-closing-brace }
- hook window ModeChange insert:.* -group latex-indent %{ latex-trim-indent }
+ hook window ModeChange pop:insert:.* -group latex-indent %{ latex-trim-indent }
hook -once -always window WinSetOption filetype=.* %{ remove-hooks latex-indent }
)
diff --git a/rc/filetype/ledger.kak b/rc/filetype/ledger.kak
index 4e4eaaf9..5130a4a3 100644
--- a/rc/filetype/ledger.kak
+++ b/rc/filetype/ledger.kak
@@ -13,7 +13,7 @@ hook global WinSetOption filetype=ledger %{
require-module ledger
hook window InsertChar \n -group ledger-indent ledger-indent-on-new-line
- hook window ModeChange insert:.* -group ledger-trim-indent ledger-trim-indent
+ hook window ModeChange pop:insert:.* -group ledger-trim-indent ledger-trim-indent
hook -once -always window WinSetOption filetype=.* %{
remove-hooks window ledger-.+
diff --git a/rc/filetype/lisp.kak b/rc/filetype/lisp.kak
index a3e2d5fb..f2052b2f 100644
--- a/rc/filetype/lisp.kak
+++ b/rc/filetype/lisp.kak
@@ -14,7 +14,7 @@ hook global BufCreate .*[.](lisp) %{
hook global WinSetOption filetype=lisp %{
require-module lisp
- hook window ModeChange insert:.* -group lisp-trim-indent lisp-trim-indent
+ hook window ModeChange pop:insert:.* -group lisp-trim-indent lisp-trim-indent
hook window InsertChar \n -group lisp-indent lisp-indent-on-new-line
set-option buffer extra_word_chars '_' '+' '-' '*' '/' '@' '$' '%' '^' '&' '_' '=' '<' '>' '~' '.'
diff --git a/rc/filetype/moon.kak b/rc/filetype/moon.kak
index f4a2c1a9..b0245ede 100644
--- a/rc/filetype/moon.kak
+++ b/rc/filetype/moon.kak
@@ -14,7 +14,7 @@ hook global BufCreate .*[.](moon) %{
hook global WinSetOption filetype=moon %{
require-module moon
- hook window ModeChange insert:.* -group moon-trim-indent moon-trim-indent
+ hook window ModeChange pop:insert:.* -group moon-trim-indent moon-trim-indent
hook window InsertChar .* -group moon-indent moon-indent-on-char
hook window InsertChar \n -group moon-indent moon-indent-on-new-line
diff --git a/rc/filetype/nim.kak b/rc/filetype/nim.kak
index c73d2b38..59fdf225 100644
--- a/rc/filetype/nim.kak
+++ b/rc/filetype/nim.kak
@@ -18,7 +18,7 @@ hook global WinSetOption filetype=nim %{
hook window InsertChar \n -group nim-indent nim-indent-on-new-line
# cleanup trailing whitespaces on current line insert end
- hook window ModeChange insert:.* -group nim-trim-indent %{ try %{ exec -draft \; <a-x> s ^\h+$ <ret> d } }
+ hook window ModeChange pop:insert:.* -group nim-trim-indent %{ try %{ exec -draft \; <a-x> s ^\h+$ <ret> d } }
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window nim-.+ }
}
diff --git a/rc/filetype/nix.kak b/rc/filetype/nix.kak
index 77073bed..4f367195 100644
--- a/rc/filetype/nix.kak
+++ b/rc/filetype/nix.kak
@@ -14,7 +14,7 @@ hook global BufCreate .*[.](nix) %{
hook global WinSetOption filetype=nix %{
require-module nix
- hook window ModeChange insert:.* -group nix-trim-indent nix-trim-indent
+ hook window ModeChange pop:insert:.* -group nix-trim-indent nix-trim-indent
hook window InsertChar .* -group nix-indent nix-indent-on-char
hook window InsertChar \n -group nix-indent nix-indent-on-new-line
diff --git a/rc/filetype/perl.kak b/rc/filetype/perl.kak
index 92d9825c..ce435cc5 100644
--- a/rc/filetype/perl.kak
+++ b/rc/filetype/perl.kak
@@ -17,7 +17,7 @@ hook global WinSetOption filetype=perl %{
set-option window static_words %opt{perl_static_words}
# cleanup trailing whitespaces when exiting insert mode
- hook window ModeChange insert:.* -group perl-trim-indent %{ try %{ execute-keys -draft <a-x>s^\h+$<ret>d } }
+ hook window ModeChange pop:insert:.* -group perl-trim-indent %{ try %{ execute-keys -draft <a-x>s^\h+$<ret>d } }
hook window InsertChar \n -group perl-indent perl-indent-on-new-line
hook window InsertChar \{ -group perl-indent perl-indent-on-opening-curly-brace
hook window InsertChar \} -group perl-indent perl-indent-on-closing-curly-brace
diff --git a/rc/filetype/php.kak b/rc/filetype/php.kak
index d25d22ab..158da4e7 100644
--- a/rc/filetype/php.kak
+++ b/rc/filetype/php.kak
@@ -11,7 +11,7 @@ hook global BufCreate .*[.](php) %{
hook global WinSetOption filetype=php %{
require-module php
- hook window ModeChange insert:.* -group php-trim-indent php-trim-indent
+ hook window ModeChange pop:insert:.* -group php-trim-indent php-trim-indent
hook window InsertChar .* -group php-indent php-indent-on-char
hook window InsertChar \n -group php-indent php-indent-on-new-line
diff --git a/rc/filetype/pony.kak b/rc/filetype/pony.kak
index 762f7c1a..03911aec 100644
--- a/rc/filetype/pony.kak
+++ b/rc/filetype/pony.kak
@@ -18,7 +18,7 @@ hook global WinSetOption filetype=pony %{
hook window InsertChar \n -group pony-indent pony-indent-on-new-line
# cleanup trailing whitespaces on current line insert end
- hook window ModeChange insert:.* -group pony-trim-indent %{ try %{ execute-keys -draft \; <a-x> s ^\h+$ <ret> d } }
+ hook window ModeChange pop:insert:.* -group pony-trim-indent %{ try %{ execute-keys -draft \; <a-x> s ^\h+$ <ret> d } }
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window pony-.+ }
}
diff --git a/rc/filetype/pug.kak b/rc/filetype/pug.kak
index c4a30511..0b1597e1 100644
--- a/rc/filetype/pug.kak
+++ b/rc/filetype/pug.kak
@@ -18,7 +18,7 @@ hook global BufCreate .*[.](pug|jade) %{
hook global WinSetOption filetype=pug %{
require-module pug
- hook window ModeChange insert:.* -group pug-trim-indent pug-trim-indent
+ hook window ModeChange pop:insert:.* -group pug-trim-indent pug-trim-indent
hook window InsertChar \n -group pug-indent pug-indent-on-new-line
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window pug-.+ }
diff --git a/rc/filetype/python.kak b/rc/filetype/python.kak
index 91dcb1ef..b88f5343 100644
--- a/rc/filetype/python.kak
+++ b/rc/filetype/python.kak
@@ -18,7 +18,7 @@ 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-trim-indent %{ try %{ execute-keys -draft \; <a-x> s ^\h+$ <ret> d } }
+ hook window ModeChange pop:insert:.* -group python-trim-indent %{ try %{ execute-keys -draft \; <a-x> s ^\h+$ <ret> d } }
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window python-.+ }
}
diff --git a/rc/filetype/r.kak b/rc/filetype/r.kak
index b5b6f6b5..ced4ad93 100644
--- a/rc/filetype/r.kak
+++ b/rc/filetype/r.kak
@@ -133,7 +133,7 @@ hook -group r-highlight global WinSetOption filetype=r %{
}
hook global WinSetOption filetype=r %~
- hook window ModeChange insert:.* r-trim-indent
+ hook window ModeChange pop:insert:.* r-trim-indent
hook window InsertChar \n r-insert-on-newline
hook window InsertChar \n r-indent-on-newline
hook window InsertChar \{ r-indent-on-opening-curly-brace
diff --git a/rc/filetype/ragel.kak b/rc/filetype/ragel.kak
index 8f3d448f..67949a83 100644
--- a/rc/filetype/ragel.kak
+++ b/rc/filetype/ragel.kak
@@ -16,7 +16,7 @@ hook global BufCreate .*[.](ragel|rl) %{
hook global WinSetOption filetype=ragel %{
require-module ragel
- hook window ModeChange insert:.* -group ragel-trim-indent ragel-trim-indent
+ hook window ModeChange pop:insert:.* -group ragel-trim-indent ragel-trim-indent
hook window InsertChar .* -group ragel-indent ragel-indent-on-char
hook window InsertChar \n -group ragel-indent ragel-indent-on-new-line
diff --git a/rc/filetype/rust.kak b/rc/filetype/rust.kak
index 0fc61af2..22178060 100644
--- a/rc/filetype/rust.kak
+++ b/rc/filetype/rust.kak
@@ -13,7 +13,7 @@ hook global BufCreate .*[.](rust|rs) %{
hook global WinSetOption filetype=rust %[
require-module rust
- hook window InsertEnd .* -group rust-trim-indent rust-trim-indent
+ hook window ModeChange pop:insert:.* -group rust-trim-indent rust-trim-indent
hook window InsertChar \n -group rust-indent rust-indent-on-new-line
hook window InsertChar \{ -group rust-indent rust-indent-on-opening-curly-brace
hook window InsertChar [)}] -group rust-indent rust-indent-on-closing
diff --git a/rc/filetype/sass.kak b/rc/filetype/sass.kak
index c5872253..8c3212fd 100644
--- a/rc/filetype/sass.kak
+++ b/rc/filetype/sass.kak
@@ -14,7 +14,7 @@ hook global BufCreate .*[.](sass) %{
hook global WinSetOption filetype=sass %{
require-module sass
- hook window ModeChange insert:.* -group sass-trim-indent sass-trim-indent
+ hook window ModeChange pop:insert:.* -group sass-trim-indent sass-trim-indent
hook window InsertChar \n -group sass-indent sass-indent-on-new-line
set-option buffer extra_word_chars '_' '-'
diff --git a/rc/filetype/scala.kak b/rc/filetype/scala.kak
index 73f086b5..47c5bbe7 100644
--- a/rc/filetype/scala.kak
+++ b/rc/filetype/scala.kak
@@ -14,7 +14,7 @@ hook global BufCreate .*[.](scala) %{
hook global WinSetOption filetype=scala %[
require-module scala
- hook window ModeChange insert:.* -group scala-trim-indent scala-trim-indent
+ hook window ModeChange pop:insert:.* -group scala-trim-indent scala-trim-indent
hook window InsertChar \n -group scala-indent scala-indent-on-new-line
hook window InsertChar \} -group scala-indent scala-indent-on-closing-curly-brace
diff --git a/rc/filetype/scheme.kak b/rc/filetype/scheme.kak
index b130127b..06cb7992 100644
--- a/rc/filetype/scheme.kak
+++ b/rc/filetype/scheme.kak
@@ -17,7 +17,7 @@ hook global WinSetOption filetype=scheme %{
set-option window static_words %opt{scheme_static_words}
set-option buffer extra_word_chars '_' '-' '!' '%' '?' '<' '>' '='
- hook window InsertEnd .* -group scheme-trim-indent lisp-trim-indent
+ hook window ModeChange pop:insert:.* -group scheme-trim-indent lisp-trim-indent
hook window InsertChar \n -group scheme-indent lisp-indent-on-new-line
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window scheme-.+ }
diff --git a/rc/filetype/scss.kak b/rc/filetype/scss.kak
index 7cb15e52..95167e75 100644
--- a/rc/filetype/scss.kak
+++ b/rc/filetype/scss.kak
@@ -14,7 +14,7 @@ hook global BufCreate .*[.](scss) %{
hook global WinSetOption filetype=scss %[
require-module scss
- hook window ModeChange insert:.* -group scss-trim-indent scss-trim-indent
+ hook window ModeChange pop:insert:.* -group scss-trim-indent scss-trim-indent
hook window InsertChar \n -group scss-indent scss-indent-on-new-line
hook window InsertChar \} -group scss-indent scss-indent-on-closing-curly-brace
set-option buffer extra_word_chars '_' '-'
diff --git a/rc/filetype/sh.kak b/rc/filetype/sh.kak
index a48e6d29..9c362d30 100644
--- a/rc/filetype/sh.kak
+++ b/rc/filetype/sh.kak
@@ -6,7 +6,7 @@ hook global WinSetOption filetype=sh %{
require-module sh
set-option window static_words %opt{sh_static_words}
- hook window ModeChange insert:.* -group sh-trim-indent sh-trim-indent
+ hook window ModeChange pop:insert:.* -group sh-trim-indent sh-trim-indent
hook window InsertChar \n -group sh-indent sh-indent-on-new-line
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window sh-.+ }
}
diff --git a/rc/filetype/toml.kak b/rc/filetype/toml.kak
index 4a7ad81c..fa3f58cb 100644
--- a/rc/filetype/toml.kak
+++ b/rc/filetype/toml.kak
@@ -14,7 +14,7 @@ hook global BufCreate .*\.(toml) %{
hook global WinSetOption filetype=toml %{
require-module toml
- hook window ModeChange insert:.* -group toml-trim-indent toml-trim-indent
+ hook window ModeChange pop:insert:.* -group toml-trim-indent toml-trim-indent
hook window InsertChar \n -group toml-indent toml-indent-on-new-line
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window toml-.+ }
diff --git a/rc/filetype/yaml.kak b/rc/filetype/yaml.kak
index ac8a9823..9731ff53 100644
--- a/rc/filetype/yaml.kak
+++ b/rc/filetype/yaml.kak
@@ -14,7 +14,7 @@ hook global BufCreate .*[.](ya?ml) %{
hook global WinSetOption filetype=yaml %{
require-module yaml
- hook window ModeChange insert:.* -group yaml-trim-indent yaml-trim-indent
+ hook window ModeChange pop:insert:.* -group yaml-trim-indent yaml-trim-indent
hook window InsertChar \n -group yaml-indent yaml-indent-on-new-line
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window yaml-.+ }
}
diff --git a/src/hook_manager.hh b/src/hook_manager.hh
index 71e9e2d1..302e3e14 100644
--- a/src/hook_manager.hh
+++ b/src/hook_manager.hh
@@ -30,10 +30,8 @@ enum class Hook
BufSetOption,
ClientCreate,
ClientClose,
- InsertBegin,
InsertChar,
InsertDelete,
- InsertEnd,
InsertIdle,
InsertKey,
InsertMove,
@@ -46,8 +44,6 @@ enum class Hook
GlobalSetOption,
RuntimeError,
PromptIdle,
- NormalBegin,
- NormalEnd,
NormalIdle,
NormalKey,
ModeChange,
@@ -62,7 +58,7 @@ enum class Hook
constexpr auto enum_desc(Meta::Type<Hook>)
{
- return make_array<EnumDesc<Hook>, 41>({
+ return make_array<EnumDesc<Hook>, 38>({
{Hook::BufCreate, "BufCreate"},
{Hook::BufNewFile, "BufNewFile"},
{Hook::BufOpenFile, "BufOpenFile"},
@@ -76,10 +72,8 @@ constexpr auto enum_desc(Meta::Type<Hook>)
{Hook::BufSetOption, "BufSetOption"},
{Hook::ClientCreate, "ClientCreate"},
{Hook::ClientClose, "ClientClose"},
- {Hook::InsertBegin, "InsertBegin"},
{Hook::InsertChar, "InsertChar"},
{Hook::InsertDelete, "InsertDelete"},
- {Hook::InsertEnd, "InsertEnd"},
{Hook::InsertIdle, "InsertIdle"},
{Hook::InsertKey, "InsertKey"},
{Hook::InsertMove, "InsertMove"},
@@ -92,8 +86,6 @@ constexpr auto enum_desc(Meta::Type<Hook>)
{Hook::GlobalSetOption, "GlobalSetOption"},
{Hook::RuntimeError, "RuntimeError"},
{Hook::PromptIdle, "PromptIdle"},
- {Hook::NormalBegin, "NormalBegin"},
- {Hook::NormalEnd, "NormalEnd"},
{Hook::NormalIdle, "NormalIdle"},
{Hook::NormalKey, "NormalKey"},
{Hook::ModeChange, "ModeChange"},
diff --git a/src/input_handler.cc b/src/input_handler.cc
index 56de0bd1..5cb780ee 100644
--- a/src/input_handler.cc
+++ b/src/input_handler.cc
@@ -203,8 +203,6 @@ public:
context().hooks_disabled().unset();
m_hooks_disabled = false;
}
-
- context().hooks().run_hook(Hook::NormalBegin, "", context());
}
void on_disabled(bool temporary) override
@@ -217,8 +215,6 @@ public:
context().hooks_disabled().unset();
m_hooks_disabled = false;
}
-
- context().hooks().run_hook(Hook::NormalEnd, "", context());
}
void on_key(Key key) override
@@ -1153,7 +1149,6 @@ public:
last_insert().keys.clear();
last_insert().disable_hooks = context().hooks_disabled();
last_insert().count = count;
- context().hooks().run_hook(Hook::InsertBegin, "", context());
prepare(mode, count);
}
@@ -1197,11 +1192,6 @@ public:
}
else if (key == Key::Escape or key == ctrl('c'))
{
- if (m_in_end)
- throw runtime_error("asked to exit insert mode while running InsertEnd hook");
- m_in_end = true;
- context().hooks().run_hook(Hook::InsertEnd, "", context());
-
m_completer.reset();
pop_mode();
}
@@ -1496,7 +1486,6 @@ private:
const bool m_restore_cursor;
bool m_auto_complete;
Timer m_idle_timer;
- bool m_in_end = false;
MouseHandler m_mouse_handler;
ScopedSetBool m_disable_hooks;
};
@@ -1520,7 +1509,7 @@ void InputHandler::push_mode(InputMode* new_mode)
m_mode_stack.emplace_back(new_mode);
new_mode->on_enabled();
- context().hooks().run_hook(Hook::ModeChange, format("{}:{}", prev_name, new_mode->name()), context());
+ context().hooks().run_hook(Hook::ModeChange, format("push:{}:{}", prev_name, new_mode->name()), context());
}
void InputHandler::pop_mode(InputMode* mode)
@@ -1534,7 +1523,7 @@ void InputHandler::pop_mode(InputMode* mode)
m_mode_stack.pop_back();
current_mode().on_enabled();
- context().hooks().run_hook(Hook::ModeChange, format("{}:{}", prev_name, current_mode().name()), context());
+ context().hooks().run_hook(Hook::ModeChange, format("pop:{}:{}", prev_name, current_mode().name()), context());
}
void InputHandler::reset_normal_mode()
@@ -1543,12 +1532,8 @@ void InputHandler::reset_normal_mode()
if (m_mode_stack.size() == 1)
return;
- StringView prev_name = current_mode().name();
- current_mode().on_disabled(false);
- m_mode_stack.resize(1);
- current_mode().on_enabled();
-
- context().hooks().run_hook(Hook::ModeChange, format("{}:{}", prev_name, current_mode().name()), context());
+ while (m_mode_stack.size() > 1)
+ pop_mode(m_mode_stack.back().get());
}
void InputHandler::insert(InsertMode mode, int count)
diff --git a/src/main.cc b/src/main.cc
index de2dba2d..5cc39286 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -44,6 +44,10 @@ struct {
unsigned int version;
const char* notes;
} constexpr version_notes[] = { {
+ 0,
+ "» ModeChange parameter has changed to contain push/pop\n"
+ " ${Mode}Begin/${Mode}End hooks were removed\n"
+ }, {
20190701,
"» %file{...} expansions to read files\n"
"» echo -to-file <filename> to write to file\n"