summaryrefslogtreecommitdiff
path: root/org-gnosis.el
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2024-12-07 09:44:00 +0200
committerThanos Apollo <[email protected]>2024-12-07 17:34:18 +0200
commitd8ceb601d7e22d02376d6e718e74d8b754877ff2 (patch)
treef911b9c7bd70fda525add2e171d65b99cdcd0521 /org-gnosis.el
parent331a98b58e4324ebdb763bb39536af8b4d085e22 (diff)
db-sync: Initialize database upon sync
Diffstat (limited to 'org-gnosis.el')
-rw-r--r--org-gnosis.el49
1 files changed, 24 insertions, 25 deletions
diff --git a/org-gnosis.el b/org-gnosis.el
index 293290e..80d05ee 100644
--- a/org-gnosis.el
+++ b/org-gnosis.el
@@ -271,31 +271,6 @@ Removes all contents of FILE in database, adding them anew."
(org-gnosis--insert-into 'tags `([,tag]))
(org-gnosis--insert-into 'node-tag `([,id ,tag]))))))))
-(defun org-gnosis-db-sync--journal ()
- "Sync journal entries in databse."
- (cl-loop for file in (cl-remove-if-not (lambda (file)
- (and (string-match-p "^[0-9]"
- (file-name-nondirectory file))
- (not (file-directory-p file))))
- (directory-files org-gnosis-journal-dir t nil t))
- do (org-gnosis-journal--update-file file)))
-
-;;;###autoload
-(defun org-gnosis-db-sync (&optional arg)
- "Sync `org-gnosis-db'.
-
-If called with ARG do not initialize the database."
- (interactive "P")
- (unless arg
- (org-gnosis-db-init))
- (let ((files (cl-remove-if-not (lambda (file)
- (and (string-match-p "^[0-9]" (file-name-nondirectory file))
- (not (file-directory-p file))))
- (directory-files org-gnosis-dir t nil t))))
- (cl-loop for file in files
- do (org-gnosis--update-file file)))
- (org-gnosis-db-sync--journal))
-
(defun org-gnosis-find--tag-with-tag-prop (lst)
"Combine each sublist of strings in LST into a single string."
(mapcar (lambda (item)
@@ -480,6 +455,30 @@ instead."
(org-gnosis--drop-table 'links)
(org-gnosis--drop-table 'node-tag))))
+(defun org-gnosis-db-sync--journal ()
+ "Sync journal entries in databse."
+ (cl-loop for file in (cl-remove-if-not (lambda (file)
+ (and (string-match-p "^[0-9]"
+ (file-name-nondirectory file))
+ (not (file-directory-p file))))
+ (directory-files org-gnosis-journal-dir t nil t))
+ do (org-gnosis-journal--update-file file)))
+
+;;;###autoload
+(defun org-gnosis-db-sync ()
+ "Sync `org-gnosis-db'.
+
+If called with ARG do not initialize the database."
+ (interactive)
+ (org-gnosis-db-init)
+ (let ((files (cl-remove-if-not (lambda (file)
+ (and (string-match-p "^[0-9]" (file-name-nondirectory file))
+ (not (file-directory-p file))))
+ (directory-files org-gnosis-dir t nil t))))
+ (cl-loop for file in files
+ do (org-gnosis--update-file file)))
+ (org-gnosis-db-sync--journal))
+
(defun org-gnosis-db-init ()
"Initialize database DB with the correct schema and user version."
(setf org-gnosis-db (emacsql-sqlite-open (locate-user-emacs-file "org-gnosis.db")))