Automatically create parent directories for gptel-crowdsourced-prompts-file (#203)

* gptel-transient.el (gptel--crowdsourced-prompts): Create containing
directory for `gptel-crowdsourced-prompts-file' if necessary.

Fixes #202.
This commit is contained in:
Ihor Radchenko 2024-02-03 01:24:13 +01:00 committed by GitHub
parent a61fda4661
commit 95925f3571
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -78,11 +78,13 @@ which see."
"?"))
;; Fetch file
(message "Fetching prompts...")
(let ((dir (file-name-directory gptel-crowdsourced-prompts-file)))
(unless (file-exists-p dir) (mkdir dir 'create-parents))
(if (url-copy-file gptel--crowdsourced-prompts-url
gptel-crowdsourced-prompts-file
'ok-if-already-exists)
(message "Fetching prompts... done.")
(message "Could not retrieve new prompts."))))
(message "Could not retrieve new prompts.")))))
(if (not (file-readable-p gptel-crowdsourced-prompts-file))
(progn (message "No crowdsourced prompts available")
(call-interactively #'gptel-system-prompt))