all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Yuan Fu <casouri@gmail.com>
To: 63879@debbugs.gnu.org
Cc: dev@rjt.dev
Subject: bug#63879: 29.0.90; [PATCH] Fix rust-ts-mode indentation for else-if
Date: Sat, 3 Jun 2023 16:18:47 -0700	[thread overview]
Message-ID: <21517EA2-5B9E-4F48-AA23-8D3EAC543F0A@gmail.com> (raw)

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

X-Debbugs-CC: dev@rjt.dev

Example:

fn main() {
    if true {
        ()
    } else if true {
            ()
        }
}


Yuan


[-- Attachment #2: rust-ts-mode.patch --]
[-- Type: application/octet-stream, Size: 2081 bytes --]

From d412e7d597d15a94b6725e231f392518138cc550 Mon Sep 17 00:00:00 2001
From: Yuan Fu <casouri@gmail.com>
Date: Sat, 3 Jun 2023 16:13:05 -0700
Subject: [PATCH] Fix rust-ts-mode indentation for else-if

This change fixes the indentation for code like this:

fn main() {
    if true {
        ()
    } else if true {
        ()
    }
}

Before this change, the else-if's are indented one more level than it
should, because it's nested in the if node:

fn main() {
    if true {
        ()
    } else if true {
            ()
        }
}

* lisp/progmodes/rust-ts-mode.el (rust-ts-mode--indent-rules): Replace
parent-bol with standalone-parent.
---
 lisp/progmodes/rust-ts-mode.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/progmodes/rust-ts-mode.el b/lisp/progmodes/rust-ts-mode.el
index be06acde3e3..ca295212640 100644
--- a/lisp/progmodes/rust-ts-mode.el
+++ b/lisp/progmodes/rust-ts-mode.el
@@ -74,7 +74,7 @@ rust-ts-mode--indent-rules
      ((parent-is "source_file") column-0 0)
      ((node-is ")") parent-bol 0)
      ((node-is "]") parent-bol 0)
-     ((node-is "}") (and parent parent-bol) 0)
+     ((node-is "}") (and parent standalone-parent) 0)
      ((and (parent-is "comment") c-ts-common-looking-at-star)
       c-ts-common-comment-start-after-first-star -1)
      ((parent-is "comment") prev-adaptive-prefix 0)
@@ -82,7 +82,7 @@ rust-ts-mode--indent-rules
      ((parent-is "await_expression") parent-bol rust-ts-mode-indent-offset)
      ((parent-is "array_expression") parent-bol rust-ts-mode-indent-offset)
      ((parent-is "binary_expression") parent-bol rust-ts-mode-indent-offset)
-     ((parent-is "block") parent-bol rust-ts-mode-indent-offset)
+     ((parent-is "block") standalone-parent rust-ts-mode-indent-offset)
      ((parent-is "declaration_list") parent-bol rust-ts-mode-indent-offset)
      ((parent-is "enum_variant_list") parent-bol rust-ts-mode-indent-offset)
      ((parent-is "field_declaration_list") parent-bol rust-ts-mode-indent-offset)
-- 
2.33.1


             reply	other threads:[~2023-06-03 23:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-03 23:18 Yuan Fu [this message]
2023-06-03 23:58 ` bug#63879: 29.0.90; [PATCH] Fix rust-ts-mode indentation for else-if Randy Taylor
2023-06-04  5:12   ` Eli Zaretskii
2023-06-05  7:43     ` 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=21517EA2-5B9E-4F48-AA23-8D3EAC543F0A@gmail.com \
    --to=casouri@gmail.com \
    --cc=63879@debbugs.gnu.org \
    --cc=dev@rjt.dev \
    /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.