all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: 59966@debbugs.gnu.org
Subject: bug#59966: [PATCH] [Tree-sitter] Align C++ access specifiers to their enclosing class/struct/union
Date: Sun, 11 Dec 2022 16:19:13 +0100	[thread overview]
Message-ID: <m1r0x6m0i6.fsf@yahoo.es> (raw)
In-Reply-To: m1r0x6m0i6.fsf.ref@yahoo.es

[-- Attachment #1: Type: text/plain, Size: 459 bytes --]

Tags: patch


The following C++ class is indented differently in c++-mode and
c++-ts-mode:

class Sample {
public:
void sample();
private:
int a;
};

c++-mode indents it like

class Sample {
public:
  void sample();
private:
  int a;
};

c++-ts-mode indents it like

class Sample {
public:
void sample();
private:
int a;
};

I've attached a patch so that C++ classes are indented the same in
c++-mode and c++-ts-mode when the default style is used.

Thanks.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Align-C-access-specifiers-to-their-enclosing-class-s.patch --]
[-- Type: text/patch, Size: 1494 bytes --]

From b1fb292835772ed6f4da4f91fa58e84ce7582a50 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Mart=C3=ADn?= <mardani29@yahoo.es>
Date: Sun, 11 Dec 2022 15:57:43 +0100
Subject: [PATCH] Align C++ access specifiers to their enclosing
 class/struct/union

The default style in c++-mode aligns access specifiers like "private",
"public" or "protected" to their enclosing class, struct, or union.
The "ellemtel" style indents access specifiers, but this C++ style is
not supported by c++-ts-mode yet.

* lisp/progmodes/c-ts-mode.el (c-ts-mode--indent-styles): Align access
specifiers to their enclosing class/struct/union.
---
 lisp/progmodes/c-ts-mode.el | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el
index 824325d83e..5dab9879dc 100644
--- a/lisp/progmodes/c-ts-mode.el
+++ b/lisp/progmodes/c-ts-mode.el
@@ -120,6 +120,8 @@ c-ts-mode--indent-styles
            ((query "(call_expression arguments: (_) @indent)") parent c-ts-mode-indent-offset)
            ((parent-is "call_expression") parent 0)
            ((parent-is "enumerator_list") parent-bol c-ts-mode-indent-offset)
+           ,@(when (eq mode 'cpp)
+               '(((node-is "access_specifier") parent-bol 0)))
            ((parent-is "field_declaration_list") parent-bol c-ts-mode-indent-offset)
            ((parent-is "initializer_list") parent-bol c-ts-mode-indent-offset)
            ((parent-is "if_statement") parent-bol c-ts-mode-indent-offset)
-- 
2.34.1


       reply	other threads:[~2022-12-11 15:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <m1r0x6m0i6.fsf.ref@yahoo.es>
2022-12-11 15:19 ` Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2022-12-12 22:39   ` bug#59966: [PATCH] [Tree-sitter] Align C++ access specifiers to their enclosing class/struct/union Yuan Fu

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

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

  git send-email \
    --in-reply-to=m1r0x6m0i6.fsf@yahoo.es \
    --to=bug-gnu-emacs@gnu.org \
    --cc=59966@debbugs.gnu.org \
    --cc=mardani29@yahoo.es \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.