all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#12527: 24.2; idented preprocessor directives confusing cc-mode indent
@ 2012-09-27 18:22 Kevin Burge
  2016-08-14 20:51 ` Alex
  0 siblings, 1 reply; 2+ messages in thread
From: Kevin Burge @ 2012-09-27 18:22 UTC (permalink / raw)
  To: 12527

Summary: Indenting the preprocessor blocks at least 1 space completely
throws off the cc-mode indentation for anything after the
preprocessor block.

To reproduce: Create the simple file "test.cpp":

===
int f(void) {
  #if defined(A)
  printf("test\n");
  #endif

  if (test) {
    int i = 0;
  }
}
===

IMPORTANT: "#if.....#endif" block MUST be indented at least 1 space.

If you navigate inside the "if (test)" block and hit tab, it
un-indents the line, and any lines after it, to the end of the file.
If you reindent the entire file, it works just fine, because the
indented preprocessor directives, which works around the problem.

You have to play around with this, too.  There are certain variations
of the #if line that affect the behavior.  And, each time you test,
you MUST re-open the file, because the caching seems to completely
throw it off.

I.e. if you change the #if block to

===
  #if 0
  printf("test\n");
  #endif
===

And re-load the file, then try to indent the "if (test)" block, it
does what it should.  Also, changing it to (and reloading):

===
  #if A
  printf("test\n");
  #endif
===

Is sufficient to break it again.  So, it seems like whatever follows
the #if affects the behavior.

Note: I ran with emacs -q, so, it's not processing any of my configuration.

I have hundreds of thousands of lines of codes that use indented
preprocessor directives, so making all those changes is not really an
option for us.

===========================

In GNU Emacs 24.2.1 (x86_64-unknown-linux-gnu, X toolkit, Xaw3d scroll bars)
 of 2012-09-27 on kevin
Windowing system distributor `CentOS', version 11.0.11006000
Configured using:
 `configure '--prefix=/usr/local/emacs24' '--with-x-toolkit=lucid''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: nil
  value of $XMODIFIERS: @im=none
  locale-coding-system: nil
  default enable-multibyte-characters: t

Major mode: C++/l

Minor modes in effect:
  tooltip-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t
  abbrev-mode: t

Recent input:
C-x C-f t e s t . c p <tab> <return> C-n <tab> C-n
C-/ C-n <tab> C-n <tab> C-/ C-x C-s C-n C-n C-a <tab>
C-n C-a <tab> C-n C-a <tab> <tab> <tab> <tab> C-p C-p
C-p C-p C-p C-p C-p C-p C-p C-SPC C-n C-n C-n C-n C-n
C-n C-n C-n C-n M-w <M-down-mouse-1> <mouse-movement>
<mouse-movement> <M-drag-mouse-1> M-x b u <backspace>
<backspace> r e p o r t - b u g <tab> <return>

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Undo! [2 times]
(No changes need to be saved)
byte-code: Beginning of buffer [2 times]
Mark set

Load-path shadows:
None found.

Features:
(shadow sort gnus-util mail-extr emacsbug message format-spec rfc822 mml
mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev
gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util
mail-prsvr mail-utils cc-mode cc-fonts easymenu cc-guess cc-menus
cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs regexp-opt
time-date tooltip ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd
tool-bar dnd fontset image fringe lisp-mode register page menu-bar
rfn-eshadow timer select scroll-bar mouse jit-lock font-lock syntax
facemenu font-core frame cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese hebrew greek romanian slovak
czech european ethiopic indian cyrillic chinese case-table epa-hook
jka-cmpr-hook help simple abbrev minibuffer loaddefs button faces
cus-face files text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget hashtable-print-readable backquote
make-network-process dbusbind dynamic-setting system-font-setting
font-render-setting x-toolkit x multi-tty emacs)





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

* bug#12527: 24.2; idented preprocessor directives confusing cc-mode indent
  2012-09-27 18:22 bug#12527: 24.2; idented preprocessor directives confusing cc-mode indent Kevin Burge
@ 2016-08-14 20:51 ` Alex
  0 siblings, 0 replies; 2+ messages in thread
From: Alex @ 2016-08-14 20:51 UTC (permalink / raw)
  To: Kevin Burge; +Cc: 12527

close 12527 24.5
quit

Kevin Burge <kcburge@gmail.com> writes:

> Summary: Indenting the preprocessor blocks at least 1 space completely
> throws off the cc-mode indentation for anything after the
> preprocessor block.
>
> To reproduce: Create the simple file "test.cpp":
>
> ===
> int f(void) {
>   #if defined(A)
>   printf("test\n");
>   #endif
>
>   if (test) {
>     int i = 0;
>   }
> }
> ===
>
> IMPORTANT: "#if.....#endif" block MUST be indented at least 1 space.
>
> If you navigate inside the "if (test)" block and hit tab, it
> un-indents the line, and any lines after it, to the end of the file.
> If you reindent the entire file, it works just fine, because the
> indented preprocessor directives, which works around the problem.
>
> You have to play around with this, too.  There are certain variations
> of the #if line that affect the behavior.  And, each time you test,
> you MUST re-open the file, because the caching seems to completely
> throw it off.
>
> I.e. if you change the #if block to
>
> ===
>   #if 0
>   printf("test\n");
>   #endif
> ===
>
> And re-load the file, then try to indent the "if (test)" block, it
> does what it should.  Also, changing it to (and reloading):
>
> ===
>   #if A
>   printf("test\n");
>   #endif
> ===
>
> Is sufficient to break it again.  So, it seems like whatever follows
> the #if affects the behavior.

This appears to work fine in 24.5.





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

end of thread, other threads:[~2016-08-14 20:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-27 18:22 bug#12527: 24.2; idented preprocessor directives confusing cc-mode indent Kevin Burge
2016-08-14 20:51 ` Alex

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.