Fix org-ql-select-tags-local-count
This commit is contained in:
parent
d6332967c8
commit
a4b1d094f4
2 changed files with 23 additions and 21 deletions
23
README.org
23
README.org
|
@ -248,10 +248,11 @@ The rationale behind using ~list-buffers~ is the same as with dired. They both d
|
|||
|
||||
Seems to be one of the most reliable tools in the basket... mostly because
|
||||
#+begin_src elisp
|
||||
(defun gptel-org-tool--list-buffers ()
|
||||
(defun gptel-org-tool--list-buffers (&optional arg)
|
||||
(list-buffers-noselect)
|
||||
(with-temp-buffer "*Buffer List*"
|
||||
(buffer-string)))
|
||||
(let ((content (buffer-string)))
|
||||
content)))
|
||||
|
||||
(add-to-list 'gptel-org-tools
|
||||
(gptel-make-tool
|
||||
|
@ -502,7 +503,7 @@ Currently *not* tangled, as I'm testing breaking out each type of query into its
|
|||
:description "Run org-ql-select against buffer with query. Using filename fails."
|
||||
:args (list '(:name "buffer"
|
||||
:type string
|
||||
:description "The name of the buffer. Can be multiple buffers. See the NAME column in `emacs-list-buffers`.")
|
||||
:description "The name of the buffer. Can be multiple buffers. See the NAME column in `list-buffers`.")
|
||||
'(:name "query"
|
||||
:type string
|
||||
:description "The query to pass into org-ql-select. See org-ql documentation for syntax. Usually `(tags \"tag1\" \"tag2\")` is sufficient. Possible predicates: `tags` (finds both local and inherited tags), `tags-local` (finds only local tags), `rifle` (matches against both heading and body text). This is a sexp, not a string."))
|
||||
|
@ -628,7 +629,7 @@ Retrieve the headings where the heading matches query..
|
|||
:description "Retreive matching headings from buffer. Matches only a single string. Using filename fails."
|
||||
:args (list '(:name "buffer"
|
||||
:type string
|
||||
:description "The name of the buffer. See the NAME column in ~emacs-list-buffers~.")
|
||||
:description "The name of the buffer. See the NAME column in ~list-buffers~.")
|
||||
'(:name "query"
|
||||
:type string
|
||||
:description "The string to match entry headings against."))
|
||||
|
@ -652,7 +653,7 @@ Retrieve all the headings where either heading or content matches query.
|
|||
:description "Retreive headings from buffer using org-ql-select. Matches against both heading and content. Using filename fails."
|
||||
:args (list '(:name "buffer"
|
||||
:type string
|
||||
:description "The name of the buffer. See the NAME column in ~emacs-list-buffers~.")
|
||||
:description "The name of the buffer. See the NAME column in ~list-buffers~.")
|
||||
'(:name "query"
|
||||
:type string
|
||||
:description "The string to match entry headings against."))
|
||||
|
@ -676,7 +677,7 @@ This pulls all the headings (and their contents) when they match tags (without i
|
|||
:description "Run org-ql-select-tags-local against buffer with query. No tag inheritance."
|
||||
:args (list '(:name "buffer"
|
||||
:type string
|
||||
:description "The name of the buffer. See the NAME column in `emacs-list-buffers`. Using filename fails.")
|
||||
:description "The name of the buffer. See the NAME column in `list-buffers`. Using filename fails.")
|
||||
'(:name "query"
|
||||
:type string
|
||||
:description "The string match entry tags against."))
|
||||
|
@ -686,7 +687,7 @@ This pulls all the headings (and their contents) when they match tags (without i
|
|||
***** org-ql-select-tags-local-count
|
||||
This pulls all the local tags (without inheritance) from buffer, and returns the number of these tagged headings.
|
||||
#+begin_src elisp
|
||||
(defun gptel-org-tools--org-ql-select-tags-local (buf query)
|
||||
(defun gptel-org-tools--org-ql-select-tags-local-count (buf query)
|
||||
(length (org-ql-select
|
||||
(get-buffer buf)
|
||||
`(tags-local ,query)
|
||||
|
@ -695,12 +696,12 @@ This pulls all the local tags (without inheritance) from buffer, and returns the
|
|||
|
||||
(add-to-list 'gptel-org-tools
|
||||
(gptel-make-tool
|
||||
:function #'gptel-org-tools--org-ql-select-tags-local
|
||||
:function #'gptel-org-tools--org-ql-select-tags-local-count
|
||||
:name "gptel-org-tools--org-ql-select-tags-local"
|
||||
:description "Get count of matching tags from buffer. No tag inheritance."
|
||||
:args (list '(:name "buffer"
|
||||
:type string
|
||||
:description "The name of the buffer. See the NAME column in `emacs-list-buffers`. Using filename fails.")
|
||||
:description "The name of the buffer. See the NAME column in `list-buffers`. Using filename fails.")
|
||||
'(:name "query"
|
||||
:type string
|
||||
:description "The string match entry tags against."))
|
||||
|
@ -723,7 +724,7 @@ This pulls all the headings (and their contents) when they match tags (with inhe
|
|||
:description "Run org-ql-select-tags against buffer with query. Supports tag inheritance."
|
||||
:args (list '(:name "buffer"
|
||||
:type string
|
||||
:description "The name of the buffer. See the NAME column in `emacs-list-buffers`. Using filename fails.")
|
||||
:description "The name of the buffer. See the NAME column in `list-buffers`. Using filename fails.")
|
||||
'(:name "query"
|
||||
:type string
|
||||
:description "The string to match entry headings against."))
|
||||
|
@ -749,7 +750,7 @@ And, the "grab everything that matches" tool.
|
|||
:description "Run org-ql-select-rifle against buffer with query."
|
||||
:args (list '(:name "buffer"
|
||||
:type string
|
||||
:description "The name of the buffer. See the NAME column in `emacs-list-buffers`. Using filename fails.")
|
||||
:description "The name of the buffer. See the NAME column in `list-buffers`. Using filename fails.")
|
||||
'(:name "query"
|
||||
:type string
|
||||
:description "A single string to search for."))
|
||||
|
|
|
@ -61,10 +61,11 @@
|
|||
(org-end-of-subtree))
|
||||
"---\n"))
|
||||
|
||||
(defun gptel-org-tool--list-buffers ()
|
||||
(defun gptel-org-tool--list-buffers (&optional arg)
|
||||
(list-buffers-noselect)
|
||||
(with-temp-buffer "*Buffer List*"
|
||||
(buffer-string)))
|
||||
(let ((content (buffer-string)))
|
||||
content)))
|
||||
|
||||
(add-to-list 'gptel-org-tools
|
||||
(gptel-make-tool
|
||||
|
@ -245,7 +246,7 @@ DATE is the date or date range to match."
|
|||
:description "Retreive matching headings from buffer. Matches only a single string. Using filename fails."
|
||||
:args (list '(:name "buffer"
|
||||
:type string
|
||||
:description "The name of the buffer. See the NAME column in ~emacs-list-buffers~.")
|
||||
:description "The name of the buffer. See the NAME column in ~list-buffers~.")
|
||||
'(:name "query"
|
||||
:type string
|
||||
:description "The string to match entry headings against."))
|
||||
|
@ -265,7 +266,7 @@ DATE is the date or date range to match."
|
|||
:description "Retreive headings from buffer using org-ql-select. Matches against both heading and content. Using filename fails."
|
||||
:args (list '(:name "buffer"
|
||||
:type string
|
||||
:description "The name of the buffer. See the NAME column in ~emacs-list-buffers~.")
|
||||
:description "The name of the buffer. See the NAME column in ~list-buffers~.")
|
||||
'(:name "query"
|
||||
:type string
|
||||
:description "The string to match entry headings against."))
|
||||
|
@ -285,13 +286,13 @@ DATE is the date or date range to match."
|
|||
:description "Run org-ql-select-tags-local against buffer with query. No tag inheritance."
|
||||
:args (list '(:name "buffer"
|
||||
:type string
|
||||
:description "The name of the buffer. See the NAME column in `emacs-list-buffers`. Using filename fails.")
|
||||
:description "The name of the buffer. See the NAME column in `list-buffers`. Using filename fails.")
|
||||
'(:name "query"
|
||||
:type string
|
||||
:description "The string match entry tags against."))
|
||||
:category "org-ql"))
|
||||
|
||||
(defun gptel-org-tools--org-ql-select-tags-local (buf query)
|
||||
(defun gptel-org-tools--org-ql-select-tags-local-count (buf query)
|
||||
(length (org-ql-select
|
||||
(get-buffer buf)
|
||||
`(tags-local ,query)
|
||||
|
@ -300,12 +301,12 @@ DATE is the date or date range to match."
|
|||
|
||||
(add-to-list 'gptel-org-tools
|
||||
(gptel-make-tool
|
||||
:function #'gptel-org-tools--org-ql-select-tags-local
|
||||
:function #'gptel-org-tools--org-ql-select-tags-local-count
|
||||
:name "gptel-org-tools--org-ql-select-tags-local"
|
||||
:description "Get count of matching tags from buffer. No tag inheritance."
|
||||
:args (list '(:name "buffer"
|
||||
:type string
|
||||
:description "The name of the buffer. See the NAME column in `emacs-list-buffers`. Using filename fails.")
|
||||
:description "The name of the buffer. See the NAME column in `list-buffers`. Using filename fails.")
|
||||
'(:name "query"
|
||||
:type string
|
||||
:description "The string match entry tags against."))
|
||||
|
@ -324,7 +325,7 @@ DATE is the date or date range to match."
|
|||
:description "Run org-ql-select-tags against buffer with query. Supports tag inheritance."
|
||||
:args (list '(:name "buffer"
|
||||
:type string
|
||||
:description "The name of the buffer. See the NAME column in `emacs-list-buffers`. Using filename fails.")
|
||||
:description "The name of the buffer. See the NAME column in `list-buffers`. Using filename fails.")
|
||||
'(:name "query"
|
||||
:type string
|
||||
:description "The string to match entry headings against."))
|
||||
|
@ -346,7 +347,7 @@ DATE is the date or date range to match."
|
|||
:description "Run org-ql-select-rifle against buffer with query."
|
||||
:args (list '(:name "buffer"
|
||||
:type string
|
||||
:description "The name of the buffer. See the NAME column in `emacs-list-buffers`. Using filename fails.")
|
||||
:description "The name of the buffer. See the NAME column in `list-buffers`. Using filename fails.")
|
||||
'(:name "query"
|
||||
:type string
|
||||
:description "A single string to search for."))
|
||||
|
|
Loading…
Add table
Reference in a new issue