[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/emacsql c634a1b6e1 340/427: Use initialize-instance with e
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/emacsql c634a1b6e1 340/427: Use initialize-instance with emacsql-sqlite (fixes #17). |
Date: |
Tue, 13 Dec 2022 03:00:00 -0500 (EST) |
branch: elpa/emacsql
commit c634a1b6e106e64c5ee179350f10234ad7dfcec6
Author: Christopher Wellons <wellons@nullprogram.com>
Commit: Christopher Wellons <wellons@nullprogram.com>
Use initialize-instance with emacsql-sqlite (fixes #17).
This allows classes to properly inherit from emacsql-sqlite-connection,
since it will configure itself.
---
emacsql-sqlite.el | 27 ++++++++++++++++-----------
1 file changed, 16 insertions(+), 11 deletions(-)
diff --git a/emacsql-sqlite.el b/emacsql-sqlite.el
index 8e089a865f..b881db114b 100644
--- a/emacsql-sqlite.el
+++ b/emacsql-sqlite.el
@@ -88,31 +88,36 @@ http://www.sqlite.org/lang_keywords.html")
(nil nil))))
(:documentation "A connection to a SQLite database."))
-(cl-defun emacsql-sqlite (file &key debug)
- "Open a connected to database stored in FILE.
-If FILE is nil use an in-memory database.
-
-:debug LOG -- When non-nil, log all SQLite commands to a log
-buffer. This is for debugging purposes."
+(defmethod initialize-instance :after
+ ((connection emacsql-sqlite-connection) &key)
(emacsql-sqlite-ensure-binary)
(let* ((process-connection-type nil) ; use a pipe
(coding-system-for-write 'utf-8-auto)
(coding-system-for-read 'utf-8-auto)
+ (file (slot-value connection 'file))
(buffer (generate-new-buffer " *emacsql-sqlite*"))
(fullfile (if file (expand-file-name file) ":memory:"))
(process (start-process
- "emacsql-sqlite" buffer emacsql-sqlite-executable fullfile))
- (connection (make-instance 'emacsql-sqlite-connection
- :process process
- :file (when file fullfile))))
+ "emacsql-sqlite" buffer emacsql-sqlite-executable
fullfile)))
+ (setf (slot-value connection 'process) process)
(setf (process-sentinel process)
(lambda (proc _) (kill-buffer (process-buffer proc))))
(emacsql-wait connection)
(emacsql connection [:pragma (= busy-timeout $s1)]
(/ (* emacsql-global-timeout 1000) 2))
- (when debug (emacsql-enable-debugging connection))
(emacsql-register connection)))
+(cl-defun emacsql-sqlite (file &key debug)
+ "Open a connected to database stored in FILE.
+If FILE is nil use an in-memory database.
+
+:debug LOG -- When non-nil, log all SQLite commands to a log
+buffer. This is for debugging purposes."
+ (let ((connection (make-instance 'emacsql-sqlite-connection :file file)))
+ (when debug
+ (emacsql-enable-debugging connection))
+ connection))
+
(defmethod emacsql-close ((connection emacsql-sqlite-connection))
"Gracefully exits the SQLite subprocess."
(let ((process (emacsql-process connection)))
- [nongnu] elpa/emacsql 4a58806d64 299/427: Improve new indentation a little bit., (continued)
- [nongnu] elpa/emacsql 4a58806d64 299/427: Improve new indentation a little bit., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql c512f4287c 315/427: Add back-end note to README., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql a0587f1b5f 311/427: Fix docstring on emacsql-enable-debugging., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 9cf4e267cc 310/427: Bump up to version 1.0.2., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql fd73d37df8 319/427: Ignore the generated executable, ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 048e81b759 320/427: Add file tests/.nosearch, ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 017cd8460d 329/427: Use own data root in emacsql-sqlite., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 03d4788708 332/427: Bump to version 2.0.0 (fix #15)., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 0a2b3f6496 337/427: Follow rename of emacsql-with-vars in doc-strings., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql a60deae960 335/427: Add NOTNULL and ISNULL special operators (#16)., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql c634a1b6e1 340/427: Use initialize-instance with emacsql-sqlite (fixes #17).,
ELPA Syncer <=
- [nongnu] elpa/emacsql 176cf10063 342/427: Bump to 2.0.1., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 95a00de3f1 346/427: Save match-data around call to accept-process-output, ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 8f3d0d4b81 344/427: Use font-lock-flush and font-lock-ensure if available, ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 3176aeee61 345/427: Use elisp--preceding-sexp if available, ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 327b09b4b9 348/427: Add support for raw strings and raw parameters (#26, #28)., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql c93f52159f 347/427: Bump to version 2.0.2., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql e91bac3a20 350/427: Add cl-generic require to emacsql.el (#32)., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql b65c5b03d5 351/427: Fix up Cask file., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql e3bc9b105f 354/427: Finish removing Cask, including updating the README, ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 83a278aa6b 356/427: Remove trailing &key in method definition, ELPA Syncer, 2022/12/13