Alex Podolsky | 11 Jun 2013 19:49
Picon

Brace lists misidentified in macro #defines

I often want to define default initializers for my structs but
c-mode's macro heuristic misidentifies and incorrectly indents the
designated initializer list.

Here's what it produces, with the .b line not aligned to the .a:

#define BAD_INDENT {                            \
        .a = 1,                                 \
            .b = 2,                             \
            }                                   \

Here's what I expect:

#define IDEAL_INDENT {                          \
       .a = 1,                             \
       .b = 2,                             \
       }                                   \

c-show-syntactic information shows that .a is being identified as
defun-block-intro, while the same spot in the corresponding non-macro
designated initializer is identified as brace-list-intro.

There's no option but to use macros for this purpose because it's
sometimes necessary to use them to initialize static variables. GCC
allows compound literals to be used for this, as an extension, but
doesn't allow the use of alternatives like const struct variables or a
const functions.

------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:
(Continue reading)

Jun | 7 Jun 2013 15:44
Picon

a problem of font locking in c-mode

The first line can't be fontified. I'm using emacs 24.3.

----------xxx--------
HI_VOID* SampleStartSnapByMode1(HI_VOID *p);
HI_VOID SampleStartSnapByMode1(HI_VOID *p);
----------xxx--------

emacs -Q, open a blank c file, and then paste the above c code.

------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
http://p.sf.net/sfu/servicenow-d2d-j

Glenn Morris | 29 May 2013 03:56
Picon

bug#14496: cc-bytecomp-obsolete-fun doesn't work

Package: emacs,cc-mode
Version: 24.1

cc-bytecomp-obsolete-fun hasn't worked for 2+ years (Emacs 24.1
onwards), since it calls cc-bytecomp-ignore-obsolete, which uses
byte-compile-obsolete, which was removed 2011-04-01.

Since no-one has complained (and a web-search shows zero apparent users
of cc-bytecomp-obsolete-fun), please can it just be removed.

IMO most of the rest of cc-bytecomp should also be removed.
cc-bytecomp-defun is replaced by the standard `declare-function', which
works since Emacs 23.1 (and is defined in 22.2 onwards as a compat stub).

cc-bytecomp-defvar is replaced by `(defvar foo)' with no init value.

------------------------------------------------------------------------------
Introducing AppDynamics Lite, a free troubleshooting tool for Java/.NET
Get 100% visibility into your production application - at no cost.
Code-level diagnostics for performance bottlenecks with <2% overhead
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap1

Sezaru | 22 May 2013 23:08
Picon

Pasting preprocessor in header files sometimes break indentation

cc-mode sometimes loose the indentation when working with c++ header files, there is another thread with some similar problem here but the workaround shown there does not work and it was said that in emacs-24.3 it was fixed, which is the version I'm using and it still have the problem, so I decided to create a new thread as it look like a diferent issue is causing the problem.

I've tested this problem in my gentoo emacs 24.3 build and in a vanilla one download from the official website. The bug persists in both even when using the built-in cc-mode or the lastest direct from the repositories. It also persistis when using -q option, so it is not another mode conflicting with cc-mode.

I've made a little example to reproduce the problem:

#ifndef TEST_H_
#define TEST_H_



class Test
{
public:
  Test(void);

  Foo(void);
  Bar(void);
};

#endif // TEST_H_


Save this code as test.hpp, now open it, and there will be 3 empty lines between #define TEST_H and class Test, in the second empty line paste this:
#include <iostream>

Now the indentation will fail and every line you try to indentate will not.

Beware that you need to paste the #include <iostream> in the code and not simply write it, if you write character by character the indentation will still works as it should, it only breaks when you paste it (or at least it was the only way I've found to reproduce it)

Thanks!
------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
E.L.K. | 21 May 2013 09:55
Picon

java-mode highlighting issues

Hello!

In 5.32.5 cc-mode in java-mode class constructor highlighted incorrectly:

class Some {
    public Some() {
   
    }
}

in this case constructor not highlighted as method.

And if <at> Override annotation added to the method, it is not higlighted as method too:

class SomeOther {
    <at> Override public void method() {

    }
}

method in this case will not be highlighted as method.

Emacs version: GNU Emacs 24.3.1 (i686-pc-linux-gnu, GTK+ Version 2.22.0) of 2013-05-17
CC Mode version: 5.32.5

Thank you for you work!

Br,
Alexey
------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
Andreas Spindler | 22 May 2013 10:14
Picon
Favicon

Emacs 24: cc-mode unmaintained?

Good morning,

