all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#72310: [PATCH] Treat period as a symbol constituent in cc-mode
@ 2024-07-26 19:20 Vladislav Yegorov
  2024-07-26 19:26 ` bug#72311: " Vladislav Yegorov
  0 siblings, 1 reply; 7+ messages in thread
From: Vladislav Yegorov @ 2024-07-26 19:20 UTC (permalink / raw)
  To: 72310

I am not sure if this is intended behavior or not, but as it's just a
small change I am directly submitting a patch.

I would expect c-mode to treat numbers with a decimal point as one
symbol instead of two separate.  The same thing can be said about
designated initializers (i.e. {.pi = 3.14}).  I quickly checked the
behavior in emacs-lisp-mode and it works as I would expect there
(forward-symbol skips a decimal point number as a whole).





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

* bug#72311: [PATCH] Treat period as a symbol constituent in cc-mode
  2024-07-26 19:20 bug#72310: [PATCH] Treat period as a symbol constituent in cc-mode Vladislav Yegorov
@ 2024-07-26 19:26 ` Vladislav Yegorov
  2024-07-26 21:37   ` Jeremy Bryant via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-07-27  5:55   ` Eli Zaretskii
  0 siblings, 2 replies; 7+ messages in thread
From: Vladislav Yegorov @ 2024-07-26 19:26 UTC (permalink / raw)
  To: Vladislav Yegorov; +Cc: 72311

[-- Attachment #1: Type: text/plain, Size: 40 bytes --]

I am sorry, I forgot the actual patch.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Treat-period-as-a-symbol-constituent-in-cc-mode.patch --]
[-- Type: text/patch, Size: 993 bytes --]

From 0378400ba000cdaf0612b80406e29aee1fd97231 Mon Sep 17 00:00:00 2001
From: Vladislav Yegorov <vlad@yegorov.org>
Date: Fri, 26 Jul 2024 20:55:22 +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.
---
 lisp/progmodes/cc-langs.el | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el
index 72cfdfa..f253df9 100644
--- a/lisp/progmodes/cc-langs.el
+++ b/lisp/progmodes/cc-langs.el
@@ -336,6 +336,7 @@ the comment syntax to handle both line style \"//\" and block style
   ;; Never native compile to allow cc-mode.el:467 hack.
   (declare (speed -1))
   (modify-syntax-entry ?_  "_"     table)
+  (modify-syntax-entry ?.  "_"     table)
   (modify-syntax-entry ?\\ "\\"    table)
   (modify-syntax-entry ?+  "."     table)
   (modify-syntax-entry ?-  "."     table)
-- 
2.45.2


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

* bug#72311: [PATCH] Treat period as a symbol constituent in cc-mode
  2024-07-26 19:26 ` bug#72311: " Vladislav Yegorov
@ 2024-07-26 21:37   ` Jeremy Bryant via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-07-27  5:55   ` Eli Zaretskii
  1 sibling, 0 replies; 7+ messages in thread
From: Jeremy Bryant via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-07-26 21:37 UTC (permalink / raw)
  To: Vladislav Yegorov; +Cc: Alan Mackenzie, 72311

Vladislav Yegorov <vlad@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?





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

* bug#72311: [PATCH] Treat period as a symbol constituent in cc-mode
  2024-07-26 19:26 ` bug#72311: " Vladislav Yegorov
  2024-07-26 21:37   ` Jeremy Bryant via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-07-27  5:55   ` Eli Zaretskii
  2024-07-27  9:22     ` Vladislav Yegorov
  1 sibling, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2024-07-27  5:55 UTC (permalink / raw)
  To: Alan Mackenzie, Vladislav Yegorov; +Cc: 72311

> Cc: 72311@debbugs.gnu.org
> From: Vladislav Yegorov <vlad@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?





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

* bug#72311: [PATCH] Treat period as a symbol constituent in cc-mode
  2024-07-27  5:55   ` Eli Zaretskii
@ 2024-07-27  9:22     ` Vladislav Yegorov
  2024-07-27 11:26       ` Alan Mackenzie
  0 siblings, 1 reply; 7+ messages in thread
From: Vladislav Yegorov @ 2024-07-27  9:22 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Alan Mackenzie, 72311


> 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?





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

* bug#72311: [PATCH] Treat period as a symbol constituent in cc-mode
  2024-07-27  9:22     ` Vladislav Yegorov
@ 2024-07-27 11:26       ` Alan Mackenzie
  2024-07-28 23:59         ` Dmitry Gutov
  0 siblings, 1 reply; 7+ messages in thread
From: Alan Mackenzie @ 2024-07-27 11:26 UTC (permalink / raw)
  To: Vladislav Yegorov; +Cc: acm, Eli Zaretskii, Jeremy Bryant, 72311

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).





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

* bug#72311: [PATCH] Treat period as a symbol constituent in cc-mode
  2024-07-27 11:26       ` Alan Mackenzie
@ 2024-07-28 23:59         ` Dmitry Gutov
  0 siblings, 0 replies; 7+ messages in thread
From: Dmitry Gutov @ 2024-07-28 23:59 UTC (permalink / raw)
  To: Alan Mackenzie, Vladislav Yegorov; +Cc: Eli Zaretskii, Jeremy Bryant, 72311

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.





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

end of thread, other threads:[~2024-07-28 23:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-26 19:20 bug#72310: [PATCH] Treat period as a symbol constituent in cc-mode Vladislav Yegorov
2024-07-26 19:26 ` bug#72311: " Vladislav Yegorov
2024-07-26 21:37   ` Jeremy Bryant via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-07-27  5:55   ` Eli Zaretskii
2024-07-27  9:22     ` Vladislav Yegorov
2024-07-27 11:26       ` Alan Mackenzie
2024-07-28 23:59         ` Dmitry Gutov

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.