Skip to content

[Feature (not a request)] Consult chatgpt-buffer #335

Open
@gggion

Description

@gggion

Just figured I would put here this consult function for chatgpt-shell buffers I've been using,
it uses the process name to fetch all the chatgpt-shell buffers so no need to pattern match buffer names in case they're renamed (previously used llm to fetch them).

Im using doom emacs so no idea if it'll work for everyone.

(require 'consult)

(defgroup consult-chatgpt-shell-buffers nil
  "Navigate between LLM conversation buffers."
  :group 'convenience
  :prefix "consult-chatgpt-shell-buffers-")


;;;###autoload
(defun consult-chatgpt-shell-buffers ()
  "Choose an LLM conversation buffer from a Consult menu.
Lists buffers that have a process with 'chatgpt' in the name."
  (interactive)
  (let* ((llm-buffers
          (cl-loop for proc in (process-list)
                   ;; Check if process name contains "chatgpt"
                   when (and (string-match-p "chatgpt" (process-name proc))
                             (process-buffer proc)
                             (buffer-live-p (process-buffer proc)))
                   collect (process-buffer proc)))
         (selected-buffer
          (consult--read
           (mapcar #'buffer-name llm-buffers)
           :prompt "Select an LLM buffer: "
           :category 'buffer
           :sort nil
           :require-match t
           :state (consult--buffer-state))))
    (when selected-buffer
      (switch-to-buffer selected-buffer))))

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions