Eshel Yaron writes: > Hi, > > Stefan Kangas writes: > >> john muhl via "Bug reports for GNU Emacs, the Swiss army knife of text >> editors" 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.