;ELC ;;; Compiled ;;; in Emacs version 28.0.50 ;;; with all optimizations. (byte-code "\300\301!\210\300\302!\210\300\303!\210\300\304!\210\305\306\307\310\311\312%\207" [require cl-lib cl-generic eieio emacsql-compiler custom-declare-group emacsql nil "The EmacSQL SQL database front-end." :group comm] 6) (defvar emacsql-version "3.0.0") #@94 Maximum number of seconds to wait before bailing out on a SQL command. If nil, wait forever. (defvar emacsql-global-timeout 30 (#$ . 352)) #@39 Directory where EmacSQL is installed. (defvar emacsql-data-root (byte-code "\302\206 !\207" [load-file-name buffer-file-name file-name-directory] 2) (#$ . 497)) (byte-code "\300\301\302\303!\"\210\300\304\305\303!\"\210\300\306\304\"\210\307\306\310\311#\210\312\303\313\304#\314\303\315\316\317$\210\320\321\315\322\315\323%\210\320\324\315\325\315\326%\210\320\327\315\330\315\331%\210\320\332\315\333\315\334%\210\320\335\315\336\315\337%\207" [defalias emacsql-connection-p eieio-make-class-predicate emacsql-connection emacsql-connection--eieio-childp eieio-make-child-predicate emacsql-connection-child-p make-obsolete "use (cl-typep ... \\='emacsql-connection) instead" "25.1" define-symbol-prop cl-deftype-satisfies eieio-defclass-internal nil ((process :type process :initarg :process :accessor emacsql-process) (log-buffer :type (or null buffer) :initarg :log-buffer :initform nil :accessor emacsql-log-buffer :documentation "Output log (debug).") (finalizer :documentation "Object returned from `make-finalizer'.") (types :allocation :class :initform nil :reader emacsql-types :documentation "Maps EmacSQL types to SQL types.")) ((:documentation "A connection to a SQL database.") :abstract t) cl-generic-define-method emacsql-types ((this emacsql-connection)) #[257 "\300\301\"\207" [slot-value types] 4 "Access the slot `types' from object of class `emacsql-connection'.\n\n(fn THIS)"] emacsql-log-buffer ((this emacsql-connection)) #[257 "\300\301\"\205 \302\301\"\207" [slot-boundp log-buffer eieio-oref] 4 "Retrieve the slot `log-buffer' from an object of class `emacsql-connection'.\n\n(fn THIS)"] \(setf\ emacsql-log-buffer\) (value (this emacsql-connection)) #[514 "\300\301#\207" [eieio-oset log-buffer] 6 "\n\n(fn VALUE THIS)"] emacsql-process ((this emacsql-connection)) #[257 "\300\301\"\205 \302\301\"\207" [slot-boundp process eieio-oref] 4 "Retrieve the slot `process' from an object of class `emacsql-connection'.\n\n(fn THIS)"] \(setf\ emacsql-process\) (value (this emacsql-connection)) #[514 "\300\301#\207" [eieio-oset process] 6 "\n\n(fn VALUE THIS)"]] 7) #@76 You cannot create a new object of type `emacsql-connection'. (fn &rest _) (defalias 'emacsql-connection #[128 "\300\301!\207" [error "Class emacsql-connection is abstract"] 3 (#$ . 2605)]) (byte-code "\300\301\302\301\303\304#\305#\210\300\306\302\306\307\304#\310#\210\311\312\304\313\304\314%\210\300\315\302\315\316\304#\317#\210\311\320\304\321\304\322%\210\311\323\304\324\304\325%\210\311\326\304\327\304\330%\210\300\331\302\331\332\304#\333#\210\311\331\334\335\304\336%\210\311\337\304\340\304\341%\210\300\342\302\342\343\304#\344#\210\311\345\304\346\304\347%\210\300\350\302\350\351\304#\352#\207" [defalias emacsql-close cl-generic-define (connection) nil "Close CONNECTION and free all resources.\n\n(fn CONNECTION)" emacsql-reconnect (connection) "Re-establish CONNECTION with the same parameters.\n\n(fn CONNECTION)" cl-generic-define-method emacsql-live-p ((connection emacsql-connection)) #[257 "\300\301!!??\207" [process-live-p emacsql-process] 4 "Return non-nil if CONNECTION is still alive and ready.\n\n(fn CONNECTION)"] emacsql-types (connection) "Return an alist mapping EmacSQL types to database types.\nThis will mask `emacsql-type-map' during expression compilation.\nThis alist should have four key symbols: integer, float, object,\nnil (default type). The values are strings to be inserted into a\nSQL expression.\n\n(fn CONNECTION)" emacsql-buffer ((connection emacsql-connection)) #[257 "\300\301!!\207" [process-buffer emacsql-process] 4 "Get process buffer for CONNECTION.\n\n(fn CONNECTION)"] emacsql-enable-debugging ((connection emacsql-connection)) #[257 "\300\301!!?\205\211\302\303\304!\"\262\207" [buffer-live-p emacsql-log-buffer \(setf\ emacsql-log-buffer\) generate-new-buffer " *emacsql-log*"] 5 "Enable debugging on CONNECTION.\n\n(fn CONNECTION)"] emacsql-log ((connection emacsql-connection) message) #[514 "\300!\211\205r\211q\210db\210\301\302P\")\207" [emacsql-log-buffer princ "\n"] 6 "Log MESSAGE into CONNECTION's log.\nMESSAGE should not have a newline on the end.\n\n(fn CONNECTION MESSAGE)"] emacsql-send-message ((connection emacsql-connection) message) "Send MESSAGE to CONNECTION.\n\n(fn (CONNECTION emacsql-connection) MESSAGE)" (:before) ((connection emacsql-connection) message) #[514 "\300\"\207" [emacsql-log] 5 "\n\n(fn CONNECTION MESSAGE)"] emacsql-clear ((connection emacsql-connection)) #[257 "r\300!q\210\301 )\207" [emacsql-buffer erase-buffer] 3 "Clear the process buffer for CONNECTION-SPEC.\n\n(fn CONNECTION)"] emacsql-waiting-p (connection) "Return non-nil if CONNECTION is ready for more input.\n\n(fn CONNECTION)" emacsql-wait ((connection emacsql-connection) &optional timeout) #[513 "\211\206\211\205 \301 \\\203\301 W\2032\302!\2042\303 \304\305\"\216\306\307!\"\210)\210\202 \302!?\205?\310\311\312D\"\207" [emacsql-global-timeout float-time emacsql-waiting-p match-data make-closure #[0 "\301\300\302\"\207" [V0 set-match-data evaporate] 3] accept-process-output emacsql-process signal emacsql-timeout "Query timed out"] 8 "Block until CONNECTION is waiting for further input.\n\n(fn CONNECTION &optional TIMEOUT)"] emacsql-parse (connection) "Return the results of parsing the latest output or signal an error.\n\n(fn CONNECTION)"] 6) #@88 Compile s-expression SQL for CONNECTION into a string. (fn CONNECTION SQL &rest ARGS) (defalias 'emacsql-compile #[642 "\205\301!\211\206\f\302\303\304!#\305P)\207" [emacsql-type-map emacsql-types apply emacsql-format emacsql-prepare ";"] 8 (#$ . 5866)]) (byte-code "\300\301\302\303\302\304%\210\305\306\307\310!\"\210\305\311\312\310!\"\210\305\313\311\"\210\314\313\315\316#\210\317\310\320\311#\321\310\302\211\322$\207" [cl-generic-define-method emacsql nil ((connection emacsql-connection) sql &rest args) #[642 "\300\301$\302!\210\303\"\210\304!\210\305!\207" [apply emacsql-compile emacsql-clear emacsql-send-message emacsql-wait emacsql-parse] 8 "Send SQL s-expression to CONNECTION and return the results.\n\n(fn CONNECTION SQL &rest ARGS)"] defalias emacsql-protocol-mixin-p eieio-make-class-predicate emacsql-protocol-mixin emacsql-protocol-mixin--eieio-childp eieio-make-child-predicate emacsql-protocol-mixin-child-p make-obsolete "use (cl-typep ... \\='emacsql-protocol-mixin) instead" "25.1" define-symbol-prop cl-deftype-satisfies eieio-defclass-internal ((:documentation "A mixin for back-ends following the EmacSQL protocol.\nThe back-end prompt must be a single \"]\" character. This prompt\nvalue was chosen because it is unreadable. Output must have\nexactly one row per line, fields separated by whitespace. NULL\nmust display as \"nil\".") :abstract t)] 6) #@80 You cannot create a new object of type `emacsql-protocol-mixin'. (fn &rest _) (defalias 'emacsql-protocol-mixin #[128 "\300\301!\207" [error "Class emacsql-protocol-mixin is abstract"] 3 (#$ . 7271)]) (byte-code "\300\301\302\303\302\304%\210\300\305\302\306\302\307%\210\300\310\302\311\302\312%\210\313\314!\207" [cl-generic-define-method emacsql-waiting-p nil ((connection emacsql-protocol-mixin)) #[257 "r\300!q\210\301 \302Y\205d\302Zd{\303\230)\207" [emacsql-buffer buffer-size 2 "#\n"] 3 "Return true if the end of the buffer has a properly-formatted prompt.\n\n(fn CONNECTION)"] emacsql-handle ((_ emacsql-protocol-mixin) code message) #[771 "\300\301D\"\207" [signal emacsql-error] 7 "Signal a specific condition for CODE from CONNECTION.\nSubclasses should override this method in order to provide more\nspecific error conditions.\n\n(fn _ CODE MESSAGE)"] emacsql-parse ((connection emacsql-protocol-mixin)) #[257 "r\301!q\210eb\210p\302 \211\303=\203\304\302 \302 #\202-\211\302 \305=\204-\304\302 \302 #\210)\262)\207" [standard-input emacsql-buffer read error emacsql-handle success] 7 "Parse well-formed output into an s-expression.\n\n(fn CONNECTION)"] provide emacsql] 6) #@83 Register CONNECTION for automatic cleanup and return CONNECTION. (fn CONNECTION) (defalias 'emacsql-register #[257 "\300\301\302\"!\211\303\304#\266\207" [make-finalizer make-closure #[0 "\301\300!\207" [V0 emacsql-close] 2] eieio-oset finalizer] 8 (#$ . 8480)]) #@352 Open an EmacSQL connection, evaluate BODY, and close the connection. CONNECTION-SPEC establishes a single binding. (emacsql-with-connection (db (emacsql-sqlite "company.db")) (emacsql db [:create-table foo [x]]) (emacsql db [:insert :into foo :values ([1] [2] [3])]) (emacsql db [:select * :from foo])) (fn CONNECTION-SPEC &rest BODY) (defalias 'emacsql-with-connection '(macro . #[385 "\300@A@DC\301\302B\303@DEE\207" [let unwind-protect progn emacsql-close] 8 (#$ . 8756)])) (byte-code "\300\301\302\303#\300\207" [function-put emacsql-with-connection lisp-indent-function 1] 4) #@67 Keeps track of nested transactions in `emacsql-with-transaction'. (defvar emacsql--transaction-level 0 (#$ . 9364)) #@384 Evaluate BODY inside a single transaction, issuing a rollback on error. This macro can be nested indefinitely, wrapping everything in a single transaction at the lowest level. Warning: BODY should *not* have any side effects besides making changes to the database behind CONNECTION. Body may be evaluated multiple times before the changes are committed. (fn CONNECTION &rest BODY) (defalias 'emacsql-with-transaction '(macro . #[385 "\300\301D\302B\303\304\305\306\307\310\311\300\312\310\fBDC\313BBE\314BBBE\315BB\316BBB\207" [let emacsql--connection ((emacsql--completed nil) (emacsql--transaction-level (1+ emacsql--transaction-level)) (emacsql--result)) unwind-protect while (not emacsql--completed) condition-case nil progn (when (= 1 emacsql--transaction-level) (emacsql emacsql--connection [:begin])) result ((setf emacsql--result result) (when (= 1 emacsql--transaction-level) (emacsql emacsql--connection [:commit])) (setf emacsql--completed t)) ((emacsql-locked (emacsql emacsql--connection [:rollback]) (sleep-for 0.05))) ((when (and (= 1 emacsql--transaction-level) (not emacsql--completed)) (emacsql emacsql--connection [:rollback]))) (emacsql--result)] 15 (#$ . 9487)])) (byte-code "\300\301\302\303#\300\207" [function-put emacsql-with-transaction lisp-indent-function 1] 4) #@143 Thread CONNECTION through STATEMENTS. A statement can be a list, containing a statement with its arguments. (fn CONNECTION &rest STATEMENTS) (defalias 'emacsql-thread '(macro . #[385 "\300\301DC\302\301\303\211:\2035@\262\304!\203$\305\301EB\262\202.\306\305\301D\"B\262A\262\202\n\211\237\266\203BBE\207" [let emacsql--conn emacsql-with-transaction nil vectorp emacsql append] 12 (#$ . 10788)])) (byte-code "\300\301\302\303#\300\207" [function-put emacsql-thread lisp-indent-function 1] 4) #@752 For each result row bind the column names for each returned row. Returns the result of the last evaluated BODY. All column names must be provided in the query ($ and * are not allowed). Hint: all of the bound identifiers must be known at compile time. For example, in the expression below the variables 'name' and 'phone' will be bound for the body. (emacsql-with-bind db [:select [name phone] :from people] (message "Found %s with %s" name phone)) (emacsql-with-bind db ([:select [name phone] :from people :where (= name $1)] my-name) (message "Found %s with %s" name phone)) Each column must be a plain symbol, no expressions allowed here. (fn CONNECTION SQL-AND-ARGS &rest BODY) (defalias 'emacsql-with-bind '(macro . #[642 "\300!\203\n\202\f@\300!?\205A\301\234\302=\204!\303\304!\210\305\234\211\306=\203.\307\310!\210\311\312\"\2049\303\313!\210\314\315\316BBBD\317B\320\321\322\323\324\325\326\"\327\fBBBEEE\207" [vectorp 0 :select cl--assertion-failed (eq :select (elt sql 0)) 1 * error "Must explicitly list columns in `emacsql-with-bind'." cl-every symbolp (cl-every #'symbolp vars) let emacsql--results emacsql ((emacsql--final nil)) dolist (emacsql--result emacsql--results emacsql--final) setf emacsql--final cl-destructuring-bind cl-coerce list emacsql--result] 16 (#$ . 11306)])) (byte-code "\300\301\302\303#\300\207" [function-put emacsql-with-bind lisp-indent-function 2] 4) #@53 Name of the buffer for displaying intermediate SQL. (defvar emacsql-show-buffer-name "*emacsql-show*" (#$ . 12798)) #@59 Indent and wrap the SQL expression in the current buffer. (defalias 'emacsql--indent #[0 "\212eb\210\302\303\304\302\305#\205i \306_V\203\307v\210\310c\210\202*\207" [case-fold-search fill-column nil search-forward-regexp " [A-Z]+" :no-error 0.8 -1 "\n "] 4 (#$ . 12920)]) #@64 Fontify and display the SQL expression in STRING. (fn STRING) (defalias 'emacsql-show-sql #[257 "\303\304\305\"r\211q\210\306\307\"\216c\210\310 \210\311 \210\312\313!\203/\312\314!\203/\214~\210\313 \210\314 \210)\2022\315 \210\316 \210\317 *\262r\320!q\210G W\203N\321\322\"\202`\323\324 \210\211c\210)\325 \210\326 \210\327p!)\207" [emacsql-show-buffer-name fill-column buffer-read-only generate-new-buffer " *temp*" t make-closure #[0 "\301\300!\205 \302\300!\207" [V0 buffer-name kill-buffer] 2] sql-mode sql-highlight-sqlite-keywords fboundp font-lock-flush font-lock-ensure font-lock-fontify-buffer emacsql--indent buffer-string get-buffer-create message "%s" nil erase-buffer special-mode visual-line-mode pop-to-buffer] 5 (#$ . 13209)]) #@70 Convert a s-expression SQL into a flat string for display. (fn SQL) (defalias 'emacsql-flatten-sql #[257 "\300!\211\203\211A\262\242\202\301\302\303GD\"\304\305\306\307\"\310\211:\203<@\262\311\305\312T\"!B\262A\262\202!\211\237\266\203#\313P\207" [emacsql-prepare signal wrong-number-of-arguments (string . vars) apply format mapcar car nil intern "$%d" ";"] 13 (#$ . 13975)]) #@170 Display the compiled SQL of the s-expression SQL expression before point. A prefix argument causes the SQL to be printed into the current buffer. (fn &optional PREFIX) (defalias 'emacsql-show-last-sql #[256 "\300\301!\203 \301 \202 \302 \303!\203!\304!\203\211c\207\305!\207\306\307\"\207" [fboundp elisp--preceding-sexp preceding-sexp emacsql-sql-p emacsql-flatten-sql emacsql-show-sql user-error "Invalid SQL: %S"] 5 (#$ . 14382) "P"]) #@56 Return non-nil if point is inside a vector expression. (defalias 'emacsql--inside-vector-p #[0 "`\212\300 \210\301`\"\302\234\211\205\211b\210\303\304!\262)\207" [beginning-of-defun parse-partial-sexp 1 looking-at "\\["] 4 (#$ . 14837)]) (ad-add-advice 'calculate-lisp-indent '(emacsql-vector-indent nil nil (advice lambda nil "Don't indent vectors in `emacs-lisp-mode' like lists." (if (save-excursion (beginning-of-line) (emacsql--inside-vector-p)) (let ((lisp-indent-offset 1)) ad-do-it) ad-do-it))) 'around nil) #@132 When called, advise `calculate-lisp-indent' to stop indenting vectors. Once activate, vector contents no longer indent like lists. (defalias 'emacsql-fix-vector-indentation #[0 "\300\301\302\303#\210\304\301!\207" [ad-enable-advice calculate-lisp-indent around emacsql-vector-indent ad-activate] 4 (#$ . 15364) nil])