From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#60186: 29.0.60; ruby-mode indentation of multi-line expressions Date: Tue, 20 Dec 2022 18:19:08 +0200 Message-ID: <358bbd65-9375-04c8-f0a2-24a4383f142e@yandex.ru> References: <4e44df18-207c-c7ca-0588-7285f3008dfb@yandex.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30750"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Cc: 60186@debbugs.gnu.org To: Aaron Jensen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Dec 20 17:27:51 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 1p7fT5-0007Lt-5R for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 20 Dec 2022 17:27:51 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p7fSM-0003Vo-C8; Tue, 20 Dec 2022 11:27:06 -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 1p7fSJ-0003Ut-UR for bug-gnu-emacs@gnu.org; Tue, 20 Dec 2022 11:27:03 -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 1p7fSJ-0004LH-MM for bug-gnu-emacs@gnu.org; Tue, 20 Dec 2022 11:27:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p7fSI-0006UW-HV for bug-gnu-emacs@gnu.org; Tue, 20 Dec 2022 11:27:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 20 Dec 2022 16:27:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60186 X-GNU-PR-Package: emacs Original-Received: via spool by 60186-submit@debbugs.gnu.org id=B60186.167155360724942 (code B ref 60186); Tue, 20 Dec 2022 16:27:02 +0000 Original-Received: (at 60186) by debbugs.gnu.org; 20 Dec 2022 16:26:47 +0000 Original-Received: from localhost ([127.0.0.1]:45804 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p7fS2-0006UE-QX for submit@debbugs.gnu.org; Tue, 20 Dec 2022 11:26:47 -0500 Original-Received: from mail-wr1-f46.google.com ([209.85.221.46]:45971) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p7fRc-0006U2-UH for 60186@debbugs.gnu.org; Tue, 20 Dec 2022 11:26:45 -0500 Original-Received: by mail-wr1-f46.google.com with SMTP id h16so12214753wrz.12 for <60186@debbugs.gnu.org>; Tue, 20 Dec 2022 08:26:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=k2esmpnmGKWCjC5gbh3aacXGEDR+4/5ZSXGQ0vnmmr8=; b=L2ymhPcme/LhKWlG0YakdmpvL0Z4A6MFFvl0CpKsUL24cAHIdp1z538LwUT/JC/JH7 Gvga3XwrDzwUAsWAmn9aXnb7irsXYZM7IFY6M0EFD9GNhUKoBGj4cwMIb8tiwEpQzmMY QrwzzOWW1OBuzuBZRXovak6SW9WK6jCF5JpmGJmuiGgH1QX1E/hl28H9xoeYYF9MlbBo cYaqFz6L7szLPQOfRWvElSzn+VR1FCRfBqOQMMJj3GUkizXM1HKpz5VOKhf9MpJ2CJQ7 PyqeXYxoJxwu2xDwy6o8HO0jkjdp1SZYjTXWVsOxKdOgkvYhaAr7VjuE4QcTkdbxIlq6 5Ssg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=k2esmpnmGKWCjC5gbh3aacXGEDR+4/5ZSXGQ0vnmmr8=; b=JcIu1WZqLEPgJ81vspixETQMxS3s4+QrQV5uPKk8NOptGZRr1xh3jcoYISBlNb58zk 8OKR0fha+gphzuU/WDQn/GLzEEXo22AT9U4bMFtc7erIAvkwzhOWaR1s6Y+Pz00gX/JH Erc7Wk1kVH9jgaNf+uiSGLjdHG8AbKgCObA5u/cVdwculiV0I0/3Et/vc3C3oq6PjQhD GjKdwY/DEbWWYAW98vHysDQTB24ejFVvEmqTFqmnn7piERiJiP/GfJRTJo4j9gbQP0M2 omA/9NdpOkq9eR5oFuSxF2ry1fluyXnxPVZUQIucNxoJWBFAjP18wXuj921Szo7m1XCB iDDQ== X-Gm-Message-State: ANoB5pk5yMsUFxsyDdatebKVvVEsp0/tYIpYhPYj3YzxsV0nNfv29tP7 YVsnd5TBo+szvNeshwqaz6RdSaWo/Lc= X-Google-Smtp-Source: AA0mqf5TmwKmtyU1CyZfRtghKYH8AEN8A9ymekQPyD9gBRDBTkg3MmKratXhDqgl767niRfyUqPxaA== X-Received: by 2002:a05:600c:19c7:b0:3d0:8722:a145 with SMTP id u7-20020a05600c19c700b003d08722a145mr36032405wmq.40.1671553150682; Tue, 20 Dec 2022 08:19:10 -0800 (PST) Original-Received: from [192.168.0.2] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id n35-20020a05600c502300b003cffd3c3d6csm16402948wmr.12.2022.12.20.08.19.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 20 Dec 2022 08:19:09 -0800 (PST) Content-Language: en-US In-Reply-To: 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:251530 Archived-At: On 20/12/2022 06:48, Aaron Jensen wrote: > In all seriousness though, > >>> Current: >>> >>> some_variable = some_object. >>> some_method >>> >>> Desired: >>> >>> some_variable = some_object. >>> some_method > > This one isn't quite right, maybe there was an email formatting issue. > I'm expecting some_method to be indented by 1 level, for me it's 2: > > some_variable = some_object. > some_method Yes, that's also the "needs more work" part. >>> >>> Current: >>> >>> some_variable = some_number + some_other_number * >>> some_third_number + some_fourth_number - >>> some_fifth_number >>> >>> Desired: >>> >>> some_variable = some_number + some_other_number * >>> some_third_number + some_fourth_number - >>> some_fifth_number > > This looks good. The funny thing is this case looked more difficult originally. >> This will take some more work too. Not in the least because the >> "Desired" forms looks illogical (at least in the context of SMIE): we're >> already "escaping" the current syntax node to line the indentation of >> the block to the beginning of the statement (which makes sense, at least >> from the ergonomics POV), so why would the line break matter? > > Do you mean why are these different? > > some_variable = some_array. > map do |x| > x + 1 > end > > vs > > some_variable = some_array.map do |x| > x + 1 > end > > It's because the end is lined up with the line opened the > block/increased indentation. In the first example, the indented map > line is the beginning and on the second, it's the assignment. One might ask why it's lined up to 'map' only after it's moved to the next line, but not in the first example. Anyway, the important part is to choose an unambiguous algorithm, even if it uses its own logic. >> Take more complex cases. How much indentation will the block have after >> some heterogeneous continuations? Is this right? >> >> some_variable = 4 + >> some_array. >> reduce do |acc, x| >> acc + x >> end > > No, there is nothing that would cause reduce to be further indented. > It should be this: > > some_variable = 4 + > some_array. > reduce do |acc, x| > acc + x > end Okay, so there should be two basic cases: - Indent to the beginning of the statement, - If there was a line continuation (no matter how many), indent 1 extra level? And maybe something related to parentheses, if used.