Subject: bug#20778: Flush left indentation in c-mode

From: Alan Mackenzie <[email-masked]>
Date: 10 Jun 2015 11:00:34 -0000

Hello, Bruce.

In article <[email-masked]> you wrote:

> With the patched cc-mode, I ran into this situation again.

Er, any chance of a reference to "this situation"?  Perhaps the bug number
of a previous bug, or the Subject: and Date: of a pertinent email, or
something like that.  :-)

> It seems to think that the flush-left alignment of the "if" statement is fine.
> The rest of the code indents as you see here.  Reloading cc-mode does no
> good, it leaves the statement flush left.  Closing and re-visiting the file
> cleans up the confusion and re-indents correctly.

> I do not know what you can do about it without better information from me,
> but I don't know what to tell you either.  :(  Oh, the "c-file-style" is "linux".

OK, standard information, please:
(i) The Emacs version number (M-x emacs-version).
(ii) The CC Mode version (M-x c-version).
(iii) Have you got any CC Mode customisations in your .emacs?  You've
  already said you're in style "linux", but is there anything else?  If
  so, what?
(iii) The EXACT steps you took between starting Emacs to seeing the error,
  detailed enough that I can reproduce it.
(iv) What exactly do you mean "It seems to think that the flush-left
  alignment ... is fine"?  What command did you give that led you to this
  conclusion, or what output from CC Mode was relevant?

Just for info, when I loaded the following fragment into Emacs, stripped
of the leading "> " from each line, set the style "linux", then indented
it (by indenting the first two lines using <tab>, then placing point at
the opening "{" and doing C-M-q), the indentation was fine.  I can't
reproduce the problem at the moment.

>> void ftl_ns_print(void)
>> {
>> #if MAX_EVENT_EVT_PRIORITY >= LOG_DEBUG
>>       int skip_ct = 0;
>>
>>       for (int i = 0; i < s_ns_table.nst_count; i++) {
>>               struct ftl_ns_t * const ns_p = &s_ns_table.nst_ns_list[i];
>>
>>               if (ns_p->active_ns_id == NS_ID_NULL) {
>>                       skip_ct++;
>>                       continue;
>>               }
>>
>>               EMIT_PRINT_NS_EVENT(
>>                       debug, "ns_id=%d, flags=%u, active_ns_id=%d, parent_ns_id=%d, next_snapshot_ns_id=%d, "
>>                       "snapshot_sn=%u, size_byte=%lu, used_bytes=%lu, physical_used_bytes=%lu, max_lpn=%lu, "
>>                       "creation_io_id=%lu, snapshot_sn_seq=%u\n",
>>                       sint32, ns_p->ns_id,
>>                       uint32, ns_p->flags,
>>                       sint32, ns_p->active_ns_id,
>>                       sint32, ns_p->parent_ns_id,
>>                       sint32, ns_p->next_snapshot_ns_id,
>>                       uint32, ns_p->snapshot_sn,
>>                       uint64, ns_p->size_bytes,
>>                       uint64, ns_p->used_bytes,
>>                       uint64, ns_p->physical_used_bytes,
>>                       uint64, ns_p->max_lpn,
>>                       uint64, ns_p->creation_io_id,
>>                       uint32, ns_p->snapshot_sn_seq
>>                       );
>>       }
>>
>> if (skip_ct > 0)
>>       EMIT_SKIPPED_NS_EVENT(debug, "skipped %d empty name spaces", sint32, skip_ct);
>> #endif
>> }

-- 
Alan Mackenzie (Nuremberg, Germany).