unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Ergus <spacibba@aol.com>
To: Theodor Thornhill <theo@thornhill.no>
Cc: Eli Zaretskii <eliz@gnu.org>, casouri@gmail.com, emacs-devel@gnu.org
Subject: Re: Missing features in c-ts-mode
Date: Fri, 17 Feb 2023 09:29:35 +0100	[thread overview]
Message-ID: <20230217082935.waa7f473dmvbpg3d@Ergus> (raw)
In-Reply-To: <87ilg1qv71.fsf@thornhill.no>

Hi Theodor:

Sorry to bother, but I have a question about commit:

f1f571e Add electric indent for preproc directives

c-mode had by default the [0] indentation for #preprocesor directives,
but there are some use cases where that behavior is not desired (i.e
#pragma).

Actually there are even multi-line pragmas when using OpenMP

int main()
{
     #pragma parallel for first private(x) \
         shared(y) etc
     for (...) {
         ....
     }
}

In this case the pragma in column zero is very confusing. Alan added a
new mode (c-toggle-cpp-indent-to-body) which worked around this issue a
few years ago. I don't if it is possible to enable similar behavior with
your change? Is is?

Best,
Ergus




On Thu, Feb 16, 2023 at 08:14:26PM +0100, Theodor Thornhill wrote:
>Theodor Thornhill <theo@thornhill.no> writes:
>
>> Eli Zaretskii <eliz@gnu.org> writes:
>>
>>>> From: Theodor Thornhill <theo@thornhill.no>
>>>> Cc: casouri@gmail.com, emacs-devel@gnu.org
>>>> Date: Wed, 15 Feb 2023 20:31:33 +0100
>>>>
>>>> This patch adds some support for this- but I'm not really satisfied yet.
>>>> It will electrically indent if you've typed "#i", or if you insert "#"
>>>> before say, "if".  The reason it behaves this way right now is that the
>>>> parser returns an (ERROR (ERROR)) node when only # is inserted.  I'll
>>>> see if I can find some workaround for it.
>>>
>>> Thank you for working on this.
>
>Now done.  I believe the fix was small enough to go to emacs-29, so just
>pushed.  What would be the best way to create a test that would emulate
>this behavior?
>
>I tried
>
>```
>Code:
>  (lambda ()
>    (c-ts-mode)
>    (self-insert-command 1 "#"))
>
>Point-Char: |
>
>Name: Electric pound indents to column 0
>
>=-=
>int
>main (void)
>{
>  |
>  return 0;
>}
>=-=
>int
>main (void)
>{
>#|
>  return 0;
>}
>=-=-=
>```
>
>But that didn't run the electric indent afaict.
>
>Theo
>



  parent reply	other threads:[~2023-02-17  8:29 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-15 17:59 Missing features in c-ts-mode Eli Zaretskii
2023-02-15 18:29 ` Theodor Thornhill
2023-02-15 19:05   ` Eli Zaretskii
2023-02-15 19:18     ` Theodor Thornhill
2023-02-15 19:31       ` Theodor Thornhill
2023-02-15 19:48         ` Eli Zaretskii
2023-02-15 19:59           ` Theodor Thornhill
2023-02-16 19:14             ` Theodor Thornhill
2023-02-16 20:38               ` Eli Zaretskii
2023-02-16 21:05                 ` Theodor Thornhill
2023-02-17  8:29               ` Ergus [this message]
2023-02-17  8:42                 ` Eli Zaretskii
2023-02-17  9:56                 ` Theodor Thornhill
2023-02-17 12:20                   ` Eli Zaretskii
2023-02-17 16:37                     ` Ergus
2023-02-17 17:34                       ` Theodor Thornhill
2023-02-17 18:02                         ` Ergus
2023-02-17 18:10                           ` Theodor Thornhill
2023-02-17 18:27                             ` Ergus
2023-02-17 18:43                               ` Theodor Thornhill
2023-02-15 20:31           ` Felix
2023-02-16  7:35             ` Eli Zaretskii
2023-02-16  8:08               ` Theodor Thornhill
2023-02-16 12:10               ` Felix
2023-02-15 20:03       ` Eli Zaretskii
2023-02-15 20:21         ` Theodor Thornhill
2023-02-16  7:04           ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230217082935.waa7f473dmvbpg3d@Ergus \
    --to=spacibba@aol.com \
    --cc=casouri@gmail.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=theo@thornhill.no \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).