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:
parent
a61fda4661
commit
95925f3571
1 changed files with 7 additions and 5 deletions
|
@ -78,11 +78,13 @@ which see."
|
||||||
"?"))
|
"?"))
|
||||||
;; Fetch file
|
;; Fetch file
|
||||||
(message "Fetching prompts...")
|
(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
|
(if (url-copy-file gptel--crowdsourced-prompts-url
|
||||||
gptel-crowdsourced-prompts-file
|
gptel-crowdsourced-prompts-file
|
||||||
'ok-if-already-exists)
|
'ok-if-already-exists)
|
||||||
(message "Fetching prompts... done.")
|
(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))
|
(if (not (file-readable-p gptel-crowdsourced-prompts-file))
|
||||||
(progn (message "No crowdsourced prompts available")
|
(progn (message "No crowdsourced prompts available")
|
||||||
(call-interactively #'gptel-system-prompt))
|
(call-interactively #'gptel-system-prompt))
|
||||||
|
|
Loading…
Add table
Reference in a new issue