unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Calling C++ hackers.  Please try out the new handling of C++11 lambda functions in CC Mode.
@ 2016-08-15 12:24 Alan Mackenzie
  2016-08-15 16:17 ` Eli Zaretskii
  2016-08-19 21:45 ` Matthias Meulien
  0 siblings, 2 replies; 13+ messages in thread
From: Alan Mackenzie @ 2016-08-15 12:24 UTC (permalink / raw)
  To: emacs-devel

Hello Emacs.

I've just committed a first version of C++11 lambda function handling
into the master branch.  It is intended to handle both indentation and
font locking.

I'd be grateful for any feedback on this new facility.

-- 
Alan Mackenzie (Nuremberg, Germany).



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Calling C++ hackers.  Please try out the new handling of C++11 lambda functions in CC Mode.
  2016-08-15 12:24 Calling C++ hackers. Please try out the new handling of C++11 lambda functions in CC Mode Alan Mackenzie
@ 2016-08-15 16:17 ` Eli Zaretskii
  2016-08-19 21:45 ` Matthias Meulien
  1 sibling, 0 replies; 13+ messages in thread
From: Eli Zaretskii @ 2016-08-15 16:17 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: emacs-devel

> Date: Mon, 15 Aug 2016 12:24:13 +0000
> From: Alan Mackenzie <acm@muc.de>
> 
> Hello Emacs.
> 
> I've just committed a first version of C++11 lambda function handling
> into the master branch.  It is intended to handle both indentation and
> font locking.

Thanks!



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Calling C++ hackers.  Please try out the new handling of C++11 lambda functions in CC Mode.
  2016-08-15 12:24 Calling C++ hackers. Please try out the new handling of C++11 lambda functions in CC Mode Alan Mackenzie
  2016-08-15 16:17 ` Eli Zaretskii
@ 2016-08-19 21:45 ` Matthias Meulien
  2016-08-20 15:19   ` Alan Mackenzie
  1 sibling, 1 reply; 13+ messages in thread
From: Matthias Meulien @ 2016-08-19 21:45 UTC (permalink / raw)
  To: Alan Mackenzie, emacs-devel

> I've just committed a first version of C++11 lambda function handling
> into the master branch.  It is intended to handle both indentation
> and font locking.

Works here (commit 4a80c8b): Capture list fonts, arguments fonts and
indentation. Well done!  

-- 
Matthias



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Calling C++ hackers.  Please try out the new handling of C++11 lambda functions in CC Mode.
  2016-08-19 21:45 ` Matthias Meulien
@ 2016-08-20 15:19   ` Alan Mackenzie
  2016-08-20 22:06     ` Matthias Meulien
  0 siblings, 1 reply; 13+ messages in thread
From: Alan Mackenzie @ 2016-08-20 15:19 UTC (permalink / raw)
  To: Matthias Meulien; +Cc: emacs-devel

Hello, Matthias.

On Fri, Aug 19, 2016 at 11:45:00PM +0200, Matthias Meulien wrote:
> > I've just committed a first version of C++11 lambda function handling
> > into the master branch.  It is intended to handle both indentation
> > and font locking.

> Works here (commit 4a80c8b): Capture list fonts, arguments fonts and
> indentation. Well done!  

Thanks!

I'm hoping to get C++11 uniform initialisation working sometime in the
next few days.

> -- 
> Matthias

-- 
Alan Mackenzie (Nuremberg, Germany).



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Calling C++ hackers.  Please try out the new handling of C++11 lambda functions in CC Mode.
  2016-08-20 15:19   ` Alan Mackenzie
@ 2016-08-20 22:06     ` Matthias Meulien
  2016-08-21 12:24       ` Alan Mackenzie
  2016-08-21 16:22       ` Alan Mackenzie
  0 siblings, 2 replies; 13+ messages in thread
From: Matthias Meulien @ 2016-08-20 22:06 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: emacs-devel

> I'm hoping to get C++11 uniform initialisation working sometime in
> the next few days.

Interesting. As I am using this style of initialization now., so I'll
test your work on my code base.

To test your implementation of C++ lambda functions handling, I've had
to build Emacs from a fresh checkout and just realized that it now
handles C++11 keywords like `nullptr' or `override'; Many thanks to
those who are bringing Emacs to modern C++!

By the way, did you experience the same strange behavior of font
locking when the `override' keyword is added to a constructor? I mean
in:

struct foo : public bar {
  foo() {}

  ~foo() override {}

  void do_something() {}
};

the function name `~foo' is not fontified. It is if the `override'
keyword is removed...

