unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: emacs-29 b18754bb179: Minor improvements in c-ts-mode and docs
       [not found] ` <20230215180229.75FF5C00613@vcs2.savannah.gnu.org>
@ 2023-02-15 18:14   ` Dmitry Gutov
  2023-02-15 18:31     ` Alan Mackenzie
  2023-02-15 18:35     ` Eli Zaretskii
  0 siblings, 2 replies; 25+ messages in thread
From: Dmitry Gutov @ 2023-02-15 18:14 UTC (permalink / raw)
  To: emacs-devel, Eli Zaretskii

On 15/02/2023 20:02, Eli Zaretskii wrote:
> +  "C-c C-c" #'comment-region)

Should we maybe take this opportunity to introduce c-ts-mode's users to 
the common bindings we use in other modes?

'M-;' seems to work just fine for commenting code already. And it has 
more capabilities than 'comment-region'.



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

* Re: emacs-29 b18754bb179: Minor improvements in c-ts-mode and docs
  2023-02-15 18:14   ` emacs-29 b18754bb179: Minor improvements in c-ts-mode and docs Dmitry Gutov
@ 2023-02-15 18:31     ` Alan Mackenzie
  2023-02-15 18:50       ` Dmitry Gutov
  2023-02-15 18:35     ` Eli Zaretskii
  1 sibling, 1 reply; 25+ messages in thread
From: Alan Mackenzie @ 2023-02-15 18:31 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: emacs-devel, Eli Zaretskii

Hello, Dmitry.

On Wed, Feb 15, 2023 at 20:14:29 +0200, Dmitry Gutov wrote:
> On 15/02/2023 20:02, Eli Zaretskii wrote:
> > +  "C-c C-c" #'comment-region)

> Should we maybe take this opportunity to introduce c-ts-mode's users to 
> the common bindings we use in other modes?

> 'M-;' seems to work just fine for commenting code already. And it has 
> more capabilities than 'comment-region'.

M-; can only comment the region when transient-mark-mode is enabled.

The flip-side of "has more capabilities" is "doesn't do one thing and do
it well".

In practice, in C Mode, I use both C-c C-c and M-;, depending on whether
I'm (un)commenting the region or a single line.  I think the C-c C-c
binding should remain.

-- 
Alan Mackenzie (Nuremberg, Germany).



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

* Re: emacs-29 b18754bb179: Minor improvements in c-ts-mode and docs
  2023-02-15 18:14   ` emacs-29 b18754bb179: Minor improvements in c-ts-mode and docs Dmitry Gutov
  2023-02-15 18:31     ` Alan Mackenzie
@ 2023-02-15 18:35     ` Eli Zaretskii
  2023-02-15 18:53       ` Dmitry Gutov
  1 sibling, 1 reply; 25+ messages in thread
From: Eli Zaretskii @ 2023-02-15 18:35 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: emacs-devel

> Date: Wed, 15 Feb 2023 20:14:29 +0200
> From: Dmitry Gutov <dgutov@yandex.ru>
> 
> On 15/02/2023 20:02, Eli Zaretskii wrote:
> > +  "C-c C-c" #'comment-region)
> 
> Should we maybe take this opportunity to introduce c-ts-mode's users to 
> the common bindings we use in other modes?

What does this mean in practice?

> 'M-;' seems to work just fine for commenting code already. And it has 
> more capabilities than 'comment-region'.

Sure, which is why it didn't need any changes in code or
documentation.  So what is your point here?



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

* Re: emacs-29 b18754bb179: Minor improvements in c-ts-mode and docs
  2023-02-15 18:31     ` Alan Mackenzie
@ 2023-02-15 18:50       ` Dmitry Gutov
  2023-02-15 19:37         ` Eli Zaretskii
  2023-02-15 19:44         ` Alan Mackenzie
  0 siblings, 2 replies; 25+ messages in thread
From: Dmitry Gutov @ 2023-02-15 18:50 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: emacs-devel, Eli Zaretskii

On 15/02/2023 20:31, Alan Mackenzie wrote:
> Hello, Dmitry.
> 
> On Wed, Feb 15, 2023 at 20:14:29 +0200, Dmitry Gutov wrote:
>> On 15/02/2023 20:02, Eli Zaretskii wrote:
>>> +  "C-c C-c" #'comment-region)
> 
>> Should we maybe take this opportunity to introduce c-ts-mode's users to
>> the common bindings we use in other modes?
> 
>> 'M-;' seems to work just fine for commenting code already. And it has
>> more capabilities than 'comment-region'.
> 
> M-; can only comment the region when transient-mark-mode is enabled.

If M-; doesn't work adequately with transient-mark-mode off, it seems 
like an area for improvement. E.g. like this:

diff --git a/lisp/newcomment.el b/lisp/newcomment.el
index 022bf3059be..effa90371e5 100644
--- a/lisp/newcomment.el
+++ b/lisp/newcomment.el
@@ -1364,7 +1364,8 @@ comment-dwim
  You can configure `comment-style' to change the way regions are 
commented."
    (interactive "*P")
    (comment-normalize-vars)
-  (if (use-region-p)
+  (if (or (not transient-mark-mode)
+          (use-region-p))
        (comment-or-uncomment-region (region-beginning) (region-end) arg)
      (if (save-excursion (beginning-of-line) (not (looking-at "\\s-*$")))
  	;; FIXME: If there's no comment to kill on this line and ARG is

Alternatively, turning transient-mark-mode off would add the 
comment-region binding globally (for those who want to stay with the 
legacy behavior) but keep the binding free otherwise.

> The flip-side of "has more capabilities" is "doesn't do one thing and do
> it well".
> 
> In practice, in C Mode, I use both C-c C-c and M-;, depending on whether
> I'm (un)commenting the region or a single line.  I think the C-c C-c
> binding should remain.

I just don't see why C Mode needs that binding, whereas all other 
language modes don't.



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

* Re: emacs-29 b18754bb179: Minor improvements in c-ts-mode and docs
  2023-02-15 18:35     ` Eli Zaretskii
