[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Edge case in c-cleanup
From: |
Miguel Guedes |
Subject: |
Edge case in c-cleanup |
Date: |
Mon, 09 Feb 2015 18:35:06 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 |
I have got the following clean ups defined in a c style (c-add-style):
(c-cleanup-list . (brace-else-brace
brace-elseif-brace
brace-catch-brace
empty-defun-braces
one-liner-defun
defun-close-semi
space-before-funcall
compact-empty-funcall))
I have noticed a minor annoying edge case that can be best illustrated
as given by:
int bazillion()
{
if(booz) {
foo();
} // typing closing brace, issues newline
else // no opening brace means `elseĀ“ isn't placed above
bar();
}
Since in my current setup typing `}' automatically issues a newline,
emacs won't correctly place an else statement next to the closing brace
above (as desired) *if it does not* contain an opening brace. For
instance, this would work just fine:
int bazillion()
{
if(booz) {
foo();
} else { // else is moved up next to the closing brace
bar(); // after typing the subsequent opening brace
}
}
Is there are way of resolving this via a style setting perhaps such that
`elseĀ“ statements without opening braces are correctly placed?
Unsure if I made my question clear enough so please ask for
clarification if in doubt.