From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Newsgroups: gmane.emacs.devel Subject: Re: c-ts-mode Date: Fri, 8 Sep 2023 13:38:58 +0100 Message-ID: References: <5F73CB5D-DB00-439F-AD7C-7E209EC83A35@gmail.com> <83jzt2z5mk.fsf@gnu.org> <83y1hhykni.fsf@gnu.org> <877cp1lvih.fsf@gmail.com> <83v8clyhqi.fsf@gnu.org> <83tts5ygv2.fsf@gnu.org> <83msxxxkc0.fsf@gnu.org> <871qf9ktxd.fsf@gmail.com> <838r9gykia.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9389"; mail-complaints-to="usenet@ciao.gmane.io" Cc: theo@thornhill.no, casouri@gmail.com, spacibba@aol.com, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Sep 08 14:40:14 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qeamT-0002Gd-Sj for ged-emacs-devel@m.gmane-mx.org; Fri, 08 Sep 2023 14:40:13 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeala-0006JF-K5; Fri, 08 Sep 2023 08:39:18 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qealY-0006Hu-8V for emacs-devel@gnu.org; Fri, 08 Sep 2023 08:39:16 -0400 Original-Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qealU-00033v-UF; Fri, 08 Sep 2023 08:39:16 -0400 Original-Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-5029e4bfa22so811681e87.3; Fri, 08 Sep 2023 05:39:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694176750; x=1694781550; darn=gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=QVbVOnmCUQop1lzRlXINIYH1r+uZKO88CnPrype3jVE=; b=p4NoO5XvW60VRWCqWncXHrxqmdor4oqyiT+5GmJMCkAOnojAsn59zfOWTOlLPhq40i Lud0F/3q6Q+qTgIId185hblbRDI+loT1FxJRbyQZ5+3Q32x80fw4n7mw8Zqv9uocxqQW E9JOYxG7wKz4Gp8VB5nllVDv2w9W85DT6sDYSCKshbGxfhr7cquK3rEplKk91mgKa2UT 7Jy5WTpfbSIjY9tnLu4UtioQz8+wGEtf7f3H7o1uwkK/VqQmn86CW/4WbKli+idzEHpP vLRxX5XuGW2By+0js2kQJ2e9uXufTHC6gQYQPYdnL2qbwaSIWw6/nPV9anWiGmAxSxD7 8VSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694176750; x=1694781550; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QVbVOnmCUQop1lzRlXINIYH1r+uZKO88CnPrype3jVE=; b=raZVswX3Pund4poWzEodeWy5sc4m8Kh3J4HxvLLiFrjeYFp2i/+wWjkmkFOpY9J1ar P7gwpzbhGaJTzCLN93/vAXNextzqQ43XJbPFFZoMmM9fzR4EM/BdHKPfbbnjRwSVzmSl ZF7oGWSLNqlaDOlxM6zxB3PEhbQA7TtCq6tvPiC+BWj59lpruYr+vwa4zWTKFblEuKDQ PCxqA6nYoIrq4u4zn/LIM3XqwycbBdTeYnLzxczaW9GaMPAYwYJBQtKGGrngNH/tORC6 eUisA69mEbGrMgCtOJhiXutWH54mctFaD6OKzSq3Bch+amKtXuFvDhS/+8InjSWj9kDA 3hCQ== X-Gm-Message-State: AOJu0YzQrfNxH7PN1RhMLX/DNKp4NbcF34NKXM8xnrlojzVxQGPz7hnC uzePlv0nYOBlGQspFFwHa7Fap+AkuXm/XRSW5MkdYUGwUrJ7jQ== X-Google-Smtp-Source: AGHT+IHrAVu2F9Y2KL2Ynqs42puIcksEbZ9f+Um4+jWa6RxvRevKGp6uYIIHitgBwcUAIdN6NgrZtnzW8MlEitWJqqc= X-Received: by 2002:a05:6512:3d09:b0:4f8:5635:2cd8 with SMTP id d9-20020a0565123d0900b004f856352cd8mr2440847lfv.32.1694176750285; Fri, 08 Sep 2023 05:39:10 -0700 (PDT) In-Reply-To: <838r9gykia.fsf@gnu.org> Received-SPF: pass client-ip=2a00:1450:4864:20::133; envelope-from=joaotavora@gmail.com; helo=mail-lf1-x133.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, FREEMAIL_REPLY=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:310325 Archived-At: On Fri, Sep 8, 2023 at 12:26=E2=80=AFPM Eli Zaretskii wrote: > > > From: Jo=C3=A3o T=C3=A1vora > > Cc: Theodor Thornhill , casouri@gmail.com, > > spacibba@aol.com, emacs-devel@gnu.org > > Date: Fri, 08 Sep 2023 08:25:50 +0100 > > > > > What I had in mind was a simple alist, like CC Mode uses, with an > > > infrastructure function to install it. Patches are welcome. > > > > It would certainly work for me, at least for my very simple case, and I > > would be happy for this. Not sure it is half as powerful, for example > > how would you make that simple alist express cases where you want to ad= d > > the rules _after_ the base set? > > How does CC Mode support this (if it does)? No idea, I don't know CC Mode's styling interface well beyond the trivial example I showed. It does seems like CC Mode have different mechanics? Maybe order doesn't matter there? > Anything beyond that is, of course, welcome, but it is > less important from my POV. Sure makes sense. As I said I'm just conjecturing someone will need that flexibility because rule ordering is a fundamental part of the mechanics in TS and I don't think we abstract it away. But personally, for those ridiculous two rules, I didn't need it at all, adding at the front was just fine Anyway, it's worth pointing out that unless you're extremely adept at crafting indentation styles for Emacs, you're always in a losing battle when working on multiple projects, since many projects nowadays (not just C/C++) use an external format definition. A .clang-format (even we have one since 2017) or other similar files. These are understood by other editors and tools. Maybe in the past CC Mode's styles were very useful, but I don't think they attract the same interest today because there are these external tools. For the same reason, I don't predict ts indentation styles to become widely used. Of course, this is a big annoyance, because there always multiple competing sources of indentation rules. Emacs TAB use one thing, everyone else uses something else. Personally I've not been fighting this, i.e. I gave up. I use Emacs indentation rules to more or less align the file with the rules and then make sure to run the tool (maybe via eglot-format) before committing. It'd be great if I could rely on indent-region or C-M-q to produce the canonical indentation like I do in Lisp modes, but I can't. A more promising solution to this whole problem would be to somehow bring these external formatter's rules to meet Emacs's idea of "just indent these lines". I tried to do that with Eglot (and Theo helped out) via indent-region-function but we alas it didn't work very well, because -- at least for clangd -- the LSP formatter (which delegates to clang-format under the hood) has a tendency to add and remove newlines even if you ask it to stay within the same line. So basic things like indenting an empty line is essentially impossible. Jo=C3=A3o