all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Kevin Burge <kcburge@gmail.com>
To: 12527@debbugs.gnu.org
Subject: bug#12527: 24.2; idented preprocessor directives confusing cc-mode indent
Date: Thu, 27 Sep 2012 13:22:39 -0500	[thread overview]
Message-ID: <CAEb-Ao-PFw9UXijesXrDv0w62hJzZLsNy_rar58QsRxDAn_F2Q@mail.gmail.com> (raw)

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)





             reply	other threads:[~2012-09-27 18:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-27 18:22 Kevin Burge [this message]
2016-08-14 20:51 ` bug#12527: 24.2; idented preprocessor directives confusing cc-mode indent Alex

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAEb-Ao-PFw9UXijesXrDv0w62hJzZLsNy_rar58QsRxDAn_F2Q@mail.gmail.com \
    --to=kcburge@gmail.com \
    --cc=12527@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.