summaryrefslogtreecommitdiff
path: root/rc/filetype/pascal.kak
diff options
context:
space:
mode:
authorJohannes Altmanninger <aclopte@gmail.com>2022-05-08 15:01:25 +0200
committerJohannes Altmanninger <aclopte@gmail.com>2022-05-29 08:23:33 +0200
commit6f28178b91cbecd1bb8f92b9731c9e85c915abdf (patch)
treef933ec8e71aaf284677702f2ff441465fc986b9c /rc/filetype/pascal.kak
parent19806a4b4c4480d3fb4421b9b77622a85d7f3b99 (diff)
rc filetype: add trim-indent hooks to all languages that have indent hooks
An indent hook automatically adds whitespace, so it seems prudent to add the hook to remove unwanted whitespace again. This is what we do in most languages already.
Diffstat (limited to 'rc/filetype/pascal.kak')
-rw-r--r--rc/filetype/pascal.kak9
1 files changed, 9 insertions, 0 deletions
diff --git a/rc/filetype/pascal.kak b/rc/filetype/pascal.kak
index 9d8267a4..8c70210b 100644
--- a/rc/filetype/pascal.kak
+++ b/rc/filetype/pascal.kak
@@ -14,6 +14,7 @@ hook global BufCreate .*\.(lpr|lfm)$ %{
hook global WinSetOption filetype=((free|object)?pascal|delphi) %[
require-module pascal
+ hook window ModeChange pop:insert:.* -group pascal-trim-indent pascal-trim-indent
hook window InsertChar \n -group pascal-indent pascal-indent-on-new-line
hook -once -always window WinSetOption filetype=.* %{ remove-hooks window pascal-.+ }
set-option window static_words %opt{static_words}
@@ -189,6 +190,14 @@ EOF
done
ΒΆ
+define-command -hidden pascal-trim-indent %{
+ evaluate-commands -no-hooks -draft -itersel %{
+ execute-keys <a-x>
+ # remove trailing white spaces
+ try %{ execute-keys -draft s \h + $ <ret> d }
+ }
+}
+
define-command -hidden pascal-indent-on-new-line %{
evaluate-commands -no-hooks -draft -itersel %{
# preserve previous line indent