gpt4 book ai didi

regex - “字符串匹配”在 'org-map-entries' 中不起作用

转载 作者:行者123 更新时间:2023-12-04 15:00:02 24 4
gpt4 key购买 nike

我正在尝试映射文件中的所有 org 条目并收集部分标题(如果它与某些正则表达式匹配)。

问题是字符串匹配总是返回 nil。当我逐步使用 edebug 时,我可以看到其他一切都正常工作。

在这里,我尽我所能减少了这个问题:

(defun test ()
(let ((found nil))
(org-map-entries (lambda ()
(let ((heading (org-get-heading t t)))
(when (string-match "[ \t]*>>>[ \t]*\\([A-Z0-9_-]+\\)"
heading)
(push (match-string 1 heading) found))))

nil '("test.org"))
found))

test.org 中的 3 行:
* >>> one
* two
* >>> three

否则字符串匹配工作正常:
(string-match "[ \t]*>>>[ \t]*\\([A-Z0-9_-]+\\)" ">>> one")
=> 0

我尝试过的一些事情:
- 在匹配之前删除字符串属性。
- 改为围绕重新搜索进行实现。
- 将正则表达式匹配移动到单独的函数。
- 将 'org-map-entries' 替换为 'mapcar' 并在列表中进行测试,效果很好。

我正在使用 GNU Emacs 24.3.1(x86_64-unknown-linux-gnu,GTK+ 版本 3.4.2)

任何提示将不胜感激。

最佳答案

我从一开始就得到了正确的结果。
Emacs 24.3.4。组织模式版本 8.0.6。
您应该更新您的设置。

关于regex - “字符串匹配”在 'org-map-entries' 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17902012/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com