I am using Emacs with a recent version of lua-mode
(20200921.1745, commit 345ebfc1e236d9676e7e9f7364493785e7756348) installed with list-packages
).
The function align-current
is not working as in C mode
. How to make it work properly?
Expected:
local Var1 = 1
local Var_2 = 2
local Var_33 = 3
> Call M-x align-current
local Var1 = 1
local Var_2 = 2
local Var_33 = 3
Result: No change at all
local Var1 = 1
local Var_2 = 2
local Var_33 = 3
> Call M-x align-current
local Var1 = 1
local Var_2 = 2
local Var_33 = 3
After some research, I finally wrote a solution based on Align regexp from emacs lisp and Inconsistent Mx align-regexp vs. Cu Mx align-regexp behaviour :
It's probably not idiomatic, as I assume that there should be a way to change the behavior of align-current
in lua-mode
, to make it work as c-mode
, but I have no idea how to do that. So this solution is probably just a work-around.
(defun lua-align-current ()
(interactive)
(save-excursion
(mark-paragraph)
(align-regexp (point) (mark) "\\(\\s-*\\)=" 1 1 nil)))
The key-point was this comment: https://stackoverflow.com/a/14587077/10953006
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.