GNU bug report logs - #12527
24.2; idented preprocessor directives confusing cc-mode indent

Previous Next

Packages: emacs, cc-mode;

Reported by: Kevin Burge <kcburge <at> gmail.com>

Date: Thu, 27 Sep 2012 19:41:01 UTC

Severity: normal

Found in version 24.2

Fixed in version 24.5

Done: Alex <agrambot <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 12527 in the body.
You can then email your comments to 12527 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#12527; Package emacs. (Thu, 27 Sep 2012 19:41:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Kevin Burge <kcburge <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 27 Sep 2012 19:41:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Kevin Burge <kcburge <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.2; idented preprocessor directives confusing cc-mode indent
Date: Thu, 27 Sep 2012 13:22:39 -0500
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)




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#12527; Package emacs,cc-mode. (Sun, 14 Aug 2016 20:52:02 GMT) Full text and rfc822 format available.

Message #8 received at 12527 <at> debbugs.gnu.org (full text, mbox):

From: Alex <agrambot <at> gmail.com>
To: Kevin Burge <kcburge <at> gmail.com>
Cc: 12527 <at> debbugs.gnu.org
Subject: Re: bug#12527: 24.2;
 idented preprocessor directives confusing cc-mode indent
Date: Sun, 14 Aug 2016 14:51:49 -0600
close 12527 24.5
quit

Kevin Burge <kcburge <at> 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.




bug marked as fixed in version 24.5, send any further explanations to 12527 <at> debbugs.gnu.org and Kevin Burge <kcburge <at> gmail.com> Request was from Alex <agrambot <at> gmail.com> to control <at> debbugs.gnu.org. (Sun, 14 Aug 2016 20:52:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 12 Sep 2016 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 9 years and 3 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.