3

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

如果可以将其与当前使用的 ispell-dictionary 结合起来,那就太好了。我知道有不同的缩写表,但这些是特定于模式的,而不是语言。

这里有什么想法吗?

4

2 回答 2

0

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

否则,我认为您需要一些东西来切换不同缓冲区中的缩写表。如果您正在使用输入法,也许您可​​以将其挂接到输入法中,然后 Emacs 就会知道您使用的是哪种语言。

于 2015-01-25T19:58:55.990 回答
0

考虑尝试dynamic-completion-mode(标准库completion.el)。

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

的“doc”dynamic-completion-modeCommentarylibrarycompletion.el中。图书馆很旧,但仍然很有用,恕我直言。摘自Commentary

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.

(另见冰柱完成dynamic-completion-mode。)

于 2015-01-26T01:19:53.247 回答