@ 2023-02-15 18:53       ` Dmitry Gutov
  2023-02-15 19:39         ` Eli Zaretskii
  0 siblings, 1 reply; 25+ messages in thread
From: Dmitry Gutov @ 2023-02-15 18:53 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

On 15/02/2023 20:35, Eli Zaretskii wrote:
>> Date: Wed, 15 Feb 2023 20:14:29 +0200
>> From: Dmitry Gutov <dgutov@yandex.ru>
>>
>> On 15/02/2023 20:02, Eli Zaretskii wrote:
>>> +  "C-c C-c" #'comment-region)
>>
>> Should we maybe take this opportunity to introduce c-ts-mode's users to
>> the common bindings we use in other modes?
> 
> What does this mean in practice?

It would mean not adding the comment-region binding. Then I imagine 
people who transition to c-ts-mode, or start using it for the first 
time, might spend a little time looking for comment-related bindings, 
but in the end will learn to reach for it.

As a result, sometime later we could get to a convention where 'C-c C-c' 
does something else, but consistent across modes.

Also see the other reply regarding the users with transient-mark-mode=nil.



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

* Re: emacs-29 b18754bb179: Minor improvements in c-ts-mode and docs
  2023-02-15 18:50       ` Dmitry Gutov
@ 2023-02-15 19:37         ` Eli Zaretskii
  2023-02-15 20:25           ` Dmitry Gutov
  2023-02-15 19:44         ` Alan Mackenzie
  1 sibling, 1 reply; 25+ messages in thread
From: Eli Zaretskii @ 2023-02-15 19:37 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: acm, emacs-devel

> Date: Wed, 15 Feb 2023 20:50:30 +0200
> Cc: emacs-devel@gnu.org, Eli Zaretskii <eliz@gnu.org>
> From: Dmitry Gutov <dgutov@yandex.ru>
> 
> If M-; doesn't work adequately with transient-mark-mode off, it seems 
> like an area for improvement. E.g. like this:
> 
> diff --git a/lisp/newcomment.el b/lisp/newcomment.el
> index 022bf3059be..effa90371e5 100644
> --- a/lisp/newcomment.el
> +++ b/lisp/newcomment.el
> @@ -1364,7 +1364,8 @@ comment-dwim
>   You can configure `comment-style' to change the way regions are 
> commented."
>     (interactive "*P")
>     (comment-normalize-vars)
> -  (if (use-region-p)
> +  (if (or (not transient-mark-mode)
> +          (use-region-p))

This cannot be right: with it, it would be impossible to get M-; to
start a new comment when transient-mark-mode is off.

> I just don't see why C Mode needs that binding, whereas all other 
> language modes don't.

Maybe it's the other way around: all other languages need "C-c C-c".



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

* Re: emacs-29 b18754bb179: Minor improvements in c-ts-mode and docs
  2023-02-15 18:53       ` Dmitry Gutov
@ 2023-02-15 19:39         ` Eli Zaretskii
  2023-02-15 20:32           ` Dmitry Gutov
  0 siblings, 1 reply; 25+ messages in thread
From: Eli Zaretskii @ 2023-02-15 19:39 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: emacs-devel

> Date: Wed, 15 Feb 2023 20:53:37 +0200
> Cc: emacs-devel@gnu.org
> From: Dmitry Gutov <dgutov@yandex.ru>
> 
> On 15/02/2023 20:35, Eli Zaretskii wrote:
> >> Date: Wed, 15 Feb 2023 20:14:29 +0200
> >> From: Dmitry Gutov <dgutov@yandex.ru>
> >>
> >> On 15/02/2023 20:02, Eli Zaretskii wrote:
> >>> +  "C-c C-c" #'comment-region)
> >>
> >> Should we maybe take this opportunity to introduce c-ts-mode's users to
> >> the common bindings we use in other modes?
> > 
> > What does this mean in practice?
> 
> It would mean not adding the comment-region binding. Then I imagine 
> people who transition to c-ts-mode, or start using it for the first 
> time, might spend a little time looking for comment-related bindings, 
> but in the end will learn to reach for it.

That'd be a hard sell for users of C mode, as I presume they are used
to have it.  I do.



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

* Re: emacs-29 b18754bb179: Minor improvements in c-ts-mode and docs
  2023-02-15 18:50       ` Dmitry Gutov
  2023-02-15 19:37         ` Eli Zaretskii
@ 2023-02-15 19:44         ` Alan Mackenzie
  2023-02-15 20:29           ` Dmitry Gutov
  1 sibling, 1 reply; 25+ messages in thread
From: Alan Mackenzie @ 2023-02-15 19:44 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: emacs-devel, Eli Zaretskii

Hello, Dmitry.

On Wed, Feb 15, 2023 at 20:50:30 +0200, Dmitry Gutov wrote:
> On 15/02/2023 20:31, Alan Mackenzie wrote:
> > Hello, Dmitry.

> > On Wed, Feb 15, 2023 at 20:14:29 +0200, Dmitry Gutov wrote:
> >> On 15/02/2023 20:02, Eli Zaretskii wrote:
> >>> +  "C-c C-c" #'comment-region)

> >> Should we maybe take this opportunity to introduce c-ts-mode's users to
> >> the common bindings we use in other modes?

> >> 'M-;' seems to work just fine for commenting code already. And it has
> >> more capabilities than 'comment-region'.

