File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -278,6 +278,31 @@ LIMIT specifies the maximum number of lines to return."
278278 (selected-lines (seq-subseq lines start end)))
279279 (string-join selected-lines " \n " ))))
280280
281+ (llm-tool-collection-deftool edit-buffer
282+ (:category " buffers" )
283+ ((buffer-name " Name of the buffer to modify" :type string)
284+ (old-string " Text to replace (must match exactly)" :type string)
285+ (new-string " Text to replace old_string with" :type string))
286+ " Edits Emacs buffers"
287+ (with-current-buffer buffer-name
288+ (let ((case-fold-search nil ))
289+ (save-excursion
290+ (goto-char (point-min ))
291+ (let ((count 0 ))
292+ (while (search-forward old-string nil t )
293+ (setq count (1+ count)))
294+ (if (= count 0 )
295+ (format
296+ " Error: Could not find text to replace in buffer %s" buffer-name)
297+ (if (> count 1 )
298+ (format
299+ " Error: Found %d matches for the text to replace in buffer %s"
300+ count buffer-name)
301+ (goto-char (point-min ))
302+ (search-forward old-string)
303+ (replace-match new-string t t )
304+ (format " Successfully edited buffer %s " buffer-name))))))))
305+
281306(provide 'llm-tool-collection )
282307
283308; ;; llm-tool-collection.el ends here
You can’t perform that action at this time.
0 commit comments