From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Aaron Jensen Newsgroups: gmane.emacs.bugs Subject: bug#60321: 29.0.60; ruby-mode indentation of hash or array as first arg in multiline method call Date: Sun, 25 Dec 2022 18:46:07 -0500 Message-ID: References: <4e44df18-207c-c7ca-0588-7285f3008dfb@yandex.ru> <358bbd65-9375-04c8-f0a2-24a4383f142e@yandex.ru> <2b4a91e1-bad1-382f-dd64-abf171efb404@yandex.ru> <60e207e0-7378-ad9f-3ef0-99df1c139939@yandex.ru> <902440c7-706a-20e1-55af-4e12e8cdda2c@yandex.ru> <1191195d-1528-dc2a-64e0-15426e4b5608@yandex.ru> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32435"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 60321@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Dec 26 00:47:29 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1p9aiH-0008CH-0Q for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 26 Dec 2022 00:47:29 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p9ahy-0000Cm-I8; Sun, 25 Dec 2022 18:47:10 -0500 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 1p9ahx-0000Ca-2k for bug-gnu-emacs@gnu.org; Sun, 25 Dec 2022 18:47:09 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p9ahq-0002qC-D2 for bug-gnu-emacs@gnu.org; Sun, 25 Dec 2022 18:47:08 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p9ahq-0000yR-3t for bug-gnu-emacs@gnu.org; Sun, 25 Dec 2022 18:47:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Aaron Jensen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 25 Dec 2022 23:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60321 X-GNU-PR-Package: emacs Original-Received: via spool by 60321-submit@debbugs.gnu.org id=B60321.16720119863668 (code B ref 60321); Sun, 25 Dec 2022 23:47:02 +0000 Original-Received: (at 60321) by debbugs.gnu.org; 25 Dec 2022 23:46:26 +0000 Original-Received: from localhost ([127.0.0.1]:50358 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p9ahG-0000x5-1c for submit@debbugs.gnu.org; Sun, 25 Dec 2022 18:46:26 -0500 Original-Received: from mail-pl1-f171.google.com ([209.85.214.171]:41716) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p9ahE-0000wr-On for 60321@debbugs.gnu.org; Sun, 25 Dec 2022 18:46:25 -0500 Original-Received: by mail-pl1-f171.google.com with SMTP id jl4so3250198plb.8 for <60321@debbugs.gnu.org>; Sun, 25 Dec 2022 15:46:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=smI/z2zLCYnUj31j5QxB0AfnM3u0kc3TmMdJlt2tX1g=; b=Wubt8IYYYN5HWSXj90/jdm2eEtLjlnDfFSdqO+TLIf73xZIkKwJN+ZZfjC1DUUJCYa 2MftOAPywFggs9UwiYcBzbbkAg3Vnlb47fMbzlLZvRyiUjgtvqlQCq24/NCc/ZkmJDud NOKbhAsUPP+trT6ULD2Pfe7ozUPN6Vf/LtL7g0qCoLqr1M7p5gccSYxmOmFa6V21ILbD 5Ff6ReG+zByP33V5RP6n59PjMOcqZjusJgGKk+KCGv5AJHMmrYyAgmKQ7+FTE00vO1zL yW2FJKpP8jZi/a9LWOaCr8Bmx+NVykmLqDRE/cZQZwtbrAOcK0FWcJ3StuOmTCixBWDr Z0rQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=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=smI/z2zLCYnUj31j5QxB0AfnM3u0kc3TmMdJlt2tX1g=; b=UF6vBOz6WDfiewHojnxhncJ4iwayyDwwCvsbGq7ngFQE0Wf1q6EQDPM7H1viYrmmxO atJtyLhWlNf8mjTm11hu+xe0hR1gjQ5Sb/OUvTGLhgJ9lxhDJuqkKL7HzH74Ujm2HFsK G0dR/muCeB9XizelDQJE7ZK1osp3rfXay7dYzMq00co9S2W9Yo/VKAVHMvythfpljxHC wUEEN+S5yqvqGwf8kKaoWWJOXKjySlqY1gs7GezeG5YvIjLOiwsGPF5tCzZgEegi6gdg E4c7lSw1dAwtlb4mCf+8ZDJor9ajRNnAlJOfIBjqCx4pJ5c6fnbq2Qm1fdvYDb/IhCnc 380A== X-Gm-Message-State: AFqh2koE33lzknUi7ZT2U/l0EUlIfTlgKwqfLqg3H88BbferzSMLSGgt g2ioSRiOkgyViWk2voUcFwiVQU93DHSL6KIx048= X-Google-Smtp-Source: AMrXdXtT118kMALEMT5qyAmI0IvVUUlmOfHVOCh30aysOYzF/Mcu/M9HDZXPVvs9ZpjJY3nROgZcSaoNURdRG9R1Bcw= X-Received: by 2002:a17:90b:d8a:b0:223:f336:1519 with SMTP id bg10-20020a17090b0d8a00b00223f3361519mr1288524pjb.198.1672011978822; Sun, 25 Dec 2022 15:46:18 -0800 (PST) In-Reply-To: <1191195d-1528-dc2a-64e0-15426e4b5608@yandex.ru> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:251880 Archived-At: On Sun, Dec 25, 2022 at 4:30 PM Dmitry Gutov wrote: > > X-Debbugs-CC: aaronjensen@gmail.com > > Splitting off from debbugs#60186, second try. > > Since this setting also seems orthogonal to the "simplified" preference, > and it'll require some more work. > > For future reference, here are the relevant Rubocop settings: > > https://docs.rubocop.org/rubocop/cops_layout.html#layoutfirsthashelementindentation > https://docs.rubocop.org/rubocop/cops_layout.html#layoutfirstarrayelementindentation > > On 25/12/2022 02:12, Aaron Jensen wrote: > >> We could also discuss cases like > >> > >> foo = bar({ > >> tee: 1, > >> qux: 2 > >> }) > >> > >> baz([ > >> 1, > >> 2, > >> 3 > >> ]) > >> > >> but those would be an orthogonal feature. And I don't see them much in > >> the wild, for some reason. > > The same logic would apply. It doesn't matter how many indent starters > > there are in a line, the indentation should only increase by one: > > > > > > foo = bar({ > > tee: 1, > > qux: 2 > > }) > > > > baz([ > > 1, > > 2, > > 3 > > ]) > > > > Of course, that begs the question what happens if you do this: > > > > baz([ > > 1, > > 2, > > 3 > > ] > > ) > > Here are a couple trickier examples: > > takes_multi_pairs_hash(x: { > a: 1, > b: 2 > }) enh-ruby-mode and vim do the same thing, which I think is fine: takes_multi_pairs_hash(x: { a: 1, b: 2 }) Though again, the best answer imo is "don't do this". > > and_in_a_method_call({ > no: :difference > }, > foo, > bar) enh-ruby-mode: and_in_a_method_call({ no: :difference }, foo, bar) Vim: and_in_a_method_call({ no: :difference }, foo, bar) I think this falls under something I wouldn't put too much effort into fixing. I would write it like this: and_in_a_method_call( { no: :difference }, foo, bar ) Which indents in a straightforward manner. If I had to type it as above, I would probably indent it like this: and_in_a_method_call({ no: :difference }, foo, bar) But I can't imagine that would be easy to implement at all, so I wouldn't bother. > AFAICT even Rubocop doesn't have a setting which would indent the second > one somewhat reasonably, while keeping two-space indent before "no". > > > And, I think again, the answer is a social one, rather than a technical one. > > > > enh-ruby-mode and vim both do this this: > > > > baz([ > > 1, > > 2, > > 3 > > ] > > ) > > Yup, that looks pretty bizarre. OTOH, I don't see why a developer would > put a newline between "]" and ")" in this case. Exactly, that's what I meant by a social problem. We have a (somewhat harsh) saying for stuff like this: you get what you deserve. That's actually why I don't mind enh-ruby-mode's behavior here. It's clearly undefined/out of bounds, so that tells a person they are currently out of bounds and they should get back in bounds. Aaron