GNU bug report logs - #72311
[PATCH] Treat period as a symbol constituent in cc-mode

Previous Next

Package: emacs;

Reported by: Vladislav Yegorov <vlad <at> yegorov.org>

Date: Fri, 26 Jul 2024 20:00:03 UTC

Severity: wishlist

Tags: patch

Merged with 72310

Done: Stefan Kangas <stefankangas <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 72311 in the body.
You can then email your comments to 72311 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#72311; Package emacs. (Fri, 26 Jul 2024 20:00:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Vladislav Yegorov <vlad <at> yegorov.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 26 Jul 2024 20:00:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Vladislav Yegorov <vlad <at> yegorov.org>
To: Vladislav Yegorov <vlad <at> yegorov.org>
Cc: bug-gnu-emacs <at> gnu.org
Subject: Re: [PATCH] Treat period as a symbol constituent in cc-mode
Date: Fri, 26 Jul 2024 21:26:34 +0200
[Message part 1 (text/plain, inline)]
I am sorry, I forgot the actual patch.

[0001-Treat-period-as-a-symbol-constituent-in-cc-mode.patch (text/patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#72311; Package emacs. (Fri, 26 Jul 2024 21:39:02 GMT) Full text and rfc822 format available.

Message #8 received at 72311 <at> debbugs.gnu.org (full text, mbox):

From: Jeremy Bryant <jb <at> jeremybryant.net>
To: Vladislav Yegorov <vlad <at> yegorov.org>
Cc: Alan Mackenzie <acm <at> muc.de>, 72311 <at> debbugs.gnu.org
Subject: Re: bug#72311: [PATCH] Treat period as a symbol constituent in cc-mode
Date: Fri, 26 Jul 2024 22:37:51 +0100
Vladislav Yegorov <vlad <at> yegorov.org> writes:

> I am sorry, I forgot the actual patch.
>
> [2. text/patch; 0001-Treat-period-as-a-symbol-constituent-in-cc-mode.patch]...

Alan, any thoughts?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#72311; Package emacs. (Sat, 27 Jul 2024 05:56:01 GMT) Full text and rfc822 format available.

Message #11 received at 72311 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Alan Mackenzie <acm <at> muc.de>, Vladislav Yegorov <vlad <at> yegorov.org>
Cc: 72311 <at> debbugs.gnu.org
Subject: Re: bug#72311: [PATCH] Treat period as a symbol constituent in cc-mode
Date: Sat, 27 Jul 2024 08:55:23 +0300
> Cc: 72311 <at> debbugs.gnu.org
> From: Vladislav Yegorov <vlad <at> yegorov.org>
> Date: Fri, 26 Jul 2024 21:26:34 +0200
> 
> Subject: [PATCH] Treat period as a symbol constituent in cc-mode
> 
> * lisp/progmodes/cc-langs.el: Classify period as a symbol constituent,
> so decimal points for example don't divide the number into two symbols.

What about stuff like 'foo.bar', where 'foo' is a struct and 'bar' is
its member? won't this change make them a single symbol?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#72311; Package emacs. (Sat, 27 Jul 2024 11:28:02 GMT) Full text and rfc822 format available.

Message #14 received at 72311 <at> debbugs.gnu.org (full text, mbox):

From: Alan Mackenzie <acm <at> muc.de>
To: Vladislav Yegorov <vlad <at> yegorov.org>
Cc: acm <at> muc.de, Eli Zaretskii <eliz <at> gnu.org>,
 Jeremy Bryant <jb <at> jeremybryant.net>, 72311 <at> debbugs.gnu.org
Subject: Re: bug#72311: [PATCH] Treat period as a symbol constituent in cc-mode
Date: Sat, 27 Jul 2024 11:26:49 +0000
Hello, Vladislav and Eli.

On Sat, Jul 27, 2024 at 11:22:11 +0200, Vladislav Yegorov wrote:

> > What about stuff like 'foo.bar', where 'foo' is a struct and 'bar'
> > is its member? won't this change make them a single symbol?

That was my first reaction, too.

> You are right, kind of forgot about that.  I think in that case a
> simple syntax table modification like my patch provides won't do the
> trick.

> My motivation for this patch was to able to use C-M-f (forward-sexp)
> to skip over decimal numbers.  What are your thoughts on defining a
> forward-sexp-function that will use a alternate syntax table in
> certain contexts? maybe a bit too hacky?

It would be possible to put a syntax-table text property on a '.' when
it is followed directly by a decimal digit, with no space between.
Maybe we could also check that there's a valid number character before
the . (space, BOL, 0-9, -, ...?), but that might be over engineering.

My next thought is, for consistency, how would we handle something like
1.381E-23?  For consistency, C-M-f ought to move forward over that
number in its entirety.  That would need some more rigorous analysis of
every piece of text, probably by a regexp, and putting syntax-table
properties on both the '.' and the '-'.  This would slow CC Mode down,
even if not by a lot.

So, it could be done, yes.  Is it worth doing, though?  I've got very
little experience of hacking files with lots of floating point constants
in them, so it's difficult for me to judge just how annoying it is for
C-M-f and C-M-b only to move over part of a number.

-- 
Alan Mackenzie (Nuremberg, Germany).




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#72311; Package emacs. (Sat, 27 Jul 2024 18:53:03 GMT) Full text and rfc822 format available.

Message #17 received at 72311 <at> debbugs.gnu.org (full text, mbox):

From: Vladislav Yegorov <vlad <at> yegorov.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Alan Mackenzie <acm <at> muc.de>, 72311 <at> debbugs.gnu.org
Subject: Re: bug#72311: [PATCH] Treat period as a symbol constituent in cc-mode
Date: Sat, 27 Jul 2024 11:22:11 +0200
> What about stuff like 'foo.bar', where 'foo' is a struct and 'bar' is
> its member? won't this change make them a single symbol?

You are right, kind of forgot about that.  I think in that case a simple
syntax table modification like my patch provides won't do the trick.

My motivation for this patch was to able to use C-M-f (forward-sexp) to
skip over decimal numbers.  What are your thoughts on defining a
forward-sexp-function that will use a alternate syntax table in certain
contexts? maybe a bit too hacky?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#72311; Package emacs. (Mon, 29 Jul 2024 00:01:01 GMT) Full text and rfc822 format available.

Message #20 received at 72311 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dmitry <at> gutov.dev>
To: Alan Mackenzie <acm <at> muc.de>, Vladislav Yegorov <vlad <at> yegorov.org>
Cc: Eli Zaretskii <eliz <at> gnu.org>, Jeremy Bryant <jb <at> jeremybryant.net>,
 72311 <at> debbugs.gnu.org
Subject: Re: bug#72311: [PATCH] Treat period as a symbol constituent in cc-mode
Date: Mon, 29 Jul 2024 02:59:44 +0300
On 27/07/2024 14:26, Alan Mackenzie wrote:
> It would be possible to put a syntax-table text property on a '.' when
> it is followed directly by a decimal digit, with no space between.
> Maybe we could also check that there's a valid number character before
> the . (space, BOL, 0-9, -, ...?), but that might be over engineering.

That sounds like the better choice indeed, but given the increase in 
complexity maybe the minor improvement in behavior is not really worth 
the effort.




Forcibly Merged 72310 72311. Request was from Stefan Kangas <stefankangas <at> gmail.com> to control <at> debbugs.gnu.org. (Sat, 05 Oct 2024 01:16:02 GMT) Full text and rfc822 format available.

Severity set to 'wishlist' from 'normal' Request was from Stefan Kangas <stefankangas <at> gmail.com> to control <at> debbugs.gnu.org. (Tue, 11 Feb 2025 19:25:01 GMT) Full text and rfc822 format available.

Reply sent to Stefan Kangas <stefankangas <at> gmail.com>:
You have taken responsibility. (Sun, 23 Feb 2025 00:50:02 GMT) Full text and rfc822 format available.

Notification sent to Vladislav Yegorov <vlad <at> yegorov.org>:
bug acknowledged by developer. (Sun, 23 Feb 2025 00:50:02 GMT) Full text and rfc822 format available.

Message #29 received at 72311-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Dmitry Gutov <dmitry <at> gutov.dev>
Cc: Alan Mackenzie <acm <at> muc.de>, Eli Zaretskii <eliz <at> gnu.org>,
 Vladislav Yegorov <vlad <at> yegorov.org>, Jeremy Bryant <jb <at> jeremybryant.net>,
 72311-done <at> debbugs.gnu.org
Subject: Re: bug#72311: [PATCH] Treat period as a symbol constituent in cc-mode
Date: Sun, 23 Feb 2025 00:49:49 +0000
Dmitry Gutov <dmitry <at> gutov.dev> writes:

> On 27/07/2024 14:26, Alan Mackenzie wrote:
>> It would be possible to put a syntax-table text property on a '.' when
>> it is followed directly by a decimal digit, with no space between.
>> Maybe we could also check that there's a valid number character before
>> the . (space, BOL, 0-9, -, ...?), but that might be over engineering.
>
> That sounds like the better choice indeed, but given the increase in complexity
> maybe the minor improvement in behavior is not really worth the effort.

It sounds like this is not a change that we want to make, so I'm closing
this now.

Nevertheless, thanks for the patch, Vladislav.




Reply sent to Stefan Kangas <stefankangas <at> gmail.com>:
You have taken responsibility. (Sun, 23 Feb 2025 00:50:03 GMT) Full text and rfc822 format available.

Notification sent to Vladislav Yegorov <vlad <at> yegorov.org>:
bug acknowledged by developer. (Sun, 23 Feb 2025 00:50:03 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 23 Mar 2025 11:24:15 GMT) Full text and rfc822 format available.

This bug report was last modified 100 days ago.

Previous Next


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