> > M-; can only comment the region when transient-mark-mode is enabled.

> If M-; doesn't work adequately with transient-mark-mode off, it seems 
> like an area for improvement.

There are five distinct function (at least) in comment-dwim.  I'm
unconvinced it's a good idea to try to make them all work under a single
key binding.

> E.g. like this:

> diff --git a/lisp/newcomment.el b/lisp/newcomment.el
> index 022bf3059be..effa90371e5 100644
> --- a/lisp/newcomment.el
> +++ b/lisp/newcomment.el
> @@ -1364,7 +1364,8 @@ comment-dwim
>   You can configure `comment-style' to change the way regions are 
> commented."
>     (interactive "*P")
>     (comment-normalize-vars)
> -  (if (use-region-p)
> +  (if (or (not transient-mark-mode)
> +          (use-region-p))
>         (comment-or-uncomment-region (region-beginning) (region-end) arg)
>       (if (save-excursion (beginning-of-line) (not (looking-at "\\s-*$")))
>   	;; FIXME: If there's no comment to kill on this line and ARG is

That would not allow the user, with transient-mark-mode disabled, to
choose between commenting the region and adding a comment to the current
line.

> Alternatively, turning transient-mark-mode off would add the 
> comment-region binding globally (for those who want to stay with the 
> legacy behavior) but keep the binding free otherwise.

The C-c C-c binding has other bindings in various major modes.

> > The flip-side of "has more capabilities" is "doesn't do one thing and do
> > it well".

> > In practice, in C Mode, I use both C-c C-c and M-;, depending on whether
> > I'm (un)commenting the region or a single line.  I think the C-c C-c
> > binding should remain.

> I just don't see why C Mode needs that binding, whereas all other 
> language modes don't.

I think they do.  It is inconvenient having to type M-x comment-region
in, for example, texinfo-mode.

-- 
Alan Mackenzie (Nuremberg, Germany).



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

* Re: emacs-29 b18754bb179: Minor improvements in c-ts-mode and docs
  2023-02-15 19:37         ` Eli Zaretskii
@ 2023-02-15 20:25           ` Dmitry Gutov
  2023-02-16  7:09             ` Eli Zaretskii
  0 siblings, 1 reply; 25+ messages in thread
From: Dmitry Gutov @ 2023-02-15 20:25 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: acm, emacs-devel

On 15/02/2023 21:37, Eli Zaretskii wrote:
>> I just don't see why C Mode needs that binding, whereas all other
>> language modes don't.
> Maybe it's the other way around: all other languages need "C-c C-c".

And yet, to my recollection nobody else has ever asked for it.



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

* Re: emacs-29 b18754bb179: Minor improvements in c-ts-mode and docs
  2023-02-15 19:44         ` Alan Mackenzie
@ 2023-02-15 20:29           ` Dmitry Gutov
  2023-02-16  7:11             ` Eli Zaretskii
  0 siblings, 1 reply; 25+ messages in thread
From: Dmitry Gutov @ 2023-02-15 20:29 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: emacs-devel, Eli Zaretskii

On 15/02/2023 21:44, Alan Mackenzie wrote:
>> Alternatively, turning transient-mark-mode off would add the
>> comment-region binding globally (for those who want to stay with the
>> legacy behavior) but keep the binding free otherwise.
> The C-c C-c binding has other bindings in various major modes.

That's the crux of the issue: outside of CC Mode, 'C-c C-c' usually 
means something else. It would be useful to reduce that inconsistency.

Speaking of the idea, though: since the users of the "various major 
modes" never really spoke up about the absence of the binding for 
'comment-region', it shouldn't hurt them to have this binding shadowed. 
OTOH, if you have a better binding in mind, we could use it as well 
(again, only for users who disable transient-mark-mode).



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

* Re: emacs-29 b18754bb179: Minor improvements in c-ts-mode and docs
  2023-02-15 19:39         ` Eli Zaretskii
@ 2023-02-15 20:32           ` Dmitry Gutov
  2023-02-16  7:32             ` Eli Zaretskii
  0 siblings, 1 reply; 25+ messages in thread
From: Dmitry Gutov @ 2023-02-15 20:32 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

On 15/02/2023 21:39, Eli Zaretskii wrote:
>> Date: Wed, 15 Feb 2023 20:53:37 +0200
>> Cc:emacs-devel@gnu.org
>> From: Dmitry Gutov<dgutov@yandex.ru>
>>
>> On 15/02/2023 20:35, Eli Zaretskii wrote:
>>>> Date: Wed, 15 Feb 2023 20:14:29 +0200
>>>> From: Dmitry Gutov<dgutov@yandex.ru>
>>>>
>>>> On 15/02/2023 20:02, Eli Zaretskii wrote:
>>>>> +  "C-c C-c" #'comment-region)
>>>> Should we maybe take this opportunity to introduce c-ts-mode's users to
>>>> the common bindings we use in other modes?
>>> What does this mean in practice?
>> It would mean not adding the comment-region binding. Then I imagine
>> people who transition to c-ts-mode, or start using it for the first
>> time, might spend a little time looking for comment-related bindings,
>> but in the end will learn to reach for it.
> That'd be a hard sell for users of C mode, as I presume they are used
> to have it.  I do.

Maybe they are. But AFAICT your commit was not associated with a 
particular bug report.



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

