From a31d947e1dca5be9178ab4ac9a685f64718c35e9 Mon Sep 17 00:00:00 2001 From: Frank LENORMAND Date: Thu, 10 Mar 2016 15:12:08 +0200 Subject: [PATCH] Give commands that do not indent their own `insert` hook --- rc/base/ruby.kak | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/rc/base/ruby.kak b/rc/base/ruby.kak index fe4272fe..ee9174ef 100644 --- a/rc/base/ruby.kak +++ b/rc/base/ruby.kak @@ -75,10 +75,15 @@ def -hidden _ruby_indent_on_new_line %{ eval -draft -itersel %{ # preserve previous line indent try %{ exec -draft K } - # copy _#_ comment prefix and following white spaces - try %{ exec -draft k x s ^ \h * \K \# \h * y j p } # indent after start structure try %{ exec -draft k x ^ \h * (begin|case|class|def|do|else|elsif|ensure|for|if|module|rescue|unless|until|when|while) \b j } + } +} + +def -hidden _ruby_insert_on_new_line %{ + eval -draft -itersel %{ + # copy _#_ comment prefix and following white spaces + try %{ exec -draft k x s ^ \h * \K \# \h * y j p } # wisely add end structure eval -save-regs x %{ try %{ exec -draft k x s ^ \h + \" x y } catch %{ reg x '' } @@ -95,6 +100,7 @@ hook global WinSetOption filetype=ruby %{ hook window InsertChar .* -group ruby-indent _ruby_indent_on_char hook window InsertChar \n -group ruby-indent _ruby_indent_on_new_line + hook window InsertChar \n -group ruby-insert _ruby_insert_on_new_line set window comment_line_chars '#' set window comment_selection_chars '^begin=:^=end'