From: Aaron Jensen <aaronjensen@gmail.com>
To: Dmitry Gutov <dgutov@yandex.ru>
Cc: 61871@debbugs.gnu.org
Subject: bug#61871: 29.0.60; ruby-mode indentation with destructuring assignment
Date: Tue, 28 Feb 2023 15:00:33 -0500 [thread overview]
Message-ID: <CAHyO48xy5hxM6Rf+o-qZ6Lxs-H8szHBEQbaDpWx4xK+Ct9paZw@mail.gmail.com> (raw)
In-Reply-To: <2eb42d48-87d5-2bc6-88c0-20dc1910dfe8@yandex.ru>
On Tue, Feb 28, 2023 at 1:37 PM Dmitry Gutov <dgutov@yandex.ru> wrote:
>
> Hi!
>
> On 28/02/2023 18:17, Aaron Jensen wrote:
> > I found another edge case:
> >
> > foo, bar = baz.(
> > some_arg
> > )
> >
> > Should indent to:
> >
> > foo, bar = baz.(
> > some_arg
> > )
>
> Thanks for that. This one is caused by implicit syntax which it
> non-trivial for SMIE to handle. ruby-ts-mode, predictably, indents it fine.
>
> Please try this patch out:
>
> diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
> index 559b62fef54..beccb8182a7 100644
> --- a/lisp/progmodes/ruby-mode.el
> +++ b/lisp/progmodes/ruby-mode.el
> @@ -916,11 +916,14 @@ ruby-smie-rules
> (smie-indent--hanging-p))
> ruby-indent-level)))
> (`(:before . "=")
> - (save-excursion
> - (and (smie-rule-parent-p " @ ")
> - (goto-char (nth 1 (smie-indent--parent)))
> - (smie-rule-prev-p "def=")
> - (cons 'column (+ (current-column) ruby-indent-level -3)))))
> + (or
> + (save-excursion
> + (and (smie-rule-parent-p " @ ")
> + (goto-char (nth 1 (smie-indent--parent)))
> + (smie-rule-prev-p "def=")
> + (cons 'column (+ (current-column) ruby-indent-level -3))))
> + (and (smie-rule-parent-p ",")
> + (smie-rule-parent))))
> (`(:after . ,(or "?" ":"))
> (if ruby-after-operator-indent
> ruby-indent-level
This works for me for this case, thank you.
Aaron
next prev parent reply other threads:[~2023-02-28 20:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-28 16:17 bug#61871: 29.0.60; ruby-mode indentation with destructuring assignment Aaron Jensen
2023-02-28 18:37 ` Dmitry Gutov
2023-02-28 20:00 ` Aaron Jensen [this message]
2023-02-28 21:01 ` Dmitry Gutov
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=CAHyO48xy5hxM6Rf+o-qZ6Lxs-H8szHBEQbaDpWx4xK+Ct9paZw@mail.gmail.com \
--to=aaronjensen@gmail.com \
--cc=61871@debbugs.gnu.org \
--cc=dgutov@yandex.ru \
/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).