【发布时间】:2021-05-26 01:36:45
【问题描述】:
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 重新计算包含在我的文档字符串中的段落?
【问题讨论】:
标签: formatting keyboard-shortcuts documentation elisp