emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: emacs-29 b18754bb179: Minor improvements in c-ts-mode and docs


From: Alan Mackenzie
Subject: Re: emacs-29 b18754bb179: Minor improvements in c-ts-mode and docs
Date: Wed, 15 Feb 2023 19:44:57 +0000

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]