refactor(org): update org-roam emacsql deferral advice
org-roam-setup was made obsolete in Org Roam 2.0. Ref: org-roam/org-roam@5dce6261a2
This commit is contained in:
parent
8cbfbce394
commit
7e6baca99d
1 changed files with 20 additions and 19 deletions
|
@ -45,26 +45,27 @@ the database. See `+org-init-roam-h' for the launch process."
|
||||||
"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-db-autosync-enable)))
|
||||||
(defadvice! +org-roam-try-init-db-a (&rest _)
|
|
||||||
"Try to initialize org-roam database at the last possible safe moment.
|
(defadvice! +org-roam-try-init-db-a (&rest _)
|
||||||
|
"Try to initialize org-roam database at the last possible safe moment.
|
||||||
In case of failure, fail gracefully."
|
In case of failure, fail gracefully."
|
||||||
:before #'org-roam-db-query
|
:before #'org-roam-db-query
|
||||||
(message "Initializing org-roam database...")
|
(message "Initializing org-roam database...")
|
||||||
(let ((run-cleanup-p t))
|
(let ((run-cleanup-p t))
|
||||||
(unwind-protect
|
(unwind-protect
|
||||||
;; Try to build the binary if it doesn't exist. In case of failure
|
;; 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 error, run the cleanup and exit, and in case of success
|
||||||
;; this will return nil and sync the database.
|
;; this will return nil and sync the database.
|
||||||
(setq run-cleanup-p (emacsql-sqlite-ensure-binary))
|
(setq run-cleanup-p (emacsql-sqlite-ensure-binary))
|
||||||
(when run-cleanup-p
|
(when run-cleanup-p
|
||||||
(setq org-roam--sqlite-available-p nil)
|
(setq org-roam--sqlite-available-p nil)
|
||||||
(org-roam-teardown)
|
(org-roam-teardown)
|
||||||
(message (concat "EmacSQL failied to build SQLite binary for org-roam; "
|
(message (concat "EmacSQL failied to build SQLite binary for org-roam; "
|
||||||
"see *Compile-Log* buffer for details.\n"
|
"see *Compile-Log* buffer for details.\n"
|
||||||
"To try reinitialize org-roam, run \"M-x org-roam-setup\"")))))
|
"To try reinitialize org-roam, run \"M-x org-roam-setup\"")))))
|
||||||
(advice-remove 'org-roam-db-query #'+org-roam-try-init-db-a)
|
(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
|
||||||
(thread-first (or org-roam-directory "roam")
|
(thread-first (or org-roam-directory "roam")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue