Indent labels by one space. Add the rule to HACKING and enforce it by syntax-check. --- Adding a space helps git's function context detection, but the fallout patch is over 800K. My reasoning for also indenting labels in nested code is that vim's cinoptions don't have a separate option for these labels (or I haven't searched hard enough?). Inspired by this thread: https://www.redhat.com/archives/libvir-list/2014-March/msg01310.html cfg.mk | 7 +++++++ docs/hacking.html.in | 18 +++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/cfg.mk b/cfg.mk index 559f719..1512fb2 100644 --- a/cfg.mk +++ b/cfg.mk @@ -898,6 +898,13 @@ sc_prohibit_virConnectOpen_in_virsh: halt='Use vshConnect() in virsh instead of virConnectOpen*' \ $(_sc_search_regexp) +sc_require_space_before_label: + @prohibit='^(( {2})*|( {3})*)([_a-zA-Z0-9]+):$$' \ + exclude='( {4})*default:$$' \ + in_vc_files='\.[ch]$$' \ + halt="Labels should be indented by 4*n + 1 spaces" \ + $(_sc_search_regexp) + sc_curly_braces_style: @files=$$($(VC_LIST_EXCEPT) | grep '\.[ch]$$'); \ $(GREP) -nHP \ diff --git a/docs/hacking.html.in b/docs/hacking.html.in index 0febee2..b2b158a 100644 --- a/docs/hacking.html.in +++ b/docs/hacking.html.in @@ -303,7 +303,7 @@ set tabstop=8 set shiftwidth=4 set expandtab - set cinoptions=(0,:0,l1,t0 + set cinoptions=(0,:0,l1,t0,L3 filetype plugin indent on au FileType make setlocal noexpandtab au BufRead,BufNewFile *.am setlocal noexpandtab @@ -1139,6 +1139,22 @@ retry: If needing to jump upwards (e.g., retry on EINTR) </pre> + <p> + Labels should be indented by one space (putting them on the beginning + of the line confuses function context detection in emacs and git): + </p> + +<pre> +int foo() +{ + if (wizz) { + retry: + goto retry; + } + cleanup: +} +</pre> + <h2><a name="committers">Libvirt committer guidelines</a></h2> -- 1.8.3.2 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list