xenodium / chatgpt-shell

A multi-llm Emacs shell (ChatGPT, Claude, Gemini, Ollama, Perplexity) + editing integrations
https://lmno.lol/alvaro
GNU General Public License v3.0
867 stars 77 forks source link

Proposal to make faster savings of transcript #112

Closed gnusupport closed 1 year ago

gnusupport commented 1 year ago

I propose that you give to user to customize path to save transcript, following shall be defcustom.

(defvar shell-maker-save-path "~/")

Then that you do something like this:

(defun shell-maker-save-session-transcript ()
  "Save shell transcript to file.

Very much EXPERIMENTAL."
  (interactive)
  (unless (eq major-mode 'shell-maker-mode)
    (user-error "Not in a shell"))
  (if shell-maker--file
      (let ((content (buffer-string))
            (path shell-maker--file))
        (with-temp-buffer
          (insert content)
          (write-file path nil)))
    (when-let ((path (read-file-name "Write file: " 
                     (file-name-as-directory (or shell-maker-save-path (getenv "HOME")))
                     nil nil (format-time-string "%Y-%m-%d-%H-%M-%S-transcript.txt")))
               (content (buffer-string)))
      (with-temp-buffer
        (insert content)
        (write-file path t))
      (setq shell-maker--file path))))

where you use that custom path, and if such not exist then $HOME.

xenodium commented 1 year ago

Thanks for the proposal. Added shell-maker-transcript-default-path and shell-maker-transcript-default-filename. Skipped(getenv "HOME") to keep the current behavior (default-directory). One can still use (setq shell-maker-transcript-default-path (getenv "HOME")) if needed.

aiwebdude commented 1 year ago

I set a directory and use the default transcript.txt. If a transcript.txt exists a later C-x C-s will overwrite that file with no confirmation asked so I made a kbd-macro that adds a unix timestamp to the latest transcript.txt filename in the folder and moves that file into another 'archive' folder. :)