如何正确包装涉及键绑定的 Elisp 文档字符串?

问题描述

Emacs Lisp一个工具可以使文档适应用户当前的键绑定,通过在文档字符串中引用命令名称并让 Emacs 在用户请求文档时动态插入该命令的当前键绑定。但是,当我在提到许多键绑定的文档字符串中使用它时,它完全弄乱了换行符。从我的包中拿这个例子:

(substitute-command-keys
 "Fix ido behavior when `require-match' is non-nil.

Standard ido will allow
\\<ido-common-completion-map>\\[ido-select-text] to exit with an
incomplete completion even when `require-match' is non-nil.
Ordinary completion does not allow this. In ordinary completion,\\[ido-exit-minibuffer] on an incomplete match is equivalent to
\\[ido-complete],and \\[ido-select-text] selects the first
match. Since \\[ido-exit-minibuffer] in ido already selects the
first match,this advice sets up \\[ido-select-text] to be
equivalent to \\[ido-complete] in the same situation.

This advice only activates if the current ido completion was
called through ido-cr+.")

使用标准绑定,显示用户的文档字符串如下所示:

Fix ido behavior when ‘require-match’ is non-nil.

Standard ido will allow
C-j to exit with an
incomplete completion even when ‘require-match’ is non-nil.
Ordinary completion does not allow this. In ordinary completion,RET on an incomplete match is equivalent to
TAB,and C-j selects the first
match. Since RET in ido already selects the
first match,this advice sets up C-j to be
equivalent to TAB in the same situation.

This advice only activates if the current ido completion was
called through ido-cr+.

由于中间段落中行长的随机变化,这看起来很残暴且难以阅读。下面是它实际的样子:

Fix ido behavior when ‘require-match’ is non-nil.

Standard ido will allow C-j to exit with an incomplete completion
even when ‘require-match’ is non-nil. Ordinary completion does
not allow this. In ordinary completion,RET on an incomplete
match is equivalent to TAB,and C-j selects the first match.
Since RET in ido already selects the first match,this advice
sets up C-j to be equivalent to TAB in the same situation.

This advice only activates if the current ido completion was
called through ido-cr+.

显然,问题在于 substitute-command-keys 识别的特殊序列的长度与替换它们的字符串的长度不同,这会导致我的源代码中的行换行。在运行 substitute-command-keys 之后和向用户显示之前,是否有某种方法可以强制 emacs 重新计算我的文档字符串中的段落换行?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)