From: Dmitry Gutov <dgutov@yandex.ru>
To: Aaron Jensen <aaronjensen@gmail.com>
Cc: 60321@debbugs.gnu.org
Subject: bug#60321: 29.0.60; ruby-mode indentation of hash or array as first arg in multiline method call
Date: Mon, 2 Sep 2024 03:19:40 +0300 [thread overview]
Message-ID: <d880fdb3-2917-4de4-bfe3-6234740ece2c@yandex.ru> (raw)
In-Reply-To: <CAHyO48weB=pikRT9wv9UcPo3_mpyMouCJW6OTtVusLKwFk+hXA@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1619 bytes --]
On 01/09/2024 22:28, Aaron Jensen wrote:
> Here's a corrected patch for that particular example. Thank you for
> finding that. I think I missed it because as long as you type the code
> in, it indents fine. I still have a lot to understand about SMIE, so if
> anything looks off in my patch, please let me know.
Thanks! Just being thorough. We can add this example to the args-indent
test file, too.
Here's a bonus example which looks off but would be more difficult to
fix (and it's not urgent, given the expression is in mixed styles):
foo([{
a: 2
},
{
b: 3
},
4
])
It would be nice to at least handle the last arg correctly - maybe we'll
just get that supported in the ts mode at some later date.
> I didn't change the default. I wasn't sure if you wanted to change the
> defaults of all of the variables you added in the last round or just
> this one, so I'll let you handle that the way you want to.
Sure. I think we can add this into Emacs 30 too, while the change is off
by default.
A few other things:
* I think the docstring should say "Set it to nil to align to the line
with the open bracket" - it doesn't necessarily align to the beginning
of the statement (seems like a good thing).
* Let's change the first example to this, for less ambiguity?
foo
.update({
key => value,
other_key:
}, {
key => value,
other_key:
})
* Support for the new option in ruby-ts-mode (it's good to have parity).
Could you take the attached patch for a spin? Seems to work here, but
I'd like to have an extra confirmation.
[-- Attachment #2: ruby-ts-bracketed-argument-indentation-option.diff --]
[-- Type: text/x-patch, Size: 1499 bytes --]
diff --git a/lisp/progmodes/ruby-ts-mode.el b/lisp/progmodes/ruby-ts-mode.el
index 5f4e11e0b4c..adcdf15c7ad 100644
--- a/lisp/progmodes/ruby-ts-mode.el
+++ b/lisp/progmodes/ruby-ts-mode.el
@@ -842,6 +842,16 @@ ruby-ts--parent-call-or-bol
;; No paren/curly/brace found on the same line.
((< (treesit-node-start found) parent-bol)
parent-bol)
+ ;; Nesting of brackets args.
+ ((and
+ (not (eq ruby-bracketed-args-indent t))
+ (string-match-p "\\`array\\|hash\\'" (treesit-node-type parent))
+ (equal (treesit-node-parent parent) found)
+ ;; Grandparent is not a parenless call.
+ (or (not (equal (treesit-node-type found) "argument_list"))
+ (equal (treesit-node-type (treesit-node-child found 0))
+ "(")))
+ parent-bol)
;; Hash or array opener on the same line.
((string-match-p "\\`array\\|hash\\'" (treesit-node-type found))
(save-excursion
diff --git a/test/lisp/progmodes/ruby-ts-mode-tests.el b/test/lisp/progmodes/ruby-ts-mode-tests.el
index 61ef80eb610..05d98974acf 100644
--- a/test/lisp/progmodes/ruby-ts-mode-tests.el
+++ b/test/lisp/progmodes/ruby-ts-mode-tests.el
@@ -326,6 +326,7 @@ "ruby-block-indent.rb"
(ruby-ts-deftest-indent "ruby-method-call-indent.rb")
(ruby-ts-deftest-indent "ruby-method-params-indent.rb")
(ruby-ts-deftest-indent "ruby-parenless-call-arguments-indent.rb")
+(ruby-ts-deftest-indent "ruby-bracketed-args-indent.rb")
(provide 'ruby-ts-mode-tests)
next prev parent reply other threads:[~2024-09-02 0:19 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-19 2:54 bug#60186: 29.0.60; ruby-mode indentation of multi-line expressions Aaron Jensen
2022-12-20 2:12 ` Dmitry Gutov
2022-12-20 2:17 ` Dmitry Gutov
2022-12-20 4:48 ` Aaron Jensen
2022-12-20 5:56 ` Aaron Jensen
2022-12-20 15:53 ` Dmitry Gutov
2022-12-20 16:19 ` Dmitry Gutov
2022-12-20 17:31 ` Dmitry Gutov
2022-12-21 1:34 ` Aaron Jensen
2022-12-20 20:05 ` Aaron Jensen
2022-12-21 22:48 ` Dmitry Gutov
2022-12-22 2:31 ` Aaron Jensen
2022-12-22 21:21 ` Dmitry Gutov
2022-12-23 4:12 ` Aaron Jensen
2022-12-23 22:26 ` Dmitry Gutov
2022-12-24 0:17 ` Aaron Jensen
2022-12-24 22:47 ` Dmitry Gutov
2022-12-25 0:12 ` Aaron Jensen
2022-12-25 21:23 ` Dmitry Gutov
2022-12-25 21:29 ` bug#60321: 29.0.60; ruby-mode indentation of hash or array as first arg in multiline method call Dmitry Gutov
2022-12-25 23:46 ` Aaron Jensen
2022-12-27 1:16 ` Dmitry Gutov
2022-12-27 1:38 ` Aaron Jensen
2024-08-31 23:41 ` Aaron Jensen
2024-09-01 0:54 ` Aaron Jensen
2024-09-01 16:36 ` Dmitry Gutov
2024-09-01 19:28 ` Aaron Jensen
2024-09-02 0:19 ` Dmitry Gutov [this message]
2024-09-02 0:49 ` Aaron Jensen
2024-09-02 1:10 ` Dmitry Gutov
2024-09-02 1:56 ` Aaron Jensen
2024-09-02 19:01 ` Dmitry Gutov
2024-09-02 19:21 ` Aaron Jensen
2022-12-25 0:14 ` bug#60186: 29.0.60; ruby-mode indentation of multi-line expressions Aaron Jensen
2022-12-25 21:29 ` Dmitry Gutov
2022-12-27 1:28 ` Dmitry Gutov
2022-12-27 1:47 ` Aaron Jensen
2022-12-27 15:56 ` Dmitry Gutov
2022-12-27 16:34 ` Aaron Jensen
2022-12-27 23:04 ` Dmitry Gutov
2022-12-28 0:38 ` Aaron Jensen
2022-12-28 1:02 ` Dmitry Gutov
2022-12-28 3:47 ` Aaron Jensen
2022-12-28 12:47 ` Dmitry Gutov
2022-12-28 21:24 ` Dmitry Gutov
2022-12-29 22:59 ` Aaron Jensen
2022-12-30 15:02 ` Dmitry Gutov
2022-12-30 18:00 ` Aaron Jensen
2022-12-30 18:16 ` Aaron Jensen
2022-12-30 22:07 ` Dmitry Gutov
2022-12-31 1:11 ` Aaron Jensen
2023-01-22 3:02 ` Dmitry Gutov
2023-01-22 5:15 ` Aaron Jensen
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=d880fdb3-2917-4de4-bfe3-6234740ece2c@yandex.ru \
--to=dgutov@yandex.ru \
--cc=60321@debbugs.gnu.org \
--cc=aaronjensen@gmail.com \
/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).