1

我发现了这个关于多词缩写的邮件列表消息,但仍然无法扩展工作。

我定义了这两个缩写:

"agw"          0    "a great whale"
"a g w"         0    "a great whale"

在“agw”之后按空格有效,但不是“ag w”。但是,如果我调用 (abbrev-expansion "a g w"),则返回正确的扩展。

问题是如何让 Emacs 向后搜索超出一个单词边界?

是的,yasnippet 存在并且我使用它,但是缩写更加无缝(例如,“1/2”之后的按空格将其变成 unicode 一半)。我也不想更改语法表。

4

2 回答 2

0

SPACE,在插入自身之前,会在点之前寻找一个缩写来展开。它使用'backward-word',它将在前一个空格处停止。因此 SPACE 不能扩展缩写内的空格。

于 2013-01-22T17:36:54.417 回答
0

As explained by Andreas, it does not work because by default abbrevs only work if they are made up of chars that are "word constituent" and " " is not a word constituent. You can change this rule, tho, for a given table, with something like (abbrev-table-put <table> :regexp <regexp>) where a regexp like "\\<\\(\\w+:?\\)\\W*" would pretty much reproduce the default behavior.

Now for your case, you want a regexp that will match "a g w" and "agw" but note that it shouldn't match the "agw" of "dawg" and neither should it match "a g agw", which makes it a bit tricky. One way to do that is to define your regexp as (concat "\\<" (regexp-opt '("agw" "a g w")) "\\W*"), which is fairly simple to do but has the downside that it requires changing the regexp any time you add an abbrev.

于 2013-03-01T14:18:43.137 回答