12

我在 Windows 7 上使用 Emacs v24.3。我正在尝试学习如何重新映射键绑定。

我在我的主目录中创建了一个 .emacs 文件,它包含一行:

 (global-set-key (kbd "C-f") 'isearch-forward)

我用 runemacs.exe 启动 Emacs。我找到一个不存在的文件,键入一些单词(单击文本开头)并键入C-F以查找。提示显示,I-search:我可以逐步搜索文本。到此为止吧。

问题是,如果假设行为与默认isearch-forward击键相同C-s,则不是。当我再次键入C-f以搜索字符串的下一次出现时,唯一发生的事情是I-search提示出现在 minibuffer 中。

我无法搜索字符串的下一次出现。此外,Del假设该键在相反方向上重复搜索。当我使用搜索时,这不会发生在我身上C-f(尽管当我使用C-s. 搜索时它会发生)。

所以这个单键映射似乎打破了两件事。我映射错了吗?还是这些错误?如果我映射错误,如何映射C-fisearch-forward命令?

4

2 回答 2

16

除了你的一行,添加:

(define-key isearch-mode-map "\C-f" 'isearch-repeat-forward)

问题是 isearch 有自己的绑定,一旦您开始增量搜索,这些绑定就会处于活动状态。添加上面的表达式会重新映射isearch-repeat-forward.

如果您对这些绑定感到好奇,可以C-h b在进行增量搜索时输入以检查完整的键盘映射。

于 2013-08-10T01:08:30.970 回答
0

不,我不认为教程这么说。我认为您指的是SEARCHING部分和此文本:

>> Type C-s again, to search for the next occurrence of "cursor".
>> Now type `<DEL>` four times and see how the cursor moves.

If you are in the middle of an incremental search and type <DEL>, the
search "retreats" to an earlier location.  If you type <DEL> just
after you had typed C-s to advance to the next occurrence of a search
string, the <DEL> moves the cursor back to an earlier occurrence.  If
there are no earlier occurrences, the `<DEL>` erases the last character
in the search string.  For instance, suppose you have typed "c", to
search for the first occurrence of "c".  Now if you type "u", the
cursor will move to the first occurrence of "cu".  Now type <DEL>.
This erases the "u" from the search string, and the cursor moves back
to the first occurrence of "c".

A<DEL>不向后搜索。它从搜索字符串中删除一个字符,然后搜索移动到结果字符串的前一个命中(仅)。但第一个<DEL>afterC-s不会改变搜索字符串。它只是移动到上一个命中(仅)。

教程文本并没有错,尽管它可能有点难以阅读。如果你有改进它的建议,或者只是想让 Emacs Dev 知道你发现它不清楚,请使用M-x report-emacs-bug.

于 2013-08-10T17:45:44.013 回答