Shall I fill a bug report? 
-- 
Matthias



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Calling C++ hackers.  Please try out the new handling of C++11 lambda functions in CC Mode.
  2016-08-20 22:06     ` Matthias Meulien
@ 2016-08-21 12:24       ` Alan Mackenzie
  2016-08-27 15:35         ` Matthias Meulien
  2016-08-21 16:22       ` Alan Mackenzie
  1 sibling, 1 reply; 13+ messages in thread
From: Alan Mackenzie @ 2016-08-21 12:24 UTC (permalink / raw)
  To: Matthias Meulien; +Cc: emacs-devel

Hello, Matthias.

On Sun, Aug 21, 2016 at 12:06:30AM +0200, Matthias Meulien wrote:
> > I'm hoping to get C++11 uniform initialisation working sometime in
> > the next few days.

> Interesting. As I am using this style of initialization now., so I'll
> test your work on my code base.

Many thanks in advance!

> To test your implementation of C++ lambda functions handling, I've had
> to build Emacs from a fresh checkout and just realized that it now
> handles C++11 keywords like `nullptr' or `override'; Many thanks to
> those who are bringing Emacs to modern C++!

> By the way, did you experience the same strange behavior of font
> locking when the `override' keyword is added to a constructor? I mean
> in:

> struct foo : public bar {
>   foo() {}

>   ~foo() override {}

>   void do_something() {}
> };

> the function name `~foo' is not fontified. It is if the `override'
> keyword is removed...

Yes.  That's something I've not seen before.

> Shall I fill a bug report?

If you would, yes please.

Would you also please try out on your real code the following patch
which is intended to fix the problem.  Please either confirm that the
bug is fixed, or let me know what's still not working properly.  Thanks!

After applying the patch (in directory .../lisp/progmodes, you will need
to recompile all of cc-*.el, since changes have been made in low level
macros.  Please send me a private mail if you want any help with the
patching or recompilation.



diff -r f6121546a9bc cc-engine.el
--- a/cc-engine.el	Sat Aug 20 20:40:26 2016 +0000
+++ b/cc-engine.el	Sun Aug 21 12:04:18 2016 +0000
@@ -7266,6 +7266,12 @@
 	  (goto-char (match-end 1))
 	  (c-forward-syntactic-ws)))
 
+      ;; Skip any "WS" identifiers (e.g. "final" or "override" in C++)
+      (while (looking-at c-type-decl-suffix-ws-ids-key)
+	(goto-char (match-end 1))
+	(c-forward-syntactic-ws)
+	(setq res t))
+
       (when c-opt-type-concat-key	; Only/mainly for pike.
 	;; Look for a trailing operator that concatenates the type
 	;; with a following one, and if so step past that one through
@@ -8140,6 +8146,11 @@
 	  (setq type-start (point))
 	  (setq at-type (c-forward-type))))
 
