微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决如何正确包装涉及键绑定的 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 举报,一经查实,本站将立刻删除。