bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#66466: [PATCH] Support lua-ts-mode in align.el


From: john muhl
Subject: bug#66466: [PATCH] Support lua-ts-mode in align.el
Date: Fri, 13 Oct 2023 21:19:48 -0500

Eshel Yaron <me@eshelyaron.com> writes:

> Hi,
>
> Stefan Kangas <stefankangas@gmail.com> writes:
>
>> john muhl via "Bug reports for GNU Emacs, the Swiss army knife of text
>> editors" <bug-gnu-emacs@gnu.org> writes:
>>
>>> Add support for using align in Lua files.
>>
>> nThanks.
>>
>>> diff --git a/lisp/align.el b/lisp/align.el
>>> index a286addb51f..e6e62ce5726 100644
>>> --- a/lisp/align.el
>>> +++ b/lisp/align.el
>>> @@ -577,7 +577,23 @@ align-rules-list
>>>                      "="
>>>                      (group (zero-or-more (syntax whitespace)))))
>>>       (group . (1 2))
>>> -     (modes . '(conf-toml-mode toml-ts-mode))))
>>> +     (modes . '(conf-toml-mode toml-ts-mode)))
>>> +
>>> +    (lua-assignment
>>> +     (regexp   . ,(concat "\\(?:^\\(?:\\s-*\\(?:local\\s-+\\)?\\(?:[,<>_]"
>>> +                          "\\|\\w\\)+\\)+\\(\\s-*\\)=\\(\\s-*\\)\\)"))
>>> +     (group    . (1 2))
>>> +     (modes    . '(lua-ts-mode))
>>> +     (tab-stop . nil))
>>> +
>>> +    (lua-comment
>>> +     (regexp   . "\\(?:\\(\\s-*\\)--.*\\)")
>>> +     (modes    . '(lua-ts-mode))
>>> +     (column   . comment-column)
>>> +     (valid    . ,(lambda ()
>>> +                    (save-excursion
>>> +                      (goto-char (match-beginning 1))
>>> +                      (not (bolp)))))))
>>
>> Should `lua-mode' also be in `modes'?
>
> Another option would be for `lua-ts-mode` to define
> `align-mode-rules-list` locally, instead of extending `align-rules-list`
> globally.
>
> Also, I noticed that we already have several similar rules for aligning
> assignments and comments in `align-rules-list`.  Do none of them work
> for Lua?

The toml-assignment rule works well enough. I added the Lua modes there
now.

> If so, I wonder what specifics of Lua's syntax make the existing rules
> inapplicable.

For comments I only see the open-comment and c++-comment rules.
open-comment doesn’t match trailing line comments. Extending c++-comment
in the obvious way (Lua uses "--" for comment start) causes trouble with
c++ code like:

  int x = 5; // declare
  x--; // decrement

Lua shares comment syntax with at least Ada, Haskell, SQL and VHDL so I
changed the name of the rule to double-dash-comment and added the Lua
modes there.

Attachment: 0001-Support-lua-ts-mode-in-align.el.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]