Subject: Re: bug#72311: [PATCH] Treat period as a symbol constituent in cc-mode

From: Alan Mackenzie <[email-masked]>
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).