diff --git a/org-roam-capture.el b/org-roam-capture.el index 65f528e..529d578 100644 --- a/org-roam-capture.el +++ b/org-roam-capture.el @@ -227,7 +227,8 @@ Template string :\n%v") :head "#+title: ${title}\n#+roam_key: ${ref}" :unnarrowed t)) "The Org-roam templates used during a capture from the roam-ref protocol. -Details on how to specify for the template is given in `org-roam-capture-templates'." +Details on how to specify for the template is given in +`org-roam-capture-templates'." :group 'org-roam ;; Adapted from `org-capture-templates' :type diff --git a/org-roam-db.el b/org-roam-db.el index 97aa493..48d2427 100644 --- a/org-roam-db.el +++ b/org-roam-db.el @@ -101,7 +101,8 @@ so that multi-directories are updated.") Update the database immediately upon file changes. `idle-timer' - Updates the database if dirty, if Emacs idles for `org-roam-db-update-idle-seconds'." + Updates the database if dirty, if Emacs idles for + `org-roam-db-update-idle-seconds'." :type '(choice (const :tag "idle-timer" idle-timer) (const :tag "immediate" immediate)) :group 'org-roam) diff --git a/org-roam-faces.el b/org-roam-faces.el index dad3bef..b3014fc 100644 --- a/org-roam-faces.el +++ b/org-roam-faces.el @@ -67,7 +67,7 @@ during an `org-roam-capture'." (defface org-roam-dailies-calendar-note '((t :inherit (org-roam-link) :underline nil)) - "Face for dates with a daily-note in the calendar" + "Face for dates with a daily-note in the calendar." :group 'org-roam-faces) ;;; _ diff --git a/org-roam-link.el b/org-roam-link.el index faa7d69..b954341 100644 --- a/org-roam-link.el +++ b/org-roam-link.el @@ -48,7 +48,7 @@ (declare-function org-roam-format-link "org-roam") (defcustom org-roam-link-auto-replace t - "When non-nil, replace Org-roam's roam links with file or id links whenever possible." + "When non-nil, replace Org-roam's roam links with file/id equivalents." :group 'org-roam :type 'boolean) diff --git a/org-roam.el b/org-roam.el index 7633777..355897b 100644 --- a/org-roam.el +++ b/org-roam.el @@ -259,7 +259,8 @@ Function should return a filename string based on title." ) "Characters to trim from Unicode normalization for slug. -By default, the characters are specified to remove Diacritical Marks from the Latin alphabet." +By default, the characters are specified to remove Diacritical +Marks from the Latin alphabet." :type '(repeat character) :group 'org-roam) @@ -305,7 +306,9 @@ The currently supported symbols are: :group 'org-roam) (defcustom org-roam-enable-headline-linking t - "Enable linking to headlines, which includes automatic :ID: creation and scanning of :ID:s for org-roam database." + "Enable linking to headlines. +This includes automatic :ID: creation and scanning of :ID:s for +org-roam database." :type 'boolean :group 'org-roam) @@ -994,13 +997,28 @@ Return nil if the file does not exist." (file (plist-get (cdr (assoc ref completions)) :path))) (org-roam--find-file file))) +(defun org-roam--org-roam-buffer-p (&optional buffer) + "Return t if BUFFER is accessing a part of Org-roam system. +If BUFFER is not specified, use the current buffer." + (let ((buffer (or buffer (current-buffer))) + path) + (with-current-buffer buffer + (and (derived-mode-p 'org-mode) + (setq path (buffer-file-name (buffer-base-buffer))) + (org-roam--org-roam-file-p path))))) + (defun org-roam--get-roam-buffers () "Return a list of buffers that are Org-roam files." - (--filter (and (with-current-buffer it (derived-mode-p 'org-mode)) - (buffer-file-name it) - (org-roam--org-roam-file-p (buffer-file-name it))) + (--filter (org-roam--org-roam-buffer-p it) (buffer-list))) +(defun org-roam--save-buffers (&optional ask update) + "Save all Org-roam buffers. +When ASK is non-nil, ask whether the buffers should be saved. +When UPDATE is non-nil, update the database after." + (save-some-buffers (not ask) #'org-roam--org-roam-buffer-p) + (when update (org-roam-db-update))) + ;;; org-roam-backlinks-mode (define-minor-mode org-roam-backlinks-mode "Minor mode for the `org-roam-buffer'. @@ -1390,7 +1408,7 @@ OLD-TITLE, and replace the link descriptions with the NEW-TITLE if applicable. To be added to `org-roam-title-change-hook'." - (let* ((current-path (buffer-file-name)) + (let* ((current-path (buffer-file-name (buffer-base-buffer))) (files-affected (org-roam-db-query [:select :distinct [source] :from links :where (= dest $s1)] @@ -1407,6 +1425,7 @@ current filename, the new slug is computed with NEW-TITLE, and that portion of the filename is renamed. To be added to `org-roam-title-change-hook'." + (org-roam--save-buffers) (when org-roam-rename-file-on-title-change (let* ((old-slug (funcall org-roam-title-to-slug-function old-title)) (file (buffer-file-name (buffer-base-buffer)))