Wrap regexp tool query in word boundary

This commit is contained in:
Phil Bajsicki 2025-04-17 03:01:42 +02:00
parent 87ab252815
commit 18c52fa9d7
2 changed files with 14 additions and 10 deletions

View file

@ -757,11 +757,14 @@ This means that /every org-mode file I have/ is part of this search.
***** org-ql-select-all-regexp
#+begin_src elisp
(defun gptel-org-tools--org-ql-select-all-regexp (query)
(org-ql-select
(org-agenda-files)
`(regexp ,query)
:action #'gptel-org-tools--heading-body))
(let ((bound-query (format "\\b%s\\b" (regexp-quote query))))
(org-ql-select
(org-agenda-files)
`(regexp ,bound-query)
:action #'gptel-org-tools--heading-body)))
#+end_src
#+begin_src elisp
(add-to-list 'gptel-org-tools
(gptel-make-tool
:function #'gptel-org-tools--org-ql-select-all-regexp
@ -769,7 +772,7 @@ This means that /every org-mode file I have/ is part of this search.
:description "Run regexp on ALL files at once."
:args (list '(:name "query"
:type string
:description "Regexp, Emacs Lisp format."))
:description "Regexp, Emacs Lisp format. Automatically wrapped in a word boundary by the tool."))
:category "org-ql"))
#+end_src

View file

@ -375,10 +375,11 @@
:category "org-ql"))
(defun gptel-org-tools--org-ql-select-all-regexp (query)
(org-ql-select
(org-agenda-files)
`(regexp ,query)
:action #'gptel-org-tools--heading-body))
(let ((bound-query (format "\\b%s\\b" (regexp-quote query))))
(org-ql-select
(org-agenda-files)
`(regexp ,bound-query)
:action #'gptel-org-tools--heading-body)))
(add-to-list 'gptel-org-tools
(gptel-make-tool
@ -387,7 +388,7 @@
:description "Run regexp on ALL files at once."
:args (list '(:name "query"
:type string
:description "Regexp, Emacs Lisp format."))
:description "Regexp, Emacs Lisp format. Automatically wrapped in a word boundary by the tool."))
:category "org-ql"))
(provide 'gptel-org-tools)