diff options
author | Thanos Apollo <[email protected]> | 2025-02-25 07:37:18 +0200 |
---|---|---|
committer | Thanos Apollo <[email protected]> | 2025-02-25 07:37:18 +0200 |
commit | 9947a1a7aee740c01dc2bee0df1490f8589e9a25 (patch) | |
tree | 27739a2e99b77abe21812b986cfa935e1661afea | |
parent | c126ae29fda650c797e6b261e757487bcd994107 (diff) |
[fix] Rewrite quoting for restrictions.
+ Resolves issues for BSD users, refer to [1][2]
[1] https://github.com/magit/emacsql/issues/128#issuecomment-2676824433
[2] https://www.sqlite.org/quirks.html#double_quoted_string_literals_are_accepted
-rw-r--r-- | org-gnosis.el | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/org-gnosis.el b/org-gnosis.el index 3db7581..127afbb 100644 --- a/org-gnosis.el +++ b/org-gnosis.el @@ -94,7 +94,7 @@ (unless (file-directory-p dir) (make-directory dir))) -(cl-defun org-gnosis-select (value table &optional (restrictions '1=1) (flatten nil)) +(cl-defun org-gnosis-select (value table &optional (restrictions '(= '1 '1)) (flatten nil)) "Select VALUE from TABLE, optionally with RESTRICTIONS. Optional argument FLATTEN, when non-nil, flattens the result." @@ -256,7 +256,7 @@ If JOURNAL is non-nil, update file as a journal entry." (table (if journal 'journal 'nodes)) (filename (file-name-nondirectory file)) (links (and (> (length info) 1) (apply #'append (last info)))) - (titles (org-gnosis-select 'title table '1=1 t))) + (titles (org-gnosis-select 'title table nil t))) ;; Add gnosis topic (message "Parsing: %s" filename) (cl-loop for item in data @@ -420,7 +420,7 @@ DIRECTORY." (interactive) (let* ((tag (or tag (funcall org-gnosis-completing-read-func "Select tag: " - (org-gnosis-select 'tag 'tags '1=1 t)))) + (org-gnosis-select 'tag 'tags nil t)))) (node (funcall org-gnosis-completing-read-func "Select node: " @@ -448,9 +448,9 @@ If JOURNAL-P is non-nil, retrieve/create node as a journal entry." (interactive "P") (let* ((table (if journal-p 'journal 'nodes)) (node (org-gnosis--find "Select gnosis node: " - (org-gnosis-select '[title tags] table '1=1) - (org-gnosis-select 'title table '1=1))) - (id (concat "id:" (car (org-gnosis-select 'id table `(= ,node title) '1=1))))) + (org-gnosis-select '[title tags] table) + (org-gnosis-select 'title table))) + (id (concat "id:" (car (org-gnosis-select 'id table `(= ,node title)))))) (cond ((< (length id) 4) ; if less that 4 then `org-gnosis-select' returned nil, (id:) (save-window-excursion (org-gnosis--create-file @@ -459,7 +459,7 @@ If JOURNAL-P is non-nil, retrieve/create node as a journal entry." (save-buffer) (setf id (concat "id:" - (car (org-gnosis-select 'id table `(= ,node title) '1=1))))) + (car (org-gnosis-select 'id table `(= ,node title)))))) (org-insert-link nil id node) (message "Created new node: %s" node)) (t (org-insert-link nil id node))))) @@ -468,7 +468,7 @@ If JOURNAL-P is non-nil, retrieve/create node as a journal entry." (defun org-gnosis-insert-filetag (&optional tag) "Insert TAG as filetag." (interactive) - (let* ((filetags (org-gnosis-select 'tag 'tags '1=1 t)) + (let* ((filetags (org-gnosis-select 'tag 'tags nil t)) (tag (or tag (funcall org-gnosis-completing-read-func "Select tag: " filetags)))) (save-excursion (if (org-at-heading-p) @@ -488,7 +488,7 @@ If JOURNAL-P is non-nil, retrieve/create node as a journal entry." (interactive (list (completing-read-multiple "Select tags (separated by ,): " - (org-gnosis-select 'tag 'tags '1=1 t)))) + (org-gnosis-select 'tag 'tags nil t)))) (let ((id (and (org-gnosis-get-id)))) (org-id-goto id) (if (org-current-level) @@ -745,10 +745,9 @@ ENTRY: Journal entry linked under the heading." "Initialize database. If database tables exist, delete them & recreate the db." - (setf org-gnosis-db (emacsql-sqlite-open (locate-user-emacs-file "org-gnosis.db"))) (org-gnosis-db-delete-tables) (when (length< (emacsql org-gnosis-db - [:select name :from sqlite-master :where (= type table)]) + [:select name :from sqlite-master :where (= type 'table)]) 3) (emacsql-with-transaction org-gnosis-db (pcase-dolist (`(,table ,schema) org-gnosis-db--table-schemata) @@ -758,7 +757,7 @@ If database tables exist, delete them & recreate the db." (defun org-gnosis-db-init-if-needed () "Init database if it has not been initizalized." (when (length< (emacsql org-gnosis-db - [:select name :from sqlite-master :where (= type table)]) + [:select name :from sqlite-master :where (= type 'table)]) 4) (message "Creating org-gnosis database...") (org-gnosis-db-init))) |