[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#66466: [PATCH] Support lua-ts-mode in align.el
From: |
Eshel Yaron |
Subject: |
bug#66466: [PATCH] Support lua-ts-mode in align.el |
Date: |
Thu, 12 Oct 2023 10:36:23 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
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? If so, I wonder what specifics of Lua's syntax make the
existing rules inapplicable. Maybe one of the existing rules can be
extended instead.
Best,
Eshel