unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#69088: [PATCH] Eagerly indent first field in tables in lua-ts-mode
@ 2024-02-13  1:00 john muhl via Bug reports for GNU Emacs, the Swiss army knife of text editors
       [not found] ` <handler.69088.B.170779128814939.ack@debbugs.gnu.org>
  0 siblings, 1 reply; 5+ messages in thread
From: john muhl via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-02-13  1:00 UTC (permalink / raw)
  To: 69088

Tags: patch

lua-ts-mode supports aligning table fields to the first field so that
you can have code like:

  local t = { a = 1,
              b = 2, }

However if you prefer to put the first field on a newline like:

  local t = {
      a = 1,
      b = 2,
  }

the indentation doesn’t happen until you press RET after the first
comma. So you initially have something like (where | is point):

  local t = {
  |
  }

This patch fixes that so the initial indentation is correct from the beginning:

  local t = {
      |
  }





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#69088: [PATCH] Eagerly indent first field in tables in lua-ts-mode
       [not found] ` <handler.69088.B.170779128814939.ack@debbugs.gnu.org>
@ 2024-02-13  2:49   ` john muhl via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-02-13  3:21     ` Dmitry Gutov
  0 siblings, 1 reply; 5+ messages in thread
From: john muhl via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-02-13  2:49 UTC (permalink / raw)
  To: 69088

[-- Attachment #1: Type: text/plain, Size: 85 bytes --]

Sorry for the duplicate. I thought there had been an error while
sending initially.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Eagerly-indent-first-field-in-tables-in-lua-ts-mode.patch --]
[-- Type: text/x-patch, Size: 1123 bytes --]

From 94de38c493fdc666cd23718d879aaad08e3e6abb Mon Sep 17 00:00:00 2001
From: john muhl <jm@pub.pink>
Date: Mon, 12 Feb 2024 18:46:51 -0600
Subject: [PATCH] Eagerly indent first field in tables in lua-ts-mode

* lisp/progmodes/lua-ts-mode.el (lua-ts--simple-indent-rules):
Properly indent the first field of a table when it appears on a
line by itself.  (bug#69088)
---
 lisp/progmodes/lua-ts-mode.el | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lisp/progmodes/lua-ts-mode.el b/lisp/progmodes/lua-ts-mode.el
index dc2a8fcec1e..15256cc7903 100644
--- a/lisp/progmodes/lua-ts-mode.el
+++ b/lisp/progmodes/lua-ts-mode.el
@@ -317,6 +317,9 @@ lua-ts--simple-indent-rules
           (node-is ")")
           (node-is "}"))
       standalone-parent 0)
+     ((and (lambda (node &rest _) (null node))
+           (parent-is "table_constructor"))
+      standalone-parent lua-ts-indent-offset)
      ((or (and (parent-is "arguments") lua-ts--first-child-matcher)
           (and (parent-is "parameters") lua-ts--first-child-matcher)
           (and (parent-is "table_constructor") lua-ts--first-child-matcher))
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* bug#69088: [PATCH] Eagerly indent first field in tables in lua-ts-mode
  2024-02-13  2:49   ` john muhl via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-02-13  3:21     ` Dmitry Gutov
  2024-02-13  3:42       ` john muhl via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 5+ messages in thread
From: Dmitry Gutov @ 2024-02-13  3:21 UTC (permalink / raw)
  To: john muhl, 69088

On 13/02/2024 04:49, john muhl via Bug reports for GNU Emacs, the Swiss 
army knife of text editors wrote:
> +     ((and (lambda (node &rest _) (null node))
> +           (parent-is "table_constructor"))

That's probably the same as (match null "table_constructor")





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#69088: [PATCH] Eagerly indent first field in tables in lua-ts-mode
  2024-02-13  3:21     ` Dmitry Gutov
@ 2024-02-13  3:42       ` john muhl via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-02-17  8:58         ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: john muhl via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-02-13  3:42 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: 69088

[-- Attachment #1: Type: text/plain, Size: 352 bytes --]

Dmitry Gutov <dmitry@gutov.dev> writes:

> On 13/02/2024 04:49, john muhl via Bug reports for GNU Emacs, the
> Swiss army knife of text editors wrote:
>> +     ((and (lambda (node &rest _) (null node))
>> +           (parent-is "table_constructor"))
>
> That's probably the same as (match null "table_constructor")

Yes it is. Thanks for the pointer.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Eagerly-indent-first-field-in-tables-in-lua-ts-mode.patch --]
[-- Type: text/x-patch, Size: 1069 bytes --]

From 2ccb8aaff8c08f1cb55f66c4b556c1f8aedc4d9e Mon Sep 17 00:00:00 2001
From: john muhl <jm@pub.pink>
Date: Mon, 12 Feb 2024 18:46:51 -0600
Subject: [PATCH] Eagerly indent first field in tables in lua-ts-mode

* lisp/progmodes/lua-ts-mode.el (lua-ts--simple-indent-rules):
Properly indent the first field of a table when it appears on a
line by itself.  (bug#69088)
---
 lisp/progmodes/lua-ts-mode.el | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lisp/progmodes/lua-ts-mode.el b/lisp/progmodes/lua-ts-mode.el
index dc2a8fcec1e..c7f5ac50b04 100644
--- a/lisp/progmodes/lua-ts-mode.el
+++ b/lisp/progmodes/lua-ts-mode.el
@@ -317,6 +317,8 @@ lua-ts--simple-indent-rules
           (node-is ")")
           (node-is "}"))
       standalone-parent 0)
+     ((match null "table_constructor")
+      standalone-parent lua-ts-indent-offset)
      ((or (and (parent-is "arguments") lua-ts--first-child-matcher)
           (and (parent-is "parameters") lua-ts--first-child-matcher)
           (and (parent-is "table_constructor") lua-ts--first-child-matcher))
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* bug#69088: [PATCH] Eagerly indent first field in tables in lua-ts-mode
  2024-02-13  3:42       ` john muhl via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-02-17  8:58         ` Eli Zaretskii
  0 siblings, 0 replies; 5+ messages in thread
From: Eli Zaretskii @ 2024-02-17  8:58 UTC (permalink / raw)
  To: john muhl; +Cc: dmitry, 69088-done

> Cc: 69088@debbugs.gnu.org
> Date: Mon, 12 Feb 2024 21:42:01 -0600
> From:  john muhl via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
> 
> Dmitry Gutov <dmitry@gutov.dev> writes:
> 
> > On 13/02/2024 04:49, john muhl via Bug reports for GNU Emacs, the
> > Swiss army knife of text editors wrote:
> >> +     ((and (lambda (node &rest _) (null node))
> >> +           (parent-is "table_constructor"))
> >
> > That's probably the same as (match null "table_constructor")
> 
> Yes it is. Thanks for the pointer.

Thanks, installed on master, and closing the bug.





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-02-17  8:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-13  1:00 bug#69088: [PATCH] Eagerly indent first field in tables in lua-ts-mode john muhl via Bug reports for GNU Emacs, the Swiss army knife of text editors
     [not found] ` <handler.69088.B.170779128814939.ack@debbugs.gnu.org>
2024-02-13  2:49   ` john muhl via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-13  3:21     ` Dmitry Gutov
2024-02-13  3:42       ` john muhl via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-17  8:58         ` Eli Zaretskii

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).