return 类型的向前搜索和其他搜索功能是什么?
What is the return type of search-forward and likewise other search functions?
我正在尝试编写一个交互式函数,它遍历目录以搜索单词或名称以及 return 包含有效搜索结果的文件。我试图以一种非常简单的方式编写它,但我检查有效搜索结果的方式是:
(point-min)
(if(search-forward thing-to-find)
(do-thing))
每当我对此进行测试时,它只会添加无论如何都没有有效结果的目录。我是否必须自己编写搜索单词的算法?我只是需要一些指导。
I've tried reading the documentation, and it tells me nothing about the return type.
不正确。 C-hf search-forward
说:
Set point to the end of the occurrence found, and return point.
Point 是缓冲区中的一个字符位置 -- 一个整数。
参见 C-hf point
和 C-hig (elisp)Point
.
不幸的是,search-forward
的文档字符串中缺少对 NOERROR 参数的解释,您 可以 在类似的 re-search-forward
文档字符串中找到详细信息:
The optional third argument NOERROR indicates how errors are handled
when the search fails. If it is nil or omitted, emit an error; if
it is t, simply return nil and do nothing; if it is neither nil nor
t, move to the limit of search and return nil.
因此这些函数 return 成功时为整数,失败时为 return nil
(如果 NOERROR 非零)或发出错误信号。
请 M-x report-emacs-bug
报告 search-forward
的文档问题。
我正在尝试编写一个交互式函数,它遍历目录以搜索单词或名称以及 return 包含有效搜索结果的文件。我试图以一种非常简单的方式编写它,但我检查有效搜索结果的方式是:
(point-min)
(if(search-forward thing-to-find)
(do-thing))
每当我对此进行测试时,它只会添加无论如何都没有有效结果的目录。我是否必须自己编写搜索单词的算法?我只是需要一些指导。
I've tried reading the documentation, and it tells me nothing about the return type.
不正确。 C-hf search-forward
说:
Set point to the end of the occurrence found, and return point.
Point 是缓冲区中的一个字符位置 -- 一个整数。
参见 C-hf point
和 C-hig (elisp)Point
.
不幸的是,search-forward
的文档字符串中缺少对 NOERROR 参数的解释,您 可以 在类似的 re-search-forward
文档字符串中找到详细信息:
The optional third argument NOERROR indicates how errors are handled when the search fails. If it is nil or omitted, emit an error; if it is t, simply return nil and do nothing; if it is neither nil nor t, move to the limit of search and return nil.
因此这些函数 return 成功时为整数,失败时为 return nil
(如果 NOERROR 非零)或发出错误信号。
请 M-x report-emacs-bug
报告 search-forward
的文档问题。