on SO the question "C++11 mode or setting for Emacs?" was raised, and I 
answered it with some code I used for years.

As the last author of cc-mode is from 2003 (Alan McKenzie) I wonder if 
anybody is maintaining the mode.
I would offer my help.

Yours,
A. Spindler

-- 

*Andreas Spindler*

	/   Web:/ 	www.visualco.de <http://www.visualco.de>
IT-Consultant
Senior Software-Entwickler/Engineer
Systemprogrammierung UNIX/Windows/Linux 	/   Email:/ 	info <at> visualco.de 
<mailto:info <at> visualco.de>
/   Tel.:/ 	 +49 6084 959990
/   Mobil:/ 	 +49 171 9579893

Attachment (info.vcf): text/x-vcard, 722 bytes
------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
Sezaru | 12 May 2013 08:49
Picon

Indentation problem when using preprocessor if/else/endif in function declaration

cc-mode indents wrongly when I use #if #else #endif to define different function definitions, to reproduce it just write the snippet code bellow:

#if DEF
void test(void)
#else
  void test2(void)
#endif
{ }

As can be seen, the line void test2(void) will be indented wrongly 2 spaces.

I've tested it with emacs 24.3 from gentoo and the vanilla one, same thing with cc-mode, the built-in one (5.32.4) and with the one from c++11 branch (5.33). All have this same behavior.

thanks!
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and 
their applications. This 200-page book is written by three acclaimed 
leaders in the field. The early access version is available now. 
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
Stefan Monnier | 10 May 2013 17:41
Picon

Cleanup patch for cc-mode

Any objection against the patch below?

Any while I'm here: I'd like to make cc-mode use syntax-propertize, but
can't understand how cc-mode currently uses the syntax-table property:
you use different values for different cases (makes sense so far) but
most importantly you set them from different places and different times
(from what I understand) and you seem to never just clear the
syntax-table property, but instead only remove it selectively, only at
those places that have a particular value.

Is it "documented" in some comment somewhere, or else could you add one,
that lists all the cases where it's used, where it's set, when it's
removed? And ideally, with some rationale/explanation why it's done this
way, why each such case is done differently, ...

        Stefan

=== modified file 'lisp/progmodes/cc-mode.el'
--- lisp/progmodes/cc-mode.el	2013-05-02 11:18:18 +0000
+++ lisp/progmodes/cc-mode.el	2013-05-10 15:33:00 +0000
 <at>  <at>  -218,12 +218,16  <at>  <at> 
      (t (error "CC Mode is incompatible with this version of Emacs")))
     map))

-(defun c-define-abbrev-table (name defs)
+(defun c-define-abbrev-table (name defs &optional doc)
   ;; Compatibility wrapper for `define-abbrev' which passes a non-nil
   ;; sixth argument for SYSTEM-FLAG in emacsen that support it
   ;; (currently only Emacs >= 21.2).
   (let ((table (or (symbol-value name)
-		   (progn (define-abbrev-table name nil)
+		   (progn (condition-case nil
+                              (define-abbrev-table name nil doc)
+                            (wrong-number-of-arguments ;Emacs<23.
+                             (eval `(defvar ,name nil))
+                             (define-abbrev-table name nil)))
 			  (symbol-value name)))))
     (while defs
       (condition-case nil
 <at>  <at>  -1235,27 +1239,22  <at>  <at> 
 
 ;; Support for C

-;;;###autoload
-(defvar c-mode-syntax-table nil
+(defvar c-mode-syntax-table
+  (funcall (c-lang-const c-make-mode-syntax-table c))
   "Syntax table used in c-mode buffers.")
-(or c-mode-syntax-table
-    (setq c-mode-syntax-table
-	  (funcall (c-lang-const c-make-mode-syntax-table c))))

-(defvar c-mode-abbrev-table nil
-  "Abbreviation table used in c-mode buffers.")
 (c-define-abbrev-table 'c-mode-abbrev-table
   '(("else" "else" c-electric-continued-statement 0)
-    ("while" "while" c-electric-continued-statement 0)))
+    ("while" "while" c-electric-continued-statement 0))
+  "Abbreviation table used in c-mode buffers.")