* Re: emacs-29 b18754bb179: Minor improvements in c-ts-mode and docs
  2023-02-15 20:25           ` Dmitry Gutov
@ 2023-02-16  7:09             ` Eli Zaretskii
  2023-02-16 11:15               ` Dmitry Gutov
  0 siblings, 1 reply; 25+ messages in thread
From: Eli Zaretskii @ 2023-02-16  7:09 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: acm, emacs-devel

> Date: Wed, 15 Feb 2023 22:25:40 +0200
> Cc: acm@muc.de, emacs-devel@gnu.org
> From: Dmitry Gutov <dgutov@yandex.ru>
> 
> On 15/02/2023 21:37, Eli Zaretskii wrote:
> >> I just don't see why C Mode needs that binding, whereas all other
> >> language modes don't.
> > Maybe it's the other way around: all other languages need "C-c C-c".
> 
> And yet, to my recollection nobody else has ever asked for it.

Which, frankly, I find strange.  Assuming that commenting out a piece
of code is not limited to C mode, how do people go about that task
with just "M-;"?  Or maybe this means there's a high correlation
between people who edit C code and those who have transient-mark-mode
disabled?  I'm always annoyed when I have to invoke comment-region via
M-x; this happens to me at annoyingly high frequency in mail-mode, for
example.



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

* Re: emacs-29 b18754bb179: Minor improvements in c-ts-mode and docs
  2023-02-15 20:29           ` Dmitry Gutov
@ 2023-02-16  7:11             ` Eli Zaretskii
  0 siblings, 0 replies; 25+ messages in thread
From: Eli Zaretskii @ 2023-02-16  7:11 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: acm, emacs-devel

> Date: Wed, 15 Feb 2023 22:29:29 +0200
> Cc: emacs-devel@gnu.org, Eli Zaretskii <eliz@gnu.org>
> From: Dmitry Gutov <dgutov@yandex.ru>
> 
> On 15/02/2023 21:44, Alan Mackenzie wrote:
> >> Alternatively, turning transient-mark-mode off would add the
> >> comment-region binding globally (for those who want to stay with the
> >> legacy behavior) but keep the binding free otherwise.
> > The C-c C-c binding has other bindings in various major modes.
> 
> That's the crux of the issue: outside of CC Mode, 'C-c C-c' usually 
> means something else. It would be useful to reduce that inconsistency.

"C-c C-c" in C mode is a very old binding.  It is even documented in
the Emacs user manual, let alone the CC Mode manual.

> OTOH, if you have a better binding in mind, we could use it as well 
> (again, only for users who disable transient-mark-mode).

I don't know.  Ideas welcome.  I use M-; a lot, btw, just not for
commenting out a region.  And I always disable transient-mark-mode.



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

* Re: emacs-29 b18754bb179: Minor improvements in c-ts-mode and docs
  2023-02-15 20:32           ` Dmitry Gutov
@ 2023-02-16  7:32             ` Eli Zaretskii
  2023-02-16 11:17               ` Dmitry Gutov
  0 siblings, 1 reply; 25+ messages in thread
From: Eli Zaretskii @ 2023-02-16  7:32 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: emacs-devel

> Date: Wed, 15 Feb 2023 22:32:43 +0200
> Cc: emacs-devel@gnu.org
> From: Dmitry Gutov <dgutov@yandex.ru>
> 
> > That'd be a hard sell for users of C mode, as I presume they are used
> > to have it.  I do.
> 
> Maybe they are. But AFAICT your commit was not associated with a 
> particular bug report.

It was my own "bug report", I just short-circuited it by fixing the
problem instead of reporting it.  The trigger was another review of
the relevant sections in the Emacs manual and in the CC Mode manual,
and of my own customizations.  I consider it confusing and sub-optimal
to have some C-related feature described in the Emacs user manual that
works only in CC Mode.  We have a couple of other keybindings in
c-ts-mode.el, for the same reasons.



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

* Re: emacs-29 b18754bb179: Minor improvements in c-ts-mode and docs
  2023-02-16  7:09             ` Eli Zaretskii
@ 2023-02-16 11:15               ` Dmitry Gutov
  2023-02-16 12:01                 ` Eli Zaretskii
  0 siblings, 1 reply; 25+ messages in thread
From: Dmitry Gutov @ 2023-02-16 11:15 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: acm, emacs-devel

On 16/02/2023 09:09, Eli Zaretskii wrote:
> Or maybe this means there's a high correlation
> between people who edit C code and those who have transient-mark-mode
> disabled?

That is indeed possible.

Note that there were no bug reports about this for c-ts-mode either, 
though. So the correlation probably is there, but definitely not every 
C/Emacs programmer turns transient-mark-mode off.



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

* Re: emacs-29 b18754bb179: Minor improvements in c-ts-mode and docs
  2023-02-16  7:32             ` Eli Zaretskii
@ 2023-02-16 11:17               ` Dmitry Gutov
  2023-02-16 12:03                 ` Eli Zaretskii
  0 siblings, 1 reply; 25+ messages in thread
From: Dmitry Gutov @ 2023-02-16 11:17 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

On 16/02/2023 09:32, Eli Zaretskii wrote:
> I consider it confusing and sub-optimal
> to have some C-related feature described in the Emacs user manual that
> works only in CC Mode.  We have a couple of other keybindings in
> c-ts-mode.el, for the same reasons.

I'm not going to chime in about every such keybinding, but this could be 
our chance to reduce inconsistency between C mode and other language modes.

It's a new major mode, so we're not bound so much by the backward 
compatibility principle.

Anyway, I'll stop here now.



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

* Re: emacs-29 b18754bb179: Minor improvements in c-ts-mode and docs
  2023-02-16 11:15               ` Dmitry Gutov
@ 2023-02-16 12:01                 ` Eli Zaretskii
  0 siblings, 0 replies; 25+ messages in thread
From: Eli Zaretskii @ 2023-02-16 12:01 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: acm, emacs-devel

