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

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

[nongnu] elpa/emacsql 810243e823 290/427: Remember SQLite fetch preferen


From: ELPA Syncer
Subject: [nongnu] elpa/emacsql 810243e823 290/427: Remember SQLite fetch preference in customization.
Date: Tue, 13 Dec 2022 02:59:52 -0500 (EST)

branch: elpa/emacsql
commit 810243e8230c163bc64a9a18e67a0ec9cbe60d87
Author: Christopher Wellons <wellons@nullprogram.com>
Commit: Christopher Wellons <wellons@nullprogram.com>

    Remember SQLite fetch preference in customization.
---
 emacsql-sqlite.el | 39 ++++++++++++++++++++++++++++-----------
 emacsql.el        |  4 ++++
 2 files changed, 32 insertions(+), 11 deletions(-)

diff --git a/emacsql-sqlite.el b/emacsql-sqlite.el
index 2033b44f0b..de7b9299f4 100644
--- a/emacsql-sqlite.el
+++ b/emacsql-sqlite.el
@@ -9,6 +9,13 @@
 (require 'emacsql)
 (require 'emacsql-system)
 
+(defcustom emacsql-sqlite-automatic-fetch nil
+  "If non-nil, the user will not be prompted to download the
+pre-built SQLite binary. A value of `yes' will always approve the
+download. A value of `no' will always deny the download."
+  :group 'emacsql
+  :type '(choice (const nil) (const yes) (const no)))
+
 (defvar emacsql-sqlite-executable
   (expand-file-name (format "bin/emacsql-sqlite-%s%s" (emacsql-system-tuple)
                             (if (memq system-type '(windows-nt cygwin ms-dos))
@@ -146,18 +153,28 @@ This works like `url-copy-file' but actually checks for 
errors."
   "Set executable bits on FILE's mode."
   (set-file-modes file (logior (file-modes file) #o111)))
 
-(defun emacsql-sqlite-fetch-binary ()
+(defun emacsql-sqlite-prompt ()
+  "Ask the user if it's ok to download the SQLite binary."
   (let ((query "EmacSQL binary could not be built. Fetch from the Internet?"))
-    (unless emacsql-sqlite-user-prompted
-      (let ((prompt (y-or-n-p query)))
-        (setf emacsql-sqlite-user-prompted t)
-        (when prompt
-          (let* ((file (file-name-nondirectory emacsql-sqlite-executable))
-                 (url (format "%s%s/%s"
-                              emacsql-sqlite-host emacsql-version file)))
-            (when (emacsql-sqlite-download url emacsql-sqlite-executable)
-              (emacsql-sqlite-mark-exec emacsql-sqlite-executable)
-              :success)))))))
+    (if emacsql-sqlite-automatic-fetch
+        (not (eq emacsql-sqlite-automatic-fetch 'no))
+      (unless emacsql-sqlite-user-prompted
+        (let ((result (y-or-n-p query)))
+          (setf emacsql-sqlite-user-prompted t)
+          (when result
+            (customize-save-variable 'emacsql-sqlite-automatic-fetch 'yes))
+          result)))))
+
+(defun emacsql-sqlite-fetch-binary ()
+  "Fetch the SQLite binary from remote host."
+  (let ((prompt (emacsql-sqlite-prompt)))
+    (when prompt
+      (let* ((file (file-name-nondirectory emacsql-sqlite-executable))
+             (url (format "%s%s/%s"
+                          emacsql-sqlite-host emacsql-version file)))
+        (when (emacsql-sqlite-download url emacsql-sqlite-executable)
+          (emacsql-sqlite-mark-exec emacsql-sqlite-executable)
+          :success)))))
 
 ;; Ensure the SQLite binary is available
 
diff --git a/emacsql.el b/emacsql.el
index 13de4ce32f..38964c8d07 100644
--- a/emacsql.el
+++ b/emacsql.el
@@ -72,6 +72,10 @@
 (require 'finalize)
 (require 'emacsql-compiler)
 
+(defgroup emacsql nil
+  "The EmacSQL SQL database front-end."
+  :group 'comm)
+
 (defvar emacsql-version "1.0.0")
 
 (defvar emacsql-global-timeout 30



reply via email to

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