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: Dmitry Gutov
Subject: Re: emacs-29 b18754bb179: Minor improvements in c-ts-mode and docs
Date: Thu, 16 Feb 2023 22:09:21 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2

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?



reply via email to

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