From cbfc6d3cd00a14f2f9003ecff8c9f2fa5baffc34 Mon Sep 17 00:00:00 2001 From: Frank LENORMAND Date: Tue, 27 Oct 2015 17:23:04 +0300 Subject: [PATCH] Allow different type of pre-processing guards to be included in C headers. This commit introduces the `c_include_guard_style` option, which can take one of the following values: "ifdef", "pragma", "none". The corresponding type of guard will be used accordingly to the value of this variable. --- rc/c-family.kak | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/rc/c-family.kak b/rc/c-family.kak index 1e0bf1c4..a033ac10 100644 --- a/rc/c-family.kak +++ b/rc/c-family.kak @@ -145,8 +145,19 @@ hook global WinSetOption filetype=(?!cpp$).* %[ rmhl cpp ] hook global WinSetOption filetype=objc %[ addhl ref objc ] hook global WinSetOption filetype=(?!objc$).* %[ rmhl objc ] +decl str c_include_guard_style "ifdef" def -hidden _c-family-insert-include-guards %{ - exec ggi%ggxs\.c_A_INCLUDEDggxyppI#ifndefjI#definejI#endif//O + %sh{ + case "${kak_opt_c_include_guard_style,,}" in + ifdef) + echo "exec ggi%ggxs\.c_A_INCLUDEDggxyppI#ifndefjI#definejI#endif//O" + ;; + pragma) + echo "exec ggi#pragmaonce" + ;; + *);; + esac + } } hook global BufNew .*\.(h|hh|hpp|hxx|H) _c-family-insert-include-guards