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

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

bug#738: indenting in cc whitesmith mode broken in emacs 22.2, works in


From: Jyrki Saarela
Subject: bug#738: indenting in cc whitesmith mode broken in emacs 22.2, works in 21.3
Date: Mon, 18 Aug 2008 13:20:40 +0300

Automating indenting of c++ code is broken

In GNU Emacs 22.2.1 (i386-mingw-nt5.1.2600)
 of 2008-03-26 on RELEASE
Windowing system distributor `Microsoft Corp.', version 5.1.2600
configured using `configure --with-gcc (3.4)'

likely in all versions. I tried to check from gnu.emacs.bug, but could
not find anything related. Feel free to blame google groups if this is
not a new bug.

There are 2 possibly separated things.

a) minor - if c-electric-flag is t then current line is re-indented
badly every time '(' is pressed within function body. This might be
even a feature - but very annoying one. It does work differently ( and
better ) in emacs 21.3. At least the indentation is corrected when ')'
is pressed.

b) major - at least last line of function where '}' is placed in
whitesmith style is indented incorrectly ( possibly other places too),
and indentation also depends on where you press <tab> key. If pressed
at left side of the '}' or on the '}' then indentation works
correctly. If c-electric-flag is t then the automatic indentation is
also incorrect. And yes, it does work in emacs 21.3.

To repro:

common:
1) see .emacs at bottom of this file
2) start up emacs. Visit a c++ file, eg ^X ^F foo.cpp<ret>

3a) to repro a), type "int main()<ret>{<ret>if("
result a:
int main()
    {
        if(

expected a:
int main()
    {
    if (


3b) to repro b) type "int main()<ret>{<ret>}"

result b:
int main()
    {
        }

expected b:
int main()
    {
    }

You can also start with

int main()
    {
    }<PRESS TAB HERE>

and press tab where indicated and end up with result b. But if you
start with result b

int main()
    {
        <PRESS TAB HERE>}

and press tab where indicated the indentation will be corrected.



-----------------------------------------------------------------------

(almost) Minimal .emacs required to reproduce:

;; ==========================
;; C/C++ indentation
;; ==========================
(defun my-c-mode-common-hook ()
  (c-set-style "whitesmith") )
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)

; if c-electric-flag is set, works even worse
;( setq-default c-electric-flag nil )
(setq-default indent-tabs-mode nil)

-- 
Jyrki







reply via email to

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