> Date: Thu, 16 Feb 2023 13:15:17 +0200
> Cc: acm@muc.de, emacs-devel@gnu.org
> From: Dmitry Gutov <dgutov@yandex.ru>
> 
> On 16/02/2023 09:09, Eli Zaretskii wrote:
> > Or maybe this means there's a high correlation
> > between people who edit C code and those who have transient-mark-mode
> > disabled?
> 
> That is indeed possible.
> 
> Note that there were no bug reports about this for c-ts-mode either, 
> though. So the correlation probably is there, but definitely not every 
> C/Emacs programmer turns transient-mark-mode off.

I'm not sure yet how many people started using c-ts-mode on a regular
basis.  I haven't, not yet.



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

* Re: emacs-29 b18754bb179: Minor improvements in c-ts-mode and docs
  2023-02-16 11:17               ` Dmitry Gutov
@ 2023-02-16 12:03                 ` Eli Zaretskii
  2023-02-16 12:51                   ` Dmitry Gutov
  0 siblings, 1 reply; 25+ messages in thread
From: Eli Zaretskii @ 2023-02-16 12:03 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: emacs-devel

> Date: Thu, 16 Feb 2023 13:17:41 +0200
> Cc: emacs-devel@gnu.org
> From: Dmitry Gutov <dgutov@yandex.ru>
> 
> On 16/02/2023 09:32, Eli Zaretskii wrote:
> > I consider it confusing and sub-optimal
> > to have some C-related feature described in the Emacs user manual that
> > works only in CC Mode.  We have a couple of other keybindings in
> > c-ts-mode.el, for the same reasons.
> 
> I'm not going to chime in about every such keybinding, but this could be 
> our chance to reduce inconsistency between C mode and other language modes.

We could at least discuss that, sure.  Is there a list of
inconsistencies between those modes available anywhere?

The next question, of course, is how to go about reducing the
inconsistencies.  What you proposed here is simply drop the
keybinding, but that might not be a good idea for other
inconsistencies, even if we finally decide that for this one it is
okay.



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

* Re: emacs-29 b18754bb179: Minor improvements in c-ts-mode and docs
  2023-02-16 12:03                 ` Eli Zaretskii
@ 2023-02-16 12:51                   ` Dmitry Gutov
  2023-02-16 15:19                     ` Eli Zaretskii
  0 siblings, 1 reply; 25+ messages in thread
From: Dmitry Gutov @ 2023-02-16 12:51 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

On 16/02/2023 14:03, Eli Zaretskii wrote:
>> Date: Thu, 16 Feb 2023 13:17:41 +0200
>> Cc: emacs-devel@gnu.org
>> From: Dmitry Gutov <dgutov@yandex.ru>
>>
>> On 16/02/2023 09:32, Eli Zaretskii wrote:
>>> I consider it confusing and sub-optimal
>>> to have some C-related feature described in the Emacs user manual that
>>> works only in CC Mode.  We have a couple of other keybindings in
>>> c-ts-mode.el, for the same reasons.
>>
>> I'm not going to chime in about every such keybinding, but this could be
>> our chance to reduce inconsistency between C mode and other language modes.
> 
> We could at least discuss that, sure.  Is there a list of
> inconsistencies between those modes available anywhere?

 From past discussions and looking at 'C-h m':

- "electric" behaviors: CC Mode's commands vs. electric-indent-mode and 
electric-pair-mode.
- c-subword-mode vs subword-mode
- c-display-defun-name vs which-function-mode
- c-indent-exp vs prog-indent-sexp
- c-indent-defun/c-fill-paragraph vs prog-fill-reindent-defun
- c-indent-line-or-region vs indent-for-tab-command and indent-region.

Curious how c-indent-line-or-region doesn't mind depending on 
transient-mark-mode being on.

> The next question, of course, is how to go about reducing the
> inconsistencies.  What you proposed here is simply drop the
> keybinding,

I also suggested, alternatively, that transient-mark-mode, when turned 
off, creates a global binding for comment-region (also with 'C-c C-c'). 
I'm guessing (almost?) all of the users who turn it off simply started 
with Emacs when that was the default behavior. If they haven't reported 
the lack of this binding in various modes, they aren't going to mind the 
shadowing of it as well.

> but that might not be a good idea for other
> inconsistencies, even if we finally decide that for this one it is
> okay.

The general plan could be:

- Wait for a complaint or a bug report.
- See if there is a generic feature which could be used instead. Or 
whether it could be tweaked.
- Or whether a new feature would benefit most/all programming modes and 
can be added to prog-mode instead, and it's easy enough to do.
- Add stuff to c-ts-mode otherwise.



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

* Re: emacs-29 b18754bb179: Minor improvements in c-ts-mode and docs
  2023-02-16 12:51                   ` Dmitry Gutov
@ 2023-02-16 15:19                     ` Eli Zaretskii
  2023-02-16 15:38                       ` Dmitry Gutov
  0 siblings, 1 reply; 25+ messages in thread
From: Eli Zaretskii @ 2023-02-16 15:19 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: emacs-devel

> Date: Thu, 16 Feb 2023 14:51:09 +0200
> Cc: emacs-devel@gnu.org
> From: Dmitry Gutov <dgutov@yandex.ru>
> 
> > We could at least discuss that, sure.  Is there a list of
> > inconsistencies between those modes available anywhere?
> 
>  From past discussions and looking at 'C-h m':
> 
> - "electric" behaviors: CC Mode's commands vs. electric-indent-mode and 
> electric-pair-mode.
> - c-subword-mode vs subword-mode
> - c-display-defun-name vs which-function-mode
> - c-indent-exp vs prog-indent-sexp
> - c-indent-defun/c-fill-paragraph vs prog-fill-reindent-defun
> - c-indent-line-or-region vs indent-for-tab-command and indent-region.

These don't exist in c-ts-mode, with the single exception of the
electric behavior of '#' (which is a must in C).  So I think we are
already there, no?

> Curious how c-indent-line-or-region doesn't mind depending on 
> transient-mark-mode being on.

It does:

  (c-indent-line-or-region &optional ARG REGION)

  Indent active region, current line, or block starting on this line.
  In Transient Mark mode, when the region is active, reindent the region.
  Otherwise, with a prefix argument, rigidly reindent the expression
  starting on the current line.
  Otherwise reindent just the current line.

> > The next question, of course, is how to go about reducing the
> > inconsistencies.  What you proposed here is simply drop the
> > keybinding,
> 
> I also suggested, alternatively, that transient-mark-mode, when turned 
> off, creates a global binding for comment-region (also with 'C-c C-c'). 

I'm not sure this is a good idea.  I'd rather we used the prefix
argument to M-; in some creative way, like if its value is zero or
negative.



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

* Re: emacs-29 b18754bb179: Minor improvements in c-ts-mode and docs
  2023-02-16 15:19                     ` Eli Zaretskii
