@@ -752,7 +752,26 @@ Customize `gptel-directives' for task-specific prompts."
752
752
:pad-keys t])
753
753
754
754
; ; ** Prefix for selecting tools
755
+ (defun gptel--toggle-all-tools ()
756
+ " Toggle the selection state of all tools in the transient menu.
755
757
758
+ If any tool is currently selected, deselect all tools.
759
+ If no tools are selected, select all tools."
760
+ (interactive )
761
+ (let ((all-selected t )
762
+ (has-tools nil ))
763
+ ; ; Check if any tools are not selected
764
+ (dolist (suffix transient-current-suffixes)
765
+ (when (cl-typep suffix 'gptel--switch )
766
+ (setq has-tools t )
767
+ (when (null (oref suffix value))
768
+ (setq all-selected nil ))))
769
+ ; ; If we have tools but not all are selected, select all; otherwise deselect all
770
+ (when has-tools
771
+ (dolist (suffix transient-current-suffixes)
772
+ (when (cl-typep suffix 'gptel--switch )
773
+ (transient-infix-set suffix (unless all-selected (oref suffix argument))))))
774
+ (transient--redisplay)))
756
775
;;;### autoload (autoload 'gptel-tools "gptel-transient" nil t)
757
776
(transient-define-prefix gptel-tools ()
758
777
" Select tools to include with gptel requests.
@@ -785,6 +804,9 @@ only (\"oneshot\")."
785
804
(cl-delete-if-not #'consp args))
786
805
gptel--set-buffer-locally))
787
806
:transient transient--do-return)
807
+ (" a" " Toggle all tools" gptel--toggle-all-tools
808
+ :transient t )
809
+
788
810
(" q" " Cancel" transient-quit-one)]]
789
811
[:class transient-column
790
812
:setup-children
@@ -794,14 +816,14 @@ only (\"oneshot\")."
794
816
(cdr
795
817
(cl-loop ; loop through gptel--known tools and collect categories
796
818
for (category . tools-alist) in gptel--known-tools
797
- with unused-keys = (delete ?q (number-sequence ?a ?z ))
819
+ with unused-keys = (delete ?q (number-sequence ?b ?z ))
798
820
for category-key = (seq-find (lambda (k ) (member k unused-keys)) category
799
821
(seq-first unused-keys))
800
822
do (setq unused-keys (delete category-key unused-keys))
801
823
nconc
802
824
(cl-loop ; for each category, collect tools as infixes
803
825
for (name . tool) in tools-alist
804
- with tool-keys = (delete category-key (number-sequence ?a ?z ))
826
+ with tool-keys = (delete category-key (number-sequence ?b ?z ))
805
827
for tool-key = (seq-find (lambda (k ) (member k tool-keys)) name
806
828
(seq-first tool-keys))
807
829
do (setq tool-keys (delete tool-key tool-keys))
0 commit comments