From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Andrey Listopadov Newsgroups: gmane.emacs.bugs Subject: bug#66159: 30.0.50; lua-ts-mode semantic indentation problems Date: Tue, 26 Sep 2023 22:21:35 +0300 Message-ID: <87lecs4ttm.fsf@gmail.com> References: <87fs36vvxl.fsf@gmail.com> <87v8bz3905.fsf@pub.pink> <878r8vwm9v.fsf@gmail.com> <87il7z5g3g.fsf@pub.pink> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16671"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.8.11; emacs 30.0.50 Cc: 66159@debbugs.gnu.org, Philip Kaludercic , Eli Zaretskii To: john muhl Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Sep 26 21:30:17 2023 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 1qlDlA-00048D-Js for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 26 Sep 2023 21:30:17 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlDkn-0002Ss-AN; Tue, 26 Sep 2023 15:29:53 -0400 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 1qlDkl-0002QW-Gz for bug-gnu-emacs@gnu.org; Tue, 26 Sep 2023 15:29:51 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qlDki-0003OK-S1 for bug-gnu-emacs@gnu.org; Tue, 26 Sep 2023 15:29:50 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qlDkv-0000f8-PH for bug-gnu-emacs@gnu.org; Tue, 26 Sep 2023 15:30:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Andrey Listopadov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 26 Sep 2023 19:30:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66159 X-GNU-PR-Package: emacs Original-Received: via spool by 66159-submit@debbugs.gnu.org id=B66159.16957565732476 (code B ref 66159); Tue, 26 Sep 2023 19:30:01 +0000 Original-Received: (at 66159) by debbugs.gnu.org; 26 Sep 2023 19:29:33 +0000 Original-Received: from localhost ([127.0.0.1]:49767 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qlDkT-0000ds-5C for submit@debbugs.gnu.org; Tue, 26 Sep 2023 15:29:33 -0400 Original-Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]:56830) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qlDkR-0000da-K1 for 66159@debbugs.gnu.org; Tue, 26 Sep 2023 15:29:32 -0400 Original-Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-9ad8d47ef2fso1159951366b.1 for <66159@debbugs.gnu.org>; Tue, 26 Sep 2023 12:29:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695756552; x=1696361352; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:message-id:in-reply-to:date :subject:cc:to:from:user-agent:references:from:to:cc:subject:date :message-id:reply-to; bh=aJrx3I8J/q+QAG+iF8Rnr3tLFQ84+2qEOf6dmLKP5DM=; b=FwRs64D4TpiICBOPOpVlzVZ8olWaPkJ/xzaC5GiIyxxAJ/KqOJPdW1ajnQuoU2+BIC gfZ+uPLckoju+RKP9xkL7UITc50YpcqwaGnCAzDlCzGDE+s/1E5rDVGzdJ/PjlPsbcW2 KZm5bdBxXjIFwgQ/duABbgKUj+1B7uEcQLXHskai8wHOCy8D24Mwoy5w+2hkyjVIiRAt L3hDnd5vNPPoPYvrFRuymWSv9SYXrKiA/vC9XvcxaTb6I7WUL+b39MBLxKgfih/+pJ5A Cext0Tnqjr99Yzfqu0VlaWHHpzjPgsli4goU/vMzdzl9CALEH3wvEal1cXQZHKc22RQX YMKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695756552; x=1696361352; h=content-transfer-encoding:mime-version:message-id:in-reply-to:date :subject:cc:to:from:user-agent:references:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=aJrx3I8J/q+QAG+iF8Rnr3tLFQ84+2qEOf6dmLKP5DM=; b=a58/2lvuDxODquinrxZAutCIcr/65crvg+ZqyVPTE95DAEPFkq7m0rTdKxdn2URa+8 dOanmILs3mM9iTxwGpeHmDoNt/7uwkaZVq5OlnUcAOqy+xWQsAdp7Flc6CpaDuWwDMB1 C87B9cVT8ryhtfKSUDIfA57L/d0YOrmzTz7yWj2YzQQXQC+A0jLOxlIC09Gd+2hBpmdp 6mi3sAwMwryukb1JcxK5qWNS2yRdXW6ILrMNgMBE6RPucQOGG/SAJg0LxwWtWIU+Tkwf /gB+xRMHegQwD5oZnfDBgwJk0xrrvR57K/AeO2f8Sdav6BIgHF2hCax+wJ6gu4ORqIdc uNOA== X-Gm-Message-State: AOJu0Ywa1FqW1Vz29T3nWv7u3QU5c7l2atJS+9wG7LbgsmM29hcwjNdo wZM3BWvlGrGa5KxT5ZpXGSY= X-Google-Smtp-Source: AGHT+IHafGMoyW7szzuMW/S2diMu3iGgveiscM+07/JXzQV8F8AFtIVQzmw6aexK+xnic8HQYMXlYw== X-Received: by 2002:a17:907:77c7:b0:9ad:e180:16e3 with SMTP id kz7-20020a17090777c700b009ade18016e3mr8543152ejc.37.1695756552261; Tue, 26 Sep 2023 12:29:12 -0700 (PDT) Original-Received: from toolbox.smtp.gmail.com (broadband-90-154-71-4.ip.moscow.rt.ru. [90.154.71.4]) by smtp.gmail.com with ESMTPSA id mh2-20020a170906eb8200b0099cc3c7ace2sm8228745ejb.140.2023.09.26.12.29.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 12:29:11 -0700 (PDT) In-reply-to: <87il7z5g3g.fsf@pub.pink> 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:271390 Archived-At: john muhl writes: > Eli Zaretskii writes: > >>> > Another thing that bothers me is that I prefer Gassanenko-style packi= ng >>> > of `end' keywords so that they vertically align with the scope of the >>> > opened block, as it saves so much vertical space and is easier for me= to >>> > read, but lua-ts-mode moves it to the latest innermost indentation >>> > level, as opposed to the outermost depending on the count of ends in = the >>> > line itself: >>> >>> I don't see any reason not to support that style but I'm not sure how to >>> do it. A patch would be welcome but I'll try to figure it out sometime. >> >> Maybe introduce indentation styles into lua-ts-mode, like CC Mode and >> c-ts-mode have? > > I=E2=80=99ll have a look at what the c-ts-mode styles do and see what mig= ht be > applicable. In this case the changes can be accommodated by default. In my opinion, this isn't distinct enough to introduce a new style. But it's up to you to decide, of course - I'm all for better editing experience for Lua! >> A far as I understand it, in the `lua-mode' the overall line indentation >> is computed via subtracting indentation for every `end' in that line, >> e.g. `end end end' subtracts `lua-indent-level three times from current >> indent level. > > Thanks for the explanation. The attached patch should make end packing > work now. I've tried your latest patch and indeed `end' now pack themselves as in the lua-mode. Thank you very much! >>> Sure. It's a new mode so nothing is really set in stone. Let me know if >>> you have other suggestions. I noticed that the `do' keyword is indented similarly to `then' before the patch when put on the new line: for i=3D1,10 do print(i) end I'm not sure if that's a proper way to indent it or not though, but `do' usually signifies start of the scope, so perhaps it shouldn't be indented in this case. There are also some weirdness in semantic navigation, but it's more likely that I'm just not used to new ts-backed navigation yet. Thanks for your work on lua-ts-mode, it's much more snappy editing experience now! If you're willing to dig into some (pretty crazy) involved examples, I can send here some really convoluted nested anonymous functions that currently are indented in a weird way in both modes. Neither does it exactly right in my opiion, but I also don't know if there is the right way to indent this. I can send these examples later this week once I finish an article I'm working on rightnow. -- Andrey Listopadov