@ 2023-02-16 15:38                       ` Dmitry Gutov
  2023-02-16 15:53                         ` Theodor Thornhill
  2023-02-16 15:58                         ` Eli Zaretskii
  0 siblings, 2 replies; 25+ messages in thread
From: Dmitry Gutov @ 2023-02-16 15:38 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

On 16/02/2023 17:19, Eli Zaretskii wrote:
>> Date: Thu, 16 Feb 2023 14:51:09 +0200
>> Cc: emacs-devel@gnu.org
>> From: Dmitry Gutov <dgutov@yandex.ru>
>>
>>> We could at least discuss that, sure.  Is there a list of
>>> inconsistencies between those modes available anywhere?
>>
>>   From past discussions and looking at 'C-h m':
>>
>> - "electric" behaviors: CC Mode's commands vs. electric-indent-mode and
>> electric-pair-mode.
>> - c-subword-mode vs subword-mode
>> - c-display-defun-name vs which-function-mode
>> - c-indent-exp vs prog-indent-sexp
>> - c-indent-defun/c-fill-paragraph vs prog-fill-reindent-defun
>> - c-indent-line-or-region vs indent-for-tab-command and indent-region.
> 
> These don't exist in c-ts-mode, with the single exception of the
> electric behavior of '#' (which is a must in C).

Could it work by adding ?# to electric-indent-chars?

> So I think we are
> already there, no?

We are at a crossroads. I think. To the left lies the approach I 
described. To the right -- adding more stuff from CC Mode verbatim, 
simply because a lot of people are already used to it.

>> Curious how c-indent-line-or-region doesn't mind depending on
>> transient-mark-mode being on.
> 
> It does:
> 
>    (c-indent-line-or-region &optional ARG REGION)
> 
>    Indent active region, current line, or block starting on this line.
>    In Transient Mark mode, when the region is active, reindent the region.
>    Otherwise, with a prefix argument, rigidly reindent the expression
>    starting on the current line.
>    Otherwise reindent just the current line.

Does the description mean that using the prefix will force a "rigid 
reindentation" of the region?

>>> The next question, of course, is how to go about reducing the
>>> inconsistencies.  What you proposed here is simply drop the
>>> keybinding,
>>
>> I also suggested, alternatively, that transient-mark-mode, when turned
>> off, creates a global binding for comment-region (also with 'C-c C-c').
> 
> I'm not sure this is a good idea.  I'd rather we used the prefix
> argument to M-; in some creative way, like if its value is zero or
> negative.

Could be a decent option. The meaning of C-u is already taken (to kill 
the comment), but 'C-u C-u' could do something different. As long as 
users with t-m-m=off think 'C-u C-u M-;' is a bearable substitute to 
'C-c C-c'.



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

* Re: emacs-29 b18754bb179: Minor improvements in c-ts-mode and docs
  2023-02-16 15:38                       ` Dmitry Gutov
@ 2023-02-16 15:53                         ` Theodor Thornhill
  2023-02-16 15:58                         ` Eli Zaretskii
  1 sibling, 0 replies; 25+ messages in thread
From: Theodor Thornhill @ 2023-02-16 15:53 UTC (permalink / raw)
  To: emacs-devel, Dmitry Gutov, Eli Zaretskii



On 16 February 2023 16:38:54 CET, Dmitry Gutov <dgutov@yandex.ru> wrote:
>On 16/02/2023 17:19, Eli Zaretskii wrote:
>>> Date: Thu, 16 Feb 2023 14:51:09 +0200
>>> Cc: emacs-devel@gnu.org
>>> From: Dmitry Gutov <dgutov@yandex.ru>
>>> 
>>>> We could at least discuss that, sure.  Is there a list of
>>>> inconsistencies between those modes available anywhere?
>>> 
>>>   From past discussions and looking at 'C-h m':
>>> 
>>> - "electric" behaviors: CC Mode's commands vs. electric-indent-mode and
>>> electric-pair-mode.
>>> - c-subword-mode vs subword-mode
>>> - c-display-defun-name vs which-function-mode
>>> - c-indent-exp vs prog-indent-sexp
>>> - c-indent-defun/c-fill-paragraph vs prog-fill-reindent-defun
>>> - c-indent-line-or-region vs indent-for-tab-command and indent-region.
>> 
>> These don't exist in c-ts-mode, with the single exception of the
>> electric behavior of '#' (which is a must in C).
>
>Could it work by adding ?# to electric-indent-chars?
>

Yes, I have a patch for this ready to go :)

