Function: org-roam-db-autosync-mode

org-roam-db-autosync-mode is an autoloaded, interactive and byte-compiled function defined in org-roam-db.el.

Signature

(org-roam-db-autosync-mode &optional ARG)

Documentation

Global minor mode to keep your Org-roam session automatically synchronized.

Through the session this will continue to setup your buffers (that are Org-roam file visiting), keep track of the related changes, maintain cache consistency and incrementally update the currently active database.

If you need to manually trigger resync of the currently active database, see org-roam-db-sync command.

This is a global minor mode. If called interactively, toggle the Org-Roam-Db-Autosync mode mode. If the prefix argument is positive, enable the mode, and if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is toggle. Enable the mode if ARG is nil, omitted, or is a positive number. Disable the mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer, evaluate (default-value \=org-roam-db-autosync-mode)'.

The mode's hook is called both when the mode is enabled and when it is disabled.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/org-roam-20260224.1637/org-roam-db.el
;;;###autoload
(define-minor-mode org-roam-db-autosync-mode
  "Global minor mode to keep your Org-roam session automatically synchronized.
Through the session this will continue to setup your
buffers (that are Org-roam file visiting), keep track of the
related changes, maintain cache consistency and incrementally
update the currently active database.

If you need to manually trigger resync of the currently active
database, see `org-roam-db-sync' command."
  :group 'org-roam
  :global t
  :init-value nil
  (let ((enabled org-roam-db-autosync-mode))
    (cond
     (enabled
      (add-hook 'find-file-hook  #'org-roam-db-autosync--setup-file-h)
      (add-hook 'kill-emacs-hook #'org-roam-db--close-all)
      (advice-add #'rename-file :after  #'org-roam-db-autosync--rename-file-a)
      (advice-add #'delete-file :before #'org-roam-db-autosync--delete-file-a)
      (advice-add #'vc-delete-file :around #'org-roam-db-autosync--vc-delete-file-a)
      (org-roam-db-sync))
     (t
      (remove-hook 'find-file-hook  #'org-roam-db-autosync--setup-file-h)
      (remove-hook 'kill-emacs-hook #'org-roam-db--close-all)
      (advice-remove #'rename-file #'org-roam-db-autosync--rename-file-a)
      (advice-remove #'delete-file #'org-roam-db-autosync--delete-file-a)
      (advice-remove #'vc-delete-file #'org-roam-db-autosync--vc-delete-file-a)
      (org-roam-db--close-all)
      ;; Disable local hooks for all org-roam buffers
      (dolist (buf (seq-filter #'org-roam-buffer-p (buffer-list)))
        (with-current-buffer buf
          (remove-hook 'after-save-hook #'org-roam-db-autosync--try-update-on-save-h t)))))))