emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/gptel 95925f3571 198/273: Automatically create parent dire


From: ELPA Syncer
Subject: [nongnu] elpa/gptel 95925f3571 198/273: Automatically create parent directories for gptel-crowdsourced-prompts-file (#203)
Date: Wed, 1 May 2024 10:02:22 -0400 (EDT)

branch: elpa/gptel
commit 95925f3571bbb2f3f800be37fa8a3a7998d1ecb4
Author: Ihor Radchenko <yantar92@posteo.net>
Commit: GitHub <noreply@github.com>

    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.
---
 gptel-transient.el | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/gptel-transient.el b/gptel-transient.el
index 4fcfa1ba63..0f4dc5763b 100644
--- a/gptel-transient.el
+++ b/gptel-transient.el
@@ -78,11 +78,13 @@ which see."
                 "?"))
           ;; Fetch file
           (message "Fetching prompts...")
-          (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."))))
+          (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.")))))
       (if (not (file-readable-p gptel-crowdsourced-prompts-file))
           (progn (message "No crowdsourced prompts available")
                  (call-interactively #'gptel-system-prompt))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]