GNU bug report logs - #20778
Flush left indentation in c-mode

Previous Next

Packages: emacs, cc-mode;

Reported by: Bruce Korb <bkorb <at> gnu.org>

Date: Tue, 9 Jun 2015 16:50:04 UTC

Severity: minor

Tags: moreinfo

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Bruce Korb <bkorb <at> gnu.org>
To: Alan Mackenzie <acm <at> muc.de>, 20778 <at> debbugs.gnu.org
Subject: bug#20778: Flush left indentation in c-mode
Date: Fri, 12 Jun 2015 07:55:37 -0700
On 06/10/15 04:00, Alan Mackenzie wrote:
>> With the patched cc-mode, I ran into this situation again.
>
> Er, any chance of a reference to "this situation"?

"see below" :)

>> 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).

> $ emacs --version
> GNU Emacs 24.3.1
> Copyright (C) 2013 Free Software Foundation, Inc.

> (ii) The CC Mode version (M-x c-version).

> $ ls -l ~/.emacs.d|fgrep cc-mode
> drwxr-xr-x 2 bkorb dev   4096 May 11 13:31 cc-mode
> -rw-r----- 1 bkorb dev 580925 May  7 17:19 cc-mode-5.32.5.tar.gz

5.32.5, but patched:

> --- cc-cmds.el  2013-05-03 10:11:16.000000000 -0700
> +++ ../cc-mode/cc-cmds.el       2015-05-11 13:31:16.758777535 -0700
> @@ -937,15 +937,8 @@
>         ;; do all cleanups and newline insertions if c-auto-newline is on.
>         (if (or (not c-auto-newline)
>                 (not (looking-at "[ \t]*\\\\?$")))
> -           (when c-syntactic-indentation
> -               (let ((syntax (c-guess-basic-syntax)))
> -                 (c-indent-line syntax)
> -                 ;; Guard against the C hacker inserting a statement before a
> -                 ;; non-compound statement in an if/while/for.
> -                 (if (eq (caar syntax) 'substatement)
> -                     (save-excursion
> -                       (if (eq 0 (forward-line))
> -                           (c-indent-line))))))
> +           (if c-syntactic-indentation
> +                (c-indent-line))
>           ;; clean ups: list-close-comma or defun-close-semi
>           (let ((pos (- (point-max) (point))))
>             (if (c-save-buffer-state ()

> (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?

Not much:

> $ cat .dir-locals.el
>
> (
>  (nil . ((indent-tabs-mode . t)
>          (tab-width . 8)
>          (show-trailing-whitespace . t)
>          (fill-column . 132)))
>
>  (c-mode . ((c-file-style . "linux")))
> )

> (iii) The EXACT steps you took between starting Emacs to seeing the error,
>    detailed enough that I can reproduce it.

If I knew the answer to that, I would have included that.  :(
I work for hours and then suddenly this happens.
The mechanism for clearing it requires closing and re-visiting the file
in question.  I do not have to restart emacs.  Changing to another
mode and changing back to C-mode is not effective (i.e. the problem
persists).

> (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?

I put the cursor on the flush-left "if" line and press <tab> to no effect.
I re-indent the region, to no effect.  I switch to "text-mode" and back
and re-indent the region, to no effect.  I close and re-visit the file
and indent-region now works correctly, as you see for yourself when
you tried re-indenting the region.  The only way I can think of
to resolve this is if there is some information I can dump out
about the buffer the next time it happens.  Obviously, I have to close
and re-visit the file fairly soon, as this is my day job....

> 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 ....  I can't
> reproduce the problem at the moment.

It is not the particular code fragment, but the editing history
that seems to trigger the problem.  I have trouble remembering
all the 100's to 1000's of keystrokes I went through to cause it. ;)




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

Previous Next


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