>> So I think we are
>> already there, no?
>
>We are at a crossroads. I think. To the left lies the approach I described. To the right -- adding more stuff from CC Mode verbatim, simply because a lot of people are already used to it.
>
>>> Curious how c-indent-line-or-region doesn't mind depending on
>>> transient-mark-mode being on.
>> 
>> It does:
>> 
>>    (c-indent-line-or-region &optional ARG REGION)
>> 
>>    Indent active region, current line, or block starting on this line.
>>    In Transient Mark mode, when the region is active, reindent the region.
>>    Otherwise, with a prefix argument, rigidly reindent the expression
>>    starting on the current line.
>>    Otherwise reindent just the current line.
>
>Does the description mean that using the prefix will force a "rigid reindentation" of the region?
>
>>>> The next question, of course, is how to go about reducing the
>>>> inconsistencies.  What you proposed here is simply drop the
>>>> keybinding,
>>> 
>>> I also suggested, alternatively, that transient-mark-mode, when turned
>>> off, creates a global binding for comment-region (also with 'C-c C-c').
>> 
>> I'm not sure this is a good idea.  I'd rather we used the prefix
>> argument to M-; in some creative way, like if its value is zero or
>> negative.
>
>Could be a decent option. The meaning of C-u is already taken (to kill the comment), but 'C-u C-u' could do something different. As long as users with t-m-m=off think 'C-u C-u M-;' is a bearable substitute to 'C-c C-c'.
>



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

* Re: emacs-29 b18754bb179: Minor improvements in c-ts-mode and docs
  2023-02-16 15:38                       ` Dmitry Gutov
  2023-02-16 15:53                         ` Theodor Thornhill
@ 2023-02-16 15:58                         ` Eli Zaretskii
  2023-02-16 20:09                           ` Dmitry Gutov
  1 sibling, 1 reply; 25+ messages in thread
From: Eli Zaretskii @ 2023-02-16 15:58 UTC (permalink / raw)
  To: Dmitry Gutov, Theodor Thornhill; +Cc: emacs-devel

> Date: Thu, 16 Feb 2023 17:38:54 +0200
> Cc: emacs-devel@gnu.org
> From: Dmitry Gutov <dgutov@yandex.ru>
> 
> On 16/02/2023 17:19, Eli Zaretskii wrote:
> >> - "electric" behaviors: CC Mode's commands vs. electric-indent-mode and
> >> electric-pair-mode.
> >> - c-subword-mode vs subword-mode
> >> - c-display-defun-name vs which-function-mode
> >> - c-indent-exp vs prog-indent-sexp
> >> - c-indent-defun/c-fill-paragraph vs prog-fill-reindent-defun
> >> - c-indent-line-or-region vs indent-for-tab-command and indent-region.
> > 
> > These don't exist in c-ts-mode, with the single exception of the
> > electric behavior of '#' (which is a must in C).
> 
> Could it work by adding ?# to electric-indent-chars?

Theo is working on that, so it's up to him.

> We are at a crossroads. I think. To the left lies the approach I 
> described. To the right -- adding more stuff from CC Mode verbatim, 
> simply because a lot of people are already used to it.

I don't see a reason to add C-specific features to c-ts-mode as long
as the general ones do a decent job.  After reviewing the features and
their current equivalents in c-ts-mode, I asked for only one to be
added: electric-pound.  All the rest I think are in relatively good
shape as we are.  So are you sure we are at a crossroads and not
already home free?

> >    (c-indent-line-or-region &optional ARG REGION)
> > 
> >    Indent active region, current line, or block starting on this line.
> >    In Transient Mark mode, when the region is active, reindent the region.
> >    Otherwise, with a prefix argument, rigidly reindent the expression
> >    starting on the current line.
> >    Otherwise reindent just the current line.
> 
> Does the description mean that using the prefix will force a "rigid 
> reindentation" of the region?

Not of the region, but of the sexp starting at that line.  Exactly
like indent-for-tab-command:

  (indent-for-tab-command &optional ARG)

  Indent the current line or region, or insert a tab, as appropriate.
  This function either inserts a tab, or indents the current line,
  or performs symbol completion, depending on ‘tab-always-indent’.
  The function called to actually indent the line or insert a tab
  is given by the variable ‘indent-line-function’.

  If a prefix argument is given (ARG), after this function indents the
  current line or inserts a tab, it also rigidly indents the entire
  balanced expression which starts at the beginning of the current
  line, to reflect the current line’s indentation.

  In most major modes, if point was in the current line’s
  indentation, it is moved to the first non-whitespace character
  after indenting; otherwise it stays at the same position relative
  to the text.

  If ‘transient-mark-mode’ is turned on and the region is active,
  this function instead calls ‘indent-region’.  In this case, any
  prefix argument is ignored.




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

