不一致的Mx对齐,正则表达式对铜的Mx对齐,正则表达式的行为正则表达式、行为、Mx

2023-09-12 21:25:52 作者:柠檬味的小仙女

我试着写了Emacs的一些新的对齐规则,发现这个奇怪的和不一致的行为。当前缓冲区的内容:

I've tried to write some new align rules for emacs and found this strange and inconsistent behaviour. Current buffer contents:

"some thing" like => this
   hello => world
and => again

在打字M-xalign-regexpRET[[:lower:]]+\(\s-+\)=>RET结果看起来期望:

After typing M-xalign-regexpRET[[:lower:]]+\(\s-+\)=>RET result looks as desired:

"some thing" like => this
             hello => world
             and => again

但经过C-uM-xalign-regexpRET[[:lower:]]+\(\s-+\)=>RET1RET1RETyRET我得到这个代替:

"some thing" like => this
   hello          => world
and               => again

同样的(错误的)事情发生,如果我把这个变成对齐-规则列表。如何解决这一问题?我想要得到的结果类似第一。

The same (wrong) thing happens if I put this into align-rules-list. How to fix this? I want to get the results like first.

推荐答案

有趣的问题。

当您运行的命令的在Emacs,记住互动形式 你pre-加工参数。

When you run commands in Emacs, keep in mind that interactive forms are pre-processing arguments for you.

要看看的功能的最终接收,preSS CX ESC ESC

To see what the function finally receives, press C-x ESC ESC

在这种情况下,您将在前者的情况看:

In this case, you'll see in the former case:

(align-regexp 1 57 "\\(\\s-*\\)[[:lower:]]+\\(\\s-+\\)=>" 1 1 nil)

和这个在后一

(align-regexp 1 57 "[[:lower:]]+\\(\\s-+\\)=>" 1 1 t)