bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#20778: Flush left indentation in c-mode


From: Bruce Korb
Subject: bug#20778: Flush left indentation in c-mode
Date: Fri, 12 Jun 2015 07:55:37 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0

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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]