+      ;; Move forward over any "WS" ids (like "final" or "override" in C++)
+      (while (looking-at c-type-decl-suffix-ws-ids-key)
+	(goto-char (match-end 1))
+	(c-forward-syntactic-ws))
+
       (setq
        at-decl-or-cast
        (catch 'at-decl-or-cast
diff -r f6121546a9bc cc-langs.el
--- a/cc-langs.el	Sat Aug 20 20:40:26 2016 +0000
+++ b/cc-langs.el	Sun Aug 21 12:04:18 2016 +0000
@@ -1817,7 +1817,7 @@
 not the type face."
   t    nil
   c    '("const" "restrict" "volatile")
-  c++  '("const" "noexcept" "volatile" "throw" "final" "override")
+  c++  '("const" "noexcept" "volatile" "throw")
   objc '("const" "volatile"))
 
 (c-lang-defconst c-opt-type-modifier-key
@@ -1846,6 +1846,18 @@
 				  (c-lang-const c-type-modifier-kwds))
 			  :test 'string-equal))
 
+(c-lang-defconst c-type-decl-suffix-ws-ids-kwds
+  "\"Identifiers\" that when immediately following a declarator have semantic
+effect in the declaration, but are syntactically like whitespace."
+  t    nil
+  c++  '("final" "override"))
+
+(c-lang-defconst c-type-decl-suffix-ws-ids-key
+  ;; An adorned regexp matching `c-type-decl-suffix-ws-ids-kwds'.
+  t (c-make-keywords-re t (c-lang-const c-type-decl-suffix-ws-ids-kwds)))
+(c-lang-defvar c-type-decl-suffix-ws-ids-key
+  (c-lang-const c-type-decl-suffix-ws-ids-key))
+
 (c-lang-defconst c-class-decl-kwds
   "Keywords introducing declarations where the following block (if any)
 contains another declaration level that should be considered a class.




> -- 
> Matthias

-- 
Alan Mackenzie (Nuremberg, Germany).



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Calling C++ hackers.  Please try out the new handling of C++11 lambda functions in CC Mode.
  2016-08-20 22:06     ` Matthias Meulien
  2016-08-21 12:24       ` Alan Mackenzie
@ 2016-08-21 16:22       ` Alan Mackenzie
  2016-08-24 19:27         ` Richard Copley
  2016-08-27 15:37         ` Matthias Meulien
  1 sibling, 2 replies; 13+ messages in thread
From: Alan Mackenzie @ 2016-08-21 16:22 UTC (permalink / raw)
  To: Matthias Meulien; +Cc: emacs-devel

Hello again, Matthias.

On Sun, Aug 21, 2016 at 12:06:30AM +0200, Matthias Meulien wrote:
> > I'm hoping to get C++11 uniform initialisation working sometime in
> > the next few days.

> Interesting. As I am using this style of initialization now., so I'll
> test your work on my code base.

I've just committed a first attempt at C++11 uniform initialization to
the savannah master branch.

Please update your Emacs, and try it out.  Let the bug reports flow!

> To test your implementation of C++ lambda functions handling, I've had
> to build Emacs from a fresh checkout and just realized that it now
> handles C++11 keywords like `nullptr' or `override'; Many thanks to
> those who are bringing Emacs to modern C++!

Thanks!

> -- 
> Matthias

-- 
Alan Mackenzie (Nuremberg, Germany).



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Calling C++ hackers. Please try out the new handling of C++11 lambda functions in CC Mode.
  2016-08-21 16:22       ` Alan Mackenzie
@ 2016-08-24 19:27         ` Richard Copley
  2016-08-24 19:43           ` Alan Mackenzie
  2016-08-27 15:37         ` Matthias Meulien
  1 sibling, 1 reply; 13+ messages in thread
From: Richard Copley @ 2016-08-24 19:27 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: Matthias Meulien, Emacs Development

Hi Alan,

Thanks for this!

I encountered a problem while trying to come up with an
example so I could suggest a different default indentation
style for lambda bodies:

int main ()
{
  std::cout << ([] (int x) -> int {
    return 2 * x;
  } (10)) << std::endl;
}

Never mind the default indentation style, life's too short!
But here is the problem I mentioned. I just pulled from master
and recompiled and the bug is still present (as of your
commit 799a8a3338389013e8a76a70f507664ccb09a14f).

From emacs -Q:

C-x b x RET ; switch to a new buffer
M-x c++-mode RET
{ } C-p ; insert a pair of braces and put point between them
[ ; insert a left square bracket

Emacs freezes. It can be woken up by holding down C-g
for a few seconds, at which point the *Messages*
buffer has this:

Error during redisplay: (jit-lock-function 55) signaled (quit)
Error during redisplay: (jit-lock-function 57) signaled (quit)
Error during redisplay: (jit-lock-function 60) signaled (quit)
Quit [7 times]



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Calling C++ hackers. Please try out the new handling of C++11 lambda functions in CC Mode.
  2016-08-24 19:27         ` Richard Copley
@ 2016-08-24 19:43           ` Alan Mackenzie
  2016-08-24 21:10             ` Richard Copley
  0 siblings, 1 reply; 13+ messages in thread
From: Alan Mackenzie @ 2016-08-24 19:43 UTC (permalink / raw)
  To: Richard Copley; +Cc: Matthias Meulien, Emacs Development

Hello, Richard.

On Wed, Aug 24, 2016 at 08:27:58PM +0100, Richard Copley wrote:
> Hi Alan,

> Thanks for this!

> I encountered a problem while trying to come up with an
> example so I could suggest a different default indentation
> style for lambda bodies:

> int main ()
> {
>   std::cout << ([] (int x) -> int {
>     return 2 * x;
>   } (10)) << std::endl;
> }

> Never mind the default indentation style, life's too short!
> But here is the problem I mentioned. I just pulled from master
> and recompiled and the bug is still present (as of your
> commit 799a8a3338389013e8a76a70f507664ccb09a14f).

> >>From emacs -Q:

> C-x b x RET ; switch to a new buffer
> M-x c++-mode RET
> { } C-p ; insert a pair of braces and put point between them
> [ ; insert a left square bracket

> Emacs freezes. It can be woken up by holding down C-g
> for a few seconds, at which point the *Messages*
> buffer has this:

> Error during redisplay: (jit-lock-function 55) signaled (quit)
> Error during redisplay: (jit-lock-function 57) signaled (quit)
> Error during redisplay: (jit-lock-function 60) signaled (quit)
> Quit [7 times]

Thanks for taking the trouble to report this.  What appears to be the
same problem was reported by Yakov Markovitch on the CC Mode list
yesterday evening.  I've investigated this and prepared a putative fix.

That fix is in the patch below.  Could you please apply the patch,
recompile CC Mode and try it out in normal C++ code, then let me know (a
second opinion besides Yakov's) whether it fixes the problem completely.

Thanks!  At the moment, I'm trying to get everything tidied up to
release CC Mode 5.33, and I'm hoping that this is the _last_ "last
minute" bug.



diff -r f3c92d9e3424 cc-fonts.el
--- a/cc-fonts.el	Sun Aug 21 15:17:45 2016 +0000
+++ b/cc-fonts.el	Tue Aug 23 20:36:35 2016 +0000
@@ -1654,7 +1654,7 @@
 	    (c-backward-token-2)))
 
 	;; Go round the following loop once per captured item.
-	(while (and (not (eq (char-after) ?\]))
+	(while (and (not (looking-at "\\s)"))
 		    (< (point) limit))
 	  (if (eq (char-after) ?&)
 	      (progn (setq mode ?&)
@@ -1703,7 +1703,7 @@
 	    (c-forward-syntactic-ws)))
 
 	(setq capture-default nil)
-	(forward-char))))			; over the terminating "]".
+	(forward-char))))	       ; over the terminating "]" or whatever.
   nil)
 
 

-- 
Alan Mackenzie (Nuremberg, Germany).



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Calling C++ hackers. Please try out the new handling of C++11 lambda functions in CC Mode.
  2016-08-24 19:43           ` Alan Mackenzie
@ 2016-08-24 21:10             ` Richard Copley
  0 siblings, 0 replies; 13+ messages in thread
From: Richard Copley @ 2016-08-24 21:10 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: Matthias Meulien, Emacs Development

On 24 August 2016 at 20:43, Alan Mackenzie <acm@muc.de> wrote:
> Hello, Richard.
>
> On Wed, Aug 24, 2016 at 08:27:58PM +0100, Richard Copley wrote:
>> Hi Alan,
>
>> Thanks for this!
>
>> I encountered a problem while trying to come up with an
>> example so I could suggest a different default indentation
>> style for lambda bodies:
>
>> int main ()
>> {
>>   std::cout << ([] (int x) -> int {
>>     return 2 * x;
>>   } (10)) << std::endl;
>> }
>
>> Never mind the default indentation style, life's too short!
>> But here is the problem I mentioned. I just pulled from master
>> and recompiled and the bug is still present (as of your
>> commit 799a8a3338389013e8a76a70f507664ccb09a14f).
>
>> >>From emacs -Q:
>
>> C-x b x RET ; switch to a new buffer
>> M-x c++-mode RET
>> { } C-p ; insert a pair of braces and put point between them
>> [ ; insert a left square bracket
>
>> Emacs freezes. It can be woken up by holding down C-g
>> for a few seconds, at which point the *Messages*
>> buffer has this:
>
>> Error during redisplay: (jit-lock-function 55) signaled (quit)
>> Error during redisplay: (jit-lock-function 57) signaled (quit)
>> Error during redisplay: (jit-lock-function 60) signaled (quit)
>> Quit [7 times]
>
> Thanks for taking the trouble to report this.  What appears to be the
> same problem was reported by Yakov Markovitch on the CC Mode list
> yesterday evening.  I've investigated this and prepared a putative fix.
>
> That fix is in the patch below.  Could you please apply the patch,
> recompile CC Mode and try it out in normal C++ code, then let me know (a
> second opinion besides Yakov's) whether it fixes the problem completely.
>
> Thanks!  At the moment, I'm trying to get everything tidied up to
> release CC Mode 5.33, and I'm hoping that this is the _last_ "last
> minute" bug.
>
>
>
> diff -r f3c92d9e3424 cc-fonts.el
> --- a/cc-fonts.el       Sun Aug 21 15:17:45 2016 +0000
> +++ b/cc-fonts.el       Tue Aug 23 20:36:35 2016 +0000
> @@ -1654,7 +1654,7 @@
>             (c-backward-token-2)))
>
>         ;; Go round the following loop once per captured item.
> -       (while (and (not (eq (char-after) ?\]))
> +       (while (and (not (looking-at "\\s)"))
>                     (< (point) limit))
>           (if (eq (char-after) ?&)
>               (progn (setq mode ?&)
> @@ -1703,7 +1703,7 @@
>             (c-forward-syntactic-ws)))
>
>         (setq capture-default nil)
> -       (forward-char))))                       ; over the terminating "]".
> +       (forward-char))))              ; over the terminating "]" or whatever.
>    nil)
>
>
>
> --
> Alan Mackenzie (Nuremberg, Germany).

Great, thank you. I didn't have time to test much, but I haven't
noticed any problems with the patch installed. Couldn't reproduce
the problem I was talking about.



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Calling C++ hackers.  Please try out the new handling of C++11 lambda functions in CC Mode.
  2016-08-21 12:24       ` Alan Mackenzie
@ 2016-08-27 15:35         ` Matthias Meulien
  2016-08-27 20:27           ` Alan Mackenzie
  0 siblings, 1 reply; 13+ messages in thread
From: Matthias Meulien @ 2016-08-27 15:35 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: emacs-devel

Hi Alan,

> > Shall I fill a bug report?

http://debbugs.gnu.org/cgi/bugreport.cgi?bug=24319

> If you would, yes please.
> 
> Would you also please try out on your real code the following patch
> which is intended to fix the problem.  Please either confirm that the
> bug is fixed, or let me know what's still not working
> properly.  Thanks!

The bug is fixed with your patch applied to a fresh source tree
(1c7166a).

Thanks!
-- 
Matthias



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Calling C++ hackers.  Please try out the new handling of C++11 lambda functions in CC Mode.
  2016-08-21 16:22       ` Alan Mackenzie
  2016-08-24 19:27         ` Richard Copley
@ 2016-08-27 15:37         ` Matthias Meulien
  1 sibling, 0 replies; 13+ messages in thread
From: Matthias Meulien @ 2016-08-27 15:37 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: emacs-devel

> I've just committed a first attempt at C++11 uniform initialization
> to the savannah master branch.
> 
> Please update your Emacs, and try it out.  Let the bug reports flow!

I looks good to me at first sight. I'll let you know if I see any
problem.

Thanks again!

-- 
Matthias



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Calling C++ hackers.  Please try out the new handling of C++11 lambda functions in CC Mode.
  2016-08-27 15:35         ` Matthias Meulien
@ 2016-08-27 20:27           ` Alan Mackenzie
  0 siblings, 0 replies; 13+ messages in thread
From: Alan Mackenzie @ 2016-08-27 20:27 UTC (permalink / raw)
  To: Matthias Meulien; +Cc: emacs-devel

Hello, Matthias.

On Sat, Aug 27, 2016 at 05:35:19PM +0200, Matthias Meulien wrote:
> Hi Alan,

> > > Shall I fill a bug report?

> http://debbugs.gnu.org/cgi/bugreport.cgi?bug=24319

Many thanks!  I've just committed the fix to the savannah master branch
and closed the bug.

> > If you would, yes please.
> > 
> > Would you also please try out on your real code the following patch
> > which is intended to fix the problem.  Please either confirm that the
> > bug is fixed, or let me know what's still not working
> > properly.  Thanks!

> The bug is fixed with your patch applied to a fresh source tree
> (1c7166a).

> Thanks!
> -- 
> Matthias

-- 
Alan Mackenzie (Nuremberg, Germany).



^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2016-08-27 20:27 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-15 12:24 Calling C++ hackers. Please try out the new handling of C++11 lambda functions in CC Mode Alan Mackenzie
2016-08-15 16:17 ` Eli Zaretskii
2016-08-19 21:45 ` Matthias Meulien
2016-08-20 15:19   ` Alan Mackenzie
2016-08-20 22:06     ` Matthias Meulien
2016-08-21 12:24       ` Alan Mackenzie
2016-08-27 15:35         ` Matthias Meulien
2016-08-27 20:27           ` Alan Mackenzie
2016-08-21 16:22       ` Alan Mackenzie
2016-08-24 19:27         ` Richard Copley
2016-08-24 19:43           ` Alan Mackenzie
2016-08-24 21:10             ` Richard Copley
2016-08-27 15:37         ` Matthias Meulien

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).