自然语言中的Emacs abbrev模式

自然语言中的Emacs abbrev模式,emacs,autocomplete,code-completion,abbreviation,ispell,Emacs,Autocomplete,Code Completion,Abbreviation,Ispell,当我写散文或只是做笔记时,我经常在Emacs中使用abbrev模式。如果有任何方法可以定义特定语言的缩写,那就太好了,例如,如果我在英文文本中写“proj”,它将扩展到“project”,而如果我在瑞典文本中写,它将扩展到“projekt”。同样,“riskfac”在英语中扩展为“risk factor”,但在瑞典语中扩展为“riskfaktor”。如何做到这一点 如果能够将它与当前使用的ispell字典相结合,那将特别好。我知道有不同的abbrev表,但这些表是特定于模式的,而不是特定于语言的

当我写散文或只是做笔记时,我经常在Emacs中使用abbrev模式。如果有任何方法可以定义特定语言的缩写,那就太好了,例如,如果我在英文文本中写“proj”,它将扩展到“project”,而如果我在瑞典文本中写,它将扩展到“projekt”。同样,“riskfac”在英语中扩展为“risk factor”,但在瑞典语中扩展为“riskfaktor”。如何做到这一点

如果能够将它与当前使用的ispell字典相结合,那将特别好。我知道有不同的abbrev表,但这些表是特定于模式的,而不是特定于语言的


这里有什么想法吗?

对于自由文本,我倾向于使用pabbrev.el(我写的!),但现在还有其他几个软件包可以做同样的事情——根据您已经写的内容动态扩展缩写。在实践中,这往往会给语言带来一定程度的特殊性


否则,我认为您需要在不同的缓冲区中切换abbrev表。如果您正在使用输入法,也许您可以将其与输入法挂钩,这样Emacs就会知道您使用的是哪种语言。

考虑尝试
(标准库
completion.el

您可以在不同的动态完成文件之间进行更改,每种语言一个。选项
save completions file name
保存文件名,但没有任何说明您不能动态更改其值,例如使用命令在多组完成项之间切换。(当然,这样的命令应该先保存到一个文件,然后再切换到另一个文件。)

动态完成模式的“doc”位于库
completion.el的
注释中。这个图书馆很旧,但仍然很有用。摘自
评论

This watches all the words that you type and remembers them.  When
typing a new word, pressing "complete" (meta-return) "completes" the
word by inserting the most recently used word that begins with the
same characters.  If you press meta-return repeatedly, it cycles
through all the words it knows about.

If you like the completion then just continue typing, it is as if you
entered the text by hand.  If you want the inserted extra characters
to go away, type control-w or delete.  More options are described below.

The guesses are made in the order of the most recently "used".  Typing
in a word and then typing a separator character (such as a space) "uses"
the word.  So does moving a cursor over the word.  If no words are found,
it uses an extended version of the dabbrev style completion.
(另见。)