[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/emacsql 13cfbeeaba 186/427: Tidy up the constructors.
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/emacsql 13cfbeeaba 186/427: Tidy up the constructors. |
Date: |
Tue, 13 Dec 2022 02:59:40 -0500 (EST) |
branch: elpa/emacsql
commit 13cfbeeaba9462a9a111a3293cf6fddf1939a9bd
Author: Christopher Wellons <wellons@nullprogram.com>
Commit: Christopher Wellons <wellons@nullprogram.com>
Tidy up the constructors.
---
emacsql-psql.el | 33 ++++++++++++++++-----------------
emacsql-sqlite.el | 32 +++++++++++++++-----------------
emacsql.el | 5 +++--
3 files changed, 34 insertions(+), 36 deletions(-)
diff --git a/emacsql-psql.el b/emacsql-psql.el
index ea6358e371..fe697ff855 100644
--- a/emacsql-psql.el
+++ b/emacsql-psql.el
@@ -57,23 +57,22 @@
(connection (make-instance 'emacsql-psql-connection
:process process
:dbname dbname)))
- (prog1 connection
- (setf (process-sentinel process)
- (lambda (proc _) (kill-buffer (process-buffer proc))))
- (when debug
- (setf (emacsql-log-buffer connection)
- (generate-new-buffer "*emacsql-log*")))
- (emacsql-register connection)
- (mapc (lambda (s) (emacsql-send-string connection s :no-log))
- '("\\pset pager off"
- "\\pset null nil"
- "\\a"
- "\\t"
- "\\f ' '"
- "SET client_min_messages TO ERROR;"
- "\\set PROMPT1 ]"
- "EMACSQL;")) ; error message flush
- (emacsql-wait connection)))))
+ (setf (process-sentinel process)
+ (lambda (proc _) (kill-buffer (process-buffer proc))))
+ (when debug
+ (setf (emacsql-log-buffer connection)
+ (generate-new-buffer "*emacsql-log*")))
+ (mapc (lambda (s) (emacsql-send-string connection s :no-log))
+ '("\\pset pager off"
+ "\\pset null nil"
+ "\\a"
+ "\\t"
+ "\\f ' '"
+ "SET client_min_messages TO ERROR;"
+ "\\set PROMPT1 ]"
+ "EMACSQL;")) ; error message flush
+ (emacsql-wait connection)
+ (emacsql-register connection))))
(defmethod emacsql-close ((connection emacsql-psql-connection))
(let ((process (emacsql-process connection)))
diff --git a/emacsql-sqlite.el b/emacsql-sqlite.el
index 06165cc714..1274898c62 100644
--- a/emacsql-sqlite.el
+++ b/emacsql-sqlite.el
@@ -50,25 +50,23 @@ buffer. This is for debugging purposes."
(fullfile (if file (expand-file-name file) ":memory:"))
(sqlite3 emacsql-sqlite3-executable)
(process (start-process "emacsql-sqlite" buffer sqlite3
- "-interactive" fullfile)))
+ "-interactive" fullfile))
+ (connection (make-instance 'emacsql-sqlite-connection
+ :process process
+ :file (when file fullfile))))
(setf (process-sentinel process)
(lambda (proc _) (kill-buffer (process-buffer proc))))
- (process-send-string process ".mode list\n")
- (process-send-string process ".separator ' '\n")
- (process-send-string process ".nullvalue nil\n")
- (process-send-string process ".prompt ]\n")
- (process-send-string process "EMACSQL;\n") ;; error message flush
- (let ((connection (make-instance
- 'emacsql-sqlite-connection
- :process process
- :file (when file fullfile)
- :log-buffer )))
- (prog1 connection
- (when debug
- (setf (emacsql-log-buffer connection)
- (generate-new-buffer "*emacsql-log*")))
- (emacsql-wait connection)
- (emacsql-register connection)))))
+ (mapc (lambda (s) (emacsql-send-string connection s :no-log))
+ '(".mode list"
+ ".separator ' '"
+ ".nullvalue nil"
+ ".prompt ]"
+ "EMACSQL;")) ; error message flush
+ (when debug
+ (setf (emacsql-log-buffer connection)
+ (generate-new-buffer "*emacsql-log*")))
+ (emacsql-wait connection)
+ (emacsql-register connection)))
;;;###autoload
(defalias 'emacsql-connect 'emacsql-sqlite)
diff --git a/emacsql.el b/emacsql.el
index 47687f6e3c..623c340a25 100644
--- a/emacsql.el
+++ b/emacsql.el
@@ -196,8 +196,9 @@ specific error conditions."
;; Automatic connection cleanup:
(defun emacsql-register (connection)
- "Add CONNECTION to the global connection list."
- (emacsql-reap-register connection #'emacsql-close (copy-sequence
connection)))
+ "Register CONNECTION for automatic cleanup and return CONNECTION."
+ (emacsql-reap-register connection #'emacsql-close (copy-sequence connection))
+ connection)
;; Useful macros:
- [nongnu] elpa/emacsql 18b40213fd 403/427: No longer use obsolete generalized variable `point', (continued)
- [nongnu] elpa/emacsql 18b40213fd 403/427: No longer use obsolete generalized variable `point', ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 6d999ba39d 400/427: Update library headers, ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql a29b9e7ea5 388/427: No longer needlessly require url and url-http, ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 20e390ea06 401/427: Add FAQ to README.md, ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 30912aa69e 404/427: Include ../.config.mk in sqlite/Makefile, ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql f5da68e5f9 391/427: Fix quoting in docstring, ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql a4d01edd71 411/427: Adjust emacsql-pg to new pg version from original author, ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql f179ba928a 047/427: Add :drop-table expander., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 458b8a6acd 074/427: Add :insert and :values expanders., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 2faed63b20 107/427: Prime emacsql-expand for substatements., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 13cfbeeaba 186/427: Tidy up the constructors.,
ELPA Syncer <=
- [nongnu] elpa/emacsql a742687cfb 192/427: Add funcall operator., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 8fa1ca451c 238/427: Fix schema mistake in unit test., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql ea613c5191 360/427: Push other sub-packages up to Emacs 25 as well, ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql fbda94e6b5 339/427: Improve some doc-strings., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 6f1e375a2e 367/427: Better escaping of NUL and control characters (#42), ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 3dc6971829 190/427: Add ALTER TABLE stuff., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql ef976b8649 189/427: Add package target for Makefile., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql 672963ae53 191/427: Add DISTINCT option to :select., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql b1da2ba9d2 297/427: Change compiler flag order (work around old gcc bug)., ELPA Syncer, 2022/12/13
- [nongnu] elpa/emacsql d21cc86540 188/427: Add lexical binding to tests., ELPA Syncer, 2022/12/13