Subject: 23.1.92; Indentation problems in C mode
From: Michael Welsh Duggan <[email-masked]>
To: [email-masked]
Date: Thu, 25 Feb 2010 11:11:37 -0500
List-Id: <debbugs-submit.debbugs.gnu.org>

I'm getting some screwy indentation behavior from C mode.  From a
current bzr checkout/install of emacs, try the following recipe: 

emacs -Q foo.c                 | starts emacs on foo.c (included below)
C-u 7 C-n                      | move down 7 lines
TAB                            | indent, nothing changes (good)
C-p C-p                        | move up 2 lines
TAB C-n TAB C-n                | indent 2 lines, nothing changes (good)
TAB                            | line unindents by 2 (bad)
TAB                            | line re-indents (good, but strange)
TAB                            | no change this time

And here's another recipe for weirdness:

emacs -Q foo.c                 | starts emacs on foo.c (included below)
C-x h                          | select buffer
C-M-\                          | indent region everything from line 7
                               |   down to the while (0) unindents 2
C-u 5 C-n                      | move down to the do {
C-x ( TAB C-n C-x )            | define a macro to indent and move down
                               |   a line
C-x e e e e e e                | Indent each line, no change

Here's foo.c

#if !SK_ENABLE_IPV6
#  define skipaddrApplyCIDR(ipaddr, cidr)       \
  ipUnionApplyCIDRV4(&(ipaddr)->ip_ip, cidr)
#else
#  define skipaddrApplyCIDR(ipaddr, cidr)                       \
  do {								\
    if (skipaddrIsV6(ipaddr)) {					\
      ipUnionApplyCIDRV6(&((ipaddr)->ip_ip), cidr);		\
    } else {							\
      ipUnionApplyCIDRV4(&((ipaddr)->ip_ip), cidr);		\
    }								\
  } while (0)
#endif

In GNU Emacs 23.1.92.2 (i686-pc-linux-gnu, GTK+ Version 2.10.4)
 of 2010-02-19 on maru.green.cert.org
Windowing system distributor `The X.Org Foundation', version 11.0.70101000
configured using `configure  '--prefix=/home/mwd' '--without-toolkit-scroll-bars' '--with-gif=no''

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: en_US.UTF-8
  value of $XMODIFIERS: @im=none
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: Group

Minor modes in effect:
  gnus-undo-mode: t
  shell-dirtrack-mode: t
  display-time-mode: t
  diff-auto-refine-mode: t
  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
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t

Recent input:
<return> C-x h C-M-\ C-n C-n C-n C-n C-n C-n C-n C-n 
C-p <tab> C-o C-_ C-p <tab> C-n C-n C-n C-n C-b C-b 
} <tab> SPC <tab> C-p C-p C-p C-p C-p C-a C-p C-x h 
C-M-\ C-n C-n C-n C-n C-n C-n C-n <tab> C-n <tab> C-n 
<tab> C-n <tab> C-b C-b C-b C-b C-b C-b C-b C-b C-b 
C-b C-b \ <return> <tab> C-p C-x h C-M-\ C-n C-n C-n 
C-n C-n C-n C-n C-n C-p <tab> C-n <tab> C-n <tab> C-n 
<tab> C-n <tab> C-p C-p C-p C-p C-p <tab> C-p <tab> 
C-p <tab> C-p C-p C-p <tab> C-n C-a <tab> C-p C-a C-x 
h C-M-\ C-_ <switch-frame> M-x r e p o r e t - e m 
<tab> <backspace> <backspace> <backspace> <backspace> 
<backspace> <backspace> r t - e m <tab> <return> I 
n d e n t a t i o n SPC p r o b l e m s SPC i n SPC 
c c - m o d e <return> M-x c c - <tab> <tab> b <tab> 
<backspace> <backspace> <backspace> - <tab> b <tab> 
<backspace> r <tab> e <tab> <backspace> <backspace> 
s u <tab> <return> y M-p C-e <M-backspace> <M-backspace> 
C SPC m o d e <return> C-x o C-x k y e s <return> C-x 
0 M-v M-v C-n C-p C-n C-n C-n C-n C-n C-n C-n C-n C-n 
C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p 
C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p 
C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p 
C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p 
C-p C-p C-p C-_ C-x k M-x r e p o r t - e m <tab> 
<return>

Recent messages:
Checking 39 files in /home/mwd/share/emacs/23.1.92/lisp/obsolete...
Checking 1 files in /home/mwd/share/emacs/23.1.92/leim...
Checking for load-path shadows...done
Making completion list... [4 times]
Do you want to submit a report on CC Mode? (y or n) 
Formatting bug report buffer.......
Please enter your report.  Type C-c C-c to send, C-c C-k to abort.
call-interactively: Beginning of buffer
Auto-saving...done
Undo!

Load-path shadows:
/afs/cert.org/usr/mwd/src/elisp/nnir hides /home/mwd/share/emacs/23.1.92/lisp/gnus/nnir

Features:
(reporter shadow emacsbug time-stamp tabify whitespace dabbrev
vc-dispatcher vc-svn flyspell ispell cc-mode cc-fonts cc-menus cc-cmds
cc-styles cc-align cc-engine cc-vars cc-defs help-mode view copyright
gnus-dup mule-util gnus-cite ansi-color mail-extr gnus-async gnus-bcklg
parse-time timezone sort gnus-ml disp-table byte-opt bytecomp
byte-compile nnml utf-7 utf7 nndraft nnmh tls nnimap imap gnus-agent
gnus-srvr gnus-score score-mode nnvirtual gnus-msg gnus-art mm-uu
mml2015 epg-config mm-view gnus-cache nnir edmacro kmacro gnus-sum
gnus-demon nntp gnus-group gnus-undo nnmail mail-source nnoo gnus-start
gnus-spec gnus-int gnus-range gnus-win uniquify tramp-imap assoc
tramp-gw tramp-fish tramp-smb tramp-cache tramp-ftp tramp-cmds tramp
auth-source advice help-fns advice-preload shell format-spec
tramp-compat trampver time smime dig server psvn cl cl-19 log-edit
pcvs-util add-log diff-mode easy-mmode pgg pgg-parse pgg-def message
sendmail ecomplete rfc822 mml easymenu mml-sec password-cache mm-decode
mm-bodies mm-encode mailcap mail-parse rfc2231 rfc2047 rfc2045 qp
ietf-drums mailabbrev gmm-utils mailheader canlock sha1 hex-util
hashcash gnus gnus-ems nnheader gnus-util netrc time-date mail-utils
mm-util mail-prsvr wid-edit generic-x dired-x dired-aux dired ange-ftp
regexp-opt comint ring tooltip ediff-hook vc-hooks lisp-float-type
mwheel x-win x-dnd font-setting tool-bar dnd fontset image fringe
lisp-mode register page menu-bar rfn-eshadow timer select scroll-bar
mldrag 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 loaddefs button minibuffer faces cus-face files text-properties
overlay md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote make-network-process dbusbind
system-font-setting font-render-setting gtk x-toolkit x multi-tty emacs)

-- 
Michael Welsh Duggan
([email-masked])