-(defvar c-mode-map ()
+(defvar c-mode-map
+  (let ((map (c-make-inherited-keymap)))
+    ;; Add bindings which are only useful for C.
+    (define-key map "\C-c\C-e"  'c-macro-expand)
+    map)
   "Keymap used in c-mode buffers.")
-(if c-mode-map
-    nil
-  (setq c-mode-map (c-make-inherited-keymap))
-  ;; add bindings which are only useful for C
-  (define-key c-mode-map "\C-c\C-e"  'c-macro-expand)
-  )
+

 (easy-menu-define c-c-menu c-mode-map "C Mode Commands"
 		  (cons "C" (c-lang-const c-mode-menu c)))
 <at>  <at>  -1320,30 +1319,25  <at>  <at> 
 
 ;; Support for C++

-;;;###autoload
-(defvar c++-mode-syntax-table nil
+(defvar c++-mode-syntax-table
+  (funcall (c-lang-const c-make-mode-syntax-table c++))
   "Syntax table used in c++-mode buffers.")
-(or c++-mode-syntax-table
-    (setq c++-mode-syntax-table
-	  (funcall (c-lang-const c-make-mode-syntax-table c++))))

-(defvar c++-mode-abbrev-table nil
-  "Abbreviation table used in c++-mode buffers.")
 (c-define-abbrev-table 'c++-mode-abbrev-table
   '(("else" "else" c-electric-continued-statement 0)
     ("while" "while" c-electric-continued-statement 0)
-    ("catch" "catch" c-electric-continued-statement 0)))
+    ("catch" "catch" c-electric-continued-statement 0))
+  "Abbreviation table used in c++-mode buffers.")

-(defvar c++-mode-map ()
+(defvar c++-mode-map
+  (let ((map (c-make-inherited-keymap)))
+    ;; Add bindings which are only useful for C++.
+    (define-key map "\C-c\C-e" 'c-macro-expand)
+    (define-key map "\C-c:"    'c-scope-operator)
+    (define-key map "<"        'c-electric-lt-gt)
+    (define-key map ">"        'c-electric-lt-gt)
+    map)
   "Keymap used in c++-mode buffers.")
-(if c++-mode-map
-    nil
-  (setq c++-mode-map (c-make-inherited-keymap))
-  ;; add bindings which are only useful for C++
-  (define-key c++-mode-map "\C-c\C-e" 'c-macro-expand)
-  (define-key c++-mode-map "\C-c:"    'c-scope-operator)
-  (define-key c++-mode-map "<"        'c-electric-lt-gt)
-  (define-key c++-mode-map ">"        'c-electric-lt-gt))

 (easy-menu-define c-c++-menu c++-mode-map "C++ Mode Commands"
 		  (cons "C++" (c-lang-const c-mode-menu c++)))
 <at>  <at>  -1380,26 +1374,21  <at>  <at> 
 
 ;; Support for Objective-C

-;;;###autoload
-(defvar objc-mode-syntax-table nil
+(defvar objc-mode-syntax-table
+  (funcall (c-lang-const c-make-mode-syntax-table objc))
   "Syntax table used in objc-mode buffers.")
-(or objc-mode-syntax-table
-    (setq objc-mode-syntax-table
-	  (funcall (c-lang-const c-make-mode-syntax-table objc))))

-(defvar objc-mode-abbrev-table nil
-  "Abbreviation table used in objc-mode buffers.")
 (c-define-abbrev-table 'objc-mode-abbrev-table
   '(("else" "else" c-electric-continued-statement 0)
-    ("while" "while" c-electric-continued-statement 0)))
+    ("while" "while" c-electric-continued-statement 0))
+  "Abbreviation table used in objc-mode buffers.")

-(defvar objc-mode-map ()
+(defvar objc-mode-map
+  (let ((map (c-make-inherited-keymap)))
+    ;; Add bindings which are only useful for Objective-C.
+    (define-key map "\C-c\C-e" 'c-macro-expand)
+    map)
   "Keymap used in objc-mode buffers.")
-(if objc-mode-map
-    nil
-  (setq objc-mode-map (c-make-inherited-keymap))
-  ;; add bindings which are only useful for Objective-C
-  (define-key objc-mode-map "\C-c\C-e" 'c-macro-expand))

 (easy-menu-define c-objc-menu objc-mode-map "ObjC Mode Commands"
 		  (cons "ObjC" (c-lang-const c-mode-menu objc)))
 <at>  <at>  -1438,28 +1427,22  <at>  <at> 
 
 ;; Support for Java

-;;;###autoload
-(defvar java-mode-syntax-table nil
+(defvar java-mode-syntax-table
+  (funcall (c-lang-const c-make-mode-syntax-table java))
   "Syntax table used in java-mode buffers.")
-(or java-mode-syntax-table
-    (setq java-mode-syntax-table
-	  (funcall (c-lang-const c-make-mode-syntax-table java))))

-(defvar java-mode-abbrev-table nil
-  "Abbreviation table used in java-mode buffers.")
 (c-define-abbrev-table 'java-mode-abbrev-table
   '(("else" "else" c-electric-continued-statement 0)
     ("while" "while" c-electric-continued-statement 0)
     ("catch" "catch" c-electric-continued-statement 0)
-    ("finally" "finally" c-electric-continued-statement 0)))
+    ("finally" "finally" c-electric-continued-statement 0))
+  "Abbreviation table used in java-mode buffers.")

-(defvar java-mode-map ()
+(defvar java-mode-map
+  (let ((map (c-make-inherited-keymap)))
+    ;; Add bindings which are only useful for Java.
+    map)
   "Keymap used in java-mode buffers.")
-(if java-mode-map
-    nil
-  (setq java-mode-map (c-make-inherited-keymap))
-  ;; add bindings which are only useful for Java
-  )

 ;; Regexp trying to describe the beginning of a Java top-level
 ;; definition.  This is not used by CC Mode, nor is it maintained
 <at>  <at>  -1504,24 +1487,18  <at>  <at> 
 
 ;; Support for CORBA's IDL language

-;;;###autoload
-(defvar idl-mode-syntax-table nil
+(defvar idl-mode-syntax-table
+  (funcall (c-lang-const c-make-mode-syntax-table idl))
   "Syntax table used in idl-mode buffers.")
-(or idl-mode-syntax-table
-    (setq idl-mode-syntax-table
-	  (funcall (c-lang-const c-make-mode-syntax-table idl))))

-(defvar idl-mode-abbrev-table nil
+(c-define-abbrev-table 'idl-mode-abbrev-table nil
   "Abbreviation table used in idl-mode buffers.")
-(c-define-abbrev-table 'idl-mode-abbrev-table nil)

-(defvar idl-mode-map ()
+(defvar idl-mode-map
+  (let ((map (c-make-inherited-keymap)))
+    ;; Add bindings which are only useful for IDL.
+    map)
   "Keymap used in idl-mode buffers.")
-(if idl-mode-map
-    nil
-  (setq idl-mode-map (c-make-inherited-keymap))
-  ;; add bindings which are only useful for IDL
-  )

 (easy-menu-define c-idl-menu idl-mode-map "IDL Mode Commands"
 		  (cons "IDL" (c-lang-const c-mode-menu idl)))
 <at>  <at>  -1558,26 +1535,21  <at>  <at> 
 
 ;; Support for Pike

-;;;###autoload
-(defvar pike-mode-syntax-table nil
+(defvar pike-mode-syntax-table
+  (funcall (c-lang-const c-make-mode-syntax-table pike))
   "Syntax table used in pike-mode buffers.")
-(or pike-mode-syntax-table
-    (setq pike-mode-syntax-table
-	  (funcall (c-lang-const c-make-mode-syntax-table pike))))

-(defvar pike-mode-abbrev-table nil
-  "Abbreviation table used in pike-mode buffers.")
 (c-define-abbrev-table 'pike-mode-abbrev-table
   '(("else" "else" c-electric-continued-statement 0)
-    ("while" "while" c-electric-continued-statement 0)))
+    ("while" "while" c-electric-continued-statement 0))
+  "Abbreviation table used in pike-mode buffers.")

-(defvar pike-mode-map ()
+(defvar pike-mode-map
+  (let ((map (c-make-inherited-keymap)))
+    ;; Additional bindings.
+    (define-key map "\C-c\C-e" 'c-macro-expand)
+    map)
   "Keymap used in pike-mode buffers.")
-(if pike-mode-map
-    nil
-  (setq pike-mode-map (c-make-inherited-keymap))
-  ;; additional bindings
-  (define-key pike-mode-map "\C-c\C-e" 'c-macro-expand))

 (easy-menu-define c-pike-menu pike-mode-map "Pike Mode Commands"
 		  (cons "Pike" (c-lang-const c-mode-menu pike)))
 <at>  <at>  -1626,28 +1598,26  <at>  <at> 
 ;;; autoload form instead.
 ;;;###autoload (autoload 'awk-mode "cc-mode" "Major mode for editing AWK code." t)

-(defvar awk-mode-abbrev-table nil
-  "Abbreviation table used in awk-mode buffers.")
 (c-define-abbrev-table 'awk-mode-abbrev-table
   '(("else" "else" c-electric-continued-statement 0)
-    ("while" "while" c-electric-continued-statement 0)))
+    ("while" "while" c-electric-continued-statement 0))
+  "Abbreviation table used in awk-mode buffers.")

-(defvar awk-mode-map ()
+(defvar awk-mode-map
+  (let ((map (c-make-inherited-keymap)))
+    ;; Add bindings which are only useful for awk.
+    (define-key map "#" 'self-insert-command)
+    (define-key map "/" 'self-insert-command)
+    (define-key map "*" 'self-insert-command)
+    (define-key map "\C-c\C-n" 'undefined) ; #if doesn't exist in awk.
+    (define-key map "\C-c\C-p" 'undefined)
+    (define-key map "\C-c\C-u" 'undefined)
+    (define-key map "\M-a" 'c-beginning-of-statement) ; 2003/10/7
+    (define-key map "\M-e" 'c-end-of-statement)       ; 2003/10/7
+    (define-key map "\C-\M-a" 'c-awk-beginning-of-defun)
+    (define-key map "\C-\M-e" 'c-awk-end-of-defun)
+    map)
   "Keymap used in awk-mode buffers.")
-(if awk-mode-map
-    nil
-  (setq awk-mode-map (c-make-inherited-keymap))
-  ;; add bindings which are only useful for awk.
-  (define-key awk-mode-map "#" 'self-insert-command)
-  (define-key awk-mode-map "/" 'self-insert-command)
-  (define-key awk-mode-map "*" 'self-insert-command)
-  (define-key awk-mode-map "\C-c\C-n" 'undefined) ; #if doesn't exist in awk.
-  (define-key awk-mode-map "\C-c\C-p" 'undefined)
-  (define-key awk-mode-map "\C-c\C-u" 'undefined)
-  (define-key awk-mode-map "\M-a" 'c-beginning-of-statement) ; 2003/10/7
-  (define-key awk-mode-map "\M-e" 'c-end-of-statement) ; 2003/10/7
-  (define-key awk-mode-map "\C-\M-a" 'c-awk-beginning-of-defun)
-  (define-key awk-mode-map "\C-\M-e" 'c-awk-end-of-defun))

 (easy-menu-define c-awk-menu awk-mode-map "AWK Mode Commands"
 		  (cons "AWK" (c-lang-const c-mode-menu awk)))

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and 
their applications. This 200-page book is written by three acclaimed 
leaders in the field. The early access version is available now. 
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may

Achim Gratz | 5 May 2013 16:17
Picon

bug#14325: 24.3; cc-mode does not initialize correctly w/ -batch

Alan Mackenzie writes:
> I've installed Glenn's patch into the Emacs trunk.  Could you please
> try it out, and see if it solves your problem.

I've built a new Emacs from trunk today and the fix works as intended.
Thanks to you and Glenn.

Regards,
Achim.
--

-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

SD adaptation for Waldorf microQ V2.22R2:
http://Synth.Stromeko.net/Downloads.html#WaldorfSDada

------------------------------------------------------------------------------
Introducing AppDynamics Lite, a free troubleshooting tool for Java/.NET
Get 100% visibility into your production application - at no cost.
Code-level diagnostics for performance bottlenecks with <2% overhead
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap1

Alan Mackenzie | 5 May 2013 14:31
Picon
Favicon

Release of CC Mode 5.32.5

Hi, CC Mode users.

CC Mode 5.32.5 has been released and is available from
<http://cc-mode.sourceforge.net/release.php>.  This is a bug-fix release;
for full details, please see the ChangeLog file.

(CC Mode 5.32.4 was the version number used in Emacs 24.3.)

--

-- 
Alan Mackenzie (Nuremberg, Germany).

------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite
It's a free troubleshooting tool designed for production
Get down to code-level detail for bottlenecks, with <2% overhead.
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap2

Achim Gratz | 2 May 2013 20:44
Picon

bug#14325: 24.3; cc-mode does not initialize correctly w/ -batch

Alan Mackenzie writes:
>> If you can tell me how to obtain a trace in batch mode?
>
> :-).  I thought you knew the software.  Never mind.

I do, but I don't know what are the differences in noninteractive mode.
Stepping through the code in interactive mode is possible, but I
wouldn't be able to tell if it goes through the same motions.

> I've installed Glenn's patch into the Emacs trunk.  Could you please try
> it out, and see if it solves your problem.

I'll give it a whirl over the weekend (I hope).

Regards,
Achim.
--

-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

Waldorf MIDI Implementation & additional documentation:
http://Synth.Stromeko.net/Downloads.html#WaldorfDocs

------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite
It's a free troubleshooting tool designed for production
Get down to code-level detail for bottlenecks, with <2% overhead.
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap2


Gmane