summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrank LENORMAND <lenormand@pkcc-tb.ru>2015-10-27 17:23:04 +0300
committerFrank LENORMAND <lenormand@pkcc-tb.ru>2015-10-27 17:23:04 +0300
commitcbfc6d3cd00a14f2f9003ecff8c9f2fa5baffc34 (patch)
treef6ff7a4617f7c24d148aa6a1b90a7cde7fce0cea
parent8f7c2ac636369f1f012fe1685ce9c0220fa81645 (diff)
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.
-rw-r--r--rc/c-family.kak13
1 files changed, 12 insertions, 1 deletions
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<c-r>%<ret><esc>ggxs\.<ret>c_<esc><space>A_INCLUDED<esc>ggxyppI#ifndef<space><esc>jI#define<space><esc>jI#endif<space>//<space><esc>O<esc>
+ %sh{
+ case "${kak_opt_c_include_guard_style,,}" in
+ ifdef)
+ echo "exec ggi<c-r>%<ret><esc>ggxs\.<ret>c_<esc><space>A_INCLUDED<esc>ggxyppI#ifndef<space><esc>jI#define<space><esc>jI#endif<space>//<space><esc>O<esc>"
+ ;;
+ pragma)
+ echo "exec ggi#pragma<space>once<esc>"
+ ;;
+ *);;
+ esac
+ }
}
hook global BufNew .*\.(h|hh|hpp|hxx|H) _c-family-insert-include-guards