all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Edge case in c-cleanup
@ 2015-02-08 17:16 Miguel Guedes
  0 siblings, 0 replies; 2+ messages in thread
From: Miguel Guedes @ 2015-02-08 17:16 UTC (permalink / raw
  To: help-gnu-emacs

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.


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Edge case in c-cleanup
@ 2015-02-09 18:35 Miguel Guedes
  0 siblings, 0 replies; 2+ messages in thread
From: Miguel Guedes @ 2015-02-09 18:35 UTC (permalink / raw
  To: help-gnu-emacs



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.



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-02-09 18:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-09 18:35 Edge case in c-cleanup Miguel Guedes
  -- strict thread matches above, loose matches on Subject: below --
2015-02-08 17:16 Miguel Guedes

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.