* Re: emacs-29 b18754bb179: Minor improvements in c-ts-mode and docs
  2023-02-16 15:58                         ` Eli Zaretskii
@ 2023-02-16 20:09                           ` Dmitry Gutov
  2023-02-16 20:22                             ` Eli Zaretskii
  0 siblings, 1 reply; 25+ messages in thread
From: Dmitry Gutov @ 2023-02-16 20:09 UTC (permalink / raw)
  To: Eli Zaretskii, Theodor Thornhill; +Cc: emacs-devel

On 16/02/2023 17:58, Eli Zaretskii wrote:
>> Date: Thu, 16 Feb 2023 17:38:54 +0200
>> Cc: emacs-devel@gnu.org
>> From: Dmitry Gutov <dgutov@yandex.ru>
>>
>> On 16/02/2023 17:19, Eli Zaretskii wrote:
>>>> - "electric" behaviors: CC Mode's commands vs. electric-indent-mode and
>>>> electric-pair-mode.
>>>> - c-subword-mode vs subword-mode
>>>> - c-display-defun-name vs which-function-mode
>>>> - c-indent-exp vs prog-indent-sexp
>>>> - c-indent-defun/c-fill-paragraph vs prog-fill-reindent-defun
>>>> - c-indent-line-or-region vs indent-for-tab-command and indent-region.
>>>
>>> These don't exist in c-ts-mode, with the single exception of the
>>> electric behavior of '#' (which is a must in C).
>>
>> Could it work by adding ?# to electric-indent-chars?
> 
> Theo is working on that, so it's up to him.

Very good.

>> We are at a crossroads. I think. To the left lies the approach I
>> described. To the right -- adding more stuff from CC Mode verbatim,
>> simply because a lot of people are already used to it.
> 
> I don't see a reason to add C-specific features to c-ts-mode as long
> as the general ones do a decent job.  After reviewing the features and
> their current equivalents in c-ts-mode, I asked for only one to be
> added: electric-pound.  All the rest I think are in relatively good
> shape as we are.  So are you sure we are at a crossroads and not
> already home free?

I don't know. The commit which gave rise to this thread surprised me 
already.

c-mode also has bindings like c-hungry-*, for example. Or 
c-toggle-auto-newline. But those seems less urgent, I guess.

>>>     (c-indent-line-or-region &optional ARG REGION)
>>>
>>>     Indent active region, current line, or block starting on this line.
>>>     In Transient Mark mode, when the region is active, reindent the region.
>>>     Otherwise, with a prefix argument, rigidly reindent the expression
>>>     starting on the current line.
>>>     Otherwise reindent just the current line.
>>
>> Does the description mean that using the prefix will force a "rigid
>> reindentation" of the region?
> 
> Not of the region, but of the sexp starting at that line.  Exactly
> like indent-for-tab-command:
> 
>    (indent-for-tab-command &optional ARG)
> 
>    Indent the current line or region, or insert a tab, as appropriate.
>    This function either inserts a tab, or indents the current line,
>    or performs symbol completion, depending on ‘tab-always-indent’.
>    The function called to actually indent the line or insert a tab
>    is given by the variable ‘indent-line-function’.
> 
>    If a prefix argument is given (ARG), after this function indents the
>    current line or inserts a tab, it also rigidly indents the entire
>    balanced expression which starts at the beginning of the current
>    line, to reflect the current line’s indentation.
> 
>    In most major modes, if point was in the current line’s
>    indentation, it is moved to the first non-whitespace character
>    after indenting; otherwise it stays at the same position relative
>    to the text.
> 
>    If ‘transient-mark-mode’ is turned on and the region is active,
>    this function instead calls ‘indent-region’.  In this case, any
>    prefix argument is ignored.

All right. So it seems like c-indent-line-or-region can be replaced with 
indent-for-tab-command without any particular loss?



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

* Re: emacs-29 b18754bb179: Minor improvements in c-ts-mode and docs
  2023-02-16 20:09                           ` Dmitry Gutov
@ 2023-02-16 20:22                             ` Eli Zaretskii
  0 siblings, 0 replies; 25+ messages in thread
From: Eli Zaretskii @ 2023-02-16 20:22 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: theo, emacs-devel

> Date: Thu, 16 Feb 2023 22:09:21 +0200
> Cc: emacs-devel@gnu.org
> From: Dmitry Gutov <dgutov@yandex.ru>
> 
> > I don't see a reason to add C-specific features to c-ts-mode as long
> > as the general ones do a decent job.  After reviewing the features and
> > their current equivalents in c-ts-mode, I asked for only one to be
> > added: electric-pound.  All the rest I think are in relatively good
> > shape as we are.  So are you sure we are at a crossroads and not
> > already home free?
> 
> I don't know. The commit which gave rise to this thread surprised me 
> already.

I already explained the rationale for that.

> All right. So it seems like c-indent-line-or-region can be replaced with 
> indent-for-tab-command without any particular loss?

That's what c-ts-mode does.



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

end of thread, other threads:[~2023-02-16 20:22 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <167648414913.7595.16030168421819097011@vcs2.savannah.gnu.org>
     [not found] ` <20230215180229.75FF5C00613@vcs2.savannah.gnu.org>
2023-02-15 18:14   ` emacs-29 b18754bb179: Minor improvements in c-ts-mode and docs Dmitry Gutov
2023-02-15 18:31     ` Alan Mackenzie
2023-02-15 18:50       ` Dmitry Gutov
2023-02-15 19:37         ` Eli Zaretskii
2023-02-15 20:25           ` Dmitry Gutov
2023-02-16  7:09             ` Eli Zaretskii
2023-02-16 11:15               ` Dmitry Gutov
2023-02-16 12:01                 ` Eli Zaretskii
2023-02-15 19:44         ` Alan Mackenzie
2023-02-15 20:29           ` Dmitry Gutov
2023-02-16  7:11             ` Eli Zaretskii
2023-02-15 18:35     ` Eli Zaretskii
2023-02-15 18:53       ` Dmitry Gutov
2023-02-15 19:39         ` Eli Zaretskii
2023-02-15 20:32           ` Dmitry Gutov
2023-02-16  7:32             ` Eli Zaretskii
2023-02-16 11:17               ` Dmitry Gutov
2023-02-16 12:03                 ` Eli Zaretskii
2023-02-16 12:51                   ` Dmitry Gutov
2023-02-16 15:19                     ` Eli Zaretskii
2023-02-16 15:38                       ` Dmitry Gutov
2023-02-16 15:53                         ` Theodor Thornhill
2023-02-16 15:58                         ` Eli Zaretskii
2023-02-16 20:09                           ` Dmitry Gutov
2023-02-16 20:22                             ` Eli Zaretskii

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