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