Update handling of the database
v2 reverted to using `emacsql-sqlite` instead of `emacsql-sqlite3`. It will now try to build the needed `sqlite3` executable by itself, using a C compiler that it can find, which is normally gcc or clang. Previously in v1 it would only check for `sqlite3` executable (using `executable-find`) and wouldn't do anything else.
This commit is contained in:
parent
5ef733b488
commit
9e12873779
2 changed files with 31 additions and 6 deletions
|
@ -24,7 +24,7 @@ of org-mode to properly utilize ID links.")
|
||||||
|
|
||||||
:init
|
:init
|
||||||
(doom-load-packages-incrementally
|
(doom-load-packages-incrementally
|
||||||
'(ansi-color dash f rx seq magit-section))
|
'(ansi-color dash f rx seq magit-section emacsql emacsql-sqlite))
|
||||||
|
|
||||||
(map! :after org
|
(map! :after org
|
||||||
:map org-mode-map
|
:map org-mode-map
|
||||||
|
@ -65,17 +65,41 @@ of org-mode to properly utilize ID links.")
|
||||||
;; Don't display warning message dedicated for v1 users. Need to be set early.
|
;; Don't display warning message dedicated for v1 users. Need to be set early.
|
||||||
(setq org-roam-v2-ack t)
|
(setq org-roam-v2-ack t)
|
||||||
|
|
||||||
|
(defadvice! +org-roam-suppress-sqlite-build-a (orig-fn &rest args)
|
||||||
|
"Suppress automatic building of sqlite3 binary when loading `org-roam'.
|
||||||
|
This is a blocking operation that can take a while to complete
|
||||||
|
and better be deferred when there will be an actual demand for
|
||||||
|
the database. See `+org-init-roam-h' for the launch process."
|
||||||
|
:around #'emacsql-sqlite-ensure-binary
|
||||||
|
(if (not (boundp 'org-roam-db-location))
|
||||||
|
(apply orig-fn args)
|
||||||
|
(advice-remove #'emacsql-sqlite-ensure-binary #'+org-roam-suppress-sqlite-build-a)
|
||||||
|
nil))
|
||||||
|
|
||||||
:config
|
:config
|
||||||
(defun +org-init-roam-h ()
|
(defun +org-init-roam-h ()
|
||||||
"Setup `org-roam' but don't immediately initialize its database.
|
"Setup `org-roam' but don't immediately initialize its database.
|
||||||
Instead, initialize it when it will be actually needed."
|
Instead, initialize it when it will be actually needed."
|
||||||
(letf! ((#'org-roam-db-sync #'ignore))
|
(letf! ((#'org-roam-db-sync #'ignore))
|
||||||
(org-roam-setup))
|
(org-roam-setup))
|
||||||
(defadvice! +org-roam-init-db-a (&rest _)
|
(defadvice! +org-roam-try-init-db-a (&rest _)
|
||||||
"Initialize org-roam database when it's first time queried to."
|
"Try to initialize org-roam database at the last possible safe moment.
|
||||||
|
In case of failure, fail gracefully."
|
||||||
:before #'org-roam-db-query
|
:before #'org-roam-db-query
|
||||||
(advice-remove 'org-roam-db-query #'+org-roam-init-db-a)
|
|
||||||
(message "Initializing org-roam database...")
|
(message "Initializing org-roam database...")
|
||||||
|
(let ((run-cleanup-p t))
|
||||||
|
(unwind-protect
|
||||||
|
;; Try to build the binary if it doesn't exist. In case of failure
|
||||||
|
;; this will error, run the cleanup and exit, and in case of success
|
||||||
|
;; this will return nil and sync the database.
|
||||||
|
(setq run-cleanup-p (emacsql-sqlite-ensure-binary))
|
||||||
|
(when run-cleanup-p
|
||||||
|
(setq org-roam--sqlite-available-p nil)
|
||||||
|
(org-roam-teardown)
|
||||||
|
(message (concat "EmacSQL failied to build SQLite binary for org-roam; "
|
||||||
|
"see *Compile-Log* buffer for details.\n"
|
||||||
|
"To try reinitialize org-roam, run \"M-x org-roam-setup\"")))))
|
||||||
|
(advice-remove 'org-roam-db-query #'+org-roam-try-init-db-a)
|
||||||
(org-roam-db-sync)))
|
(org-roam-db-sync)))
|
||||||
|
|
||||||
(setq org-roam-directory
|
(setq org-roam-directory
|
||||||
|
|
|
@ -5,10 +5,11 @@
|
||||||
(unless (executable-find "gnuplot")
|
(unless (executable-find "gnuplot")
|
||||||
(warn! "Couldn't find gnuplot. org-plot/gnuplot will not work")))
|
(warn! "Couldn't find gnuplot. org-plot/gnuplot will not work")))
|
||||||
|
|
||||||
|
(when (featurep! +roam)
|
||||||
|
(unless (executable-find "sqlite3")
|
||||||
|
(warn! "Couldn't find the sqlite3 executable. org-roam will not work.")))
|
||||||
(when (or (featurep! +roam)
|
(when (or (featurep! +roam)
|
||||||
(featurep! +roam2))
|
(featurep! +roam2))
|
||||||
(unless (executable-find "sqlite3")
|
|
||||||
(warn! "Couldn't find the sqlite3 executable. org-roam will not work."))
|
|
||||||
(unless (executable-find "dot")
|
(unless (executable-find "dot")
|
||||||
(warn! "Couldn't find the dot executable (from graphviz). org-roam will not be able to generate graph visualizations.")))
|
(warn! "Couldn't find the dot executable (from graphviz). org-roam will not be able to generate graph visualizations.")))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue