From d2e933cc3e4f5ee843bfca9525a30eb395c60990 Mon Sep 17 00:00:00 2001 From: Troy Hinckley Date: Sun, 2 May 2021 13:36:09 -0600 Subject: [PATCH 1/3] Fix auto save buffer in org-roam-doctor (#1493) --- org-roam-doctor.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/org-roam-doctor.el b/org-roam-doctor.el index 0f3c275..66c334b 100644 --- a/org-roam-doctor.el +++ b/org-roam-doctor.el @@ -308,7 +308,8 @@ If CHECKALL, run the check for all Org-roam files." (let ((buf (find-file-noselect f))) (org-roam-doctor--check buf checkers) (unless (memq buf existing-buffers) - (save-buffer buf) + (with-current-buffer buf + (save-buffer)) (kill-buffer buf)))))) (org-roam-message "Linting completed.")) From 02e35e3b01914a0dceb39a116a978f523d5f4272 Mon Sep 17 00:00:00 2001 From: Greg Date: Thu, 6 May 2021 04:23:46 -0700 Subject: [PATCH 2/3] (feat): add org-roam-graph-filetype (#1513) Co-authored-by: Greg Coladonato --- CHANGELOG.md | 1 + org-roam-graph.el | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 28060f3..ed1f935 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ ### Changed - [#1352](https://github.com/org-roam/org-roam/pull/1352) prefer lower-case for roam_tag and roam_alias in interactive commands +- [#1513](https://github.com/org-roam/org-roam/pull/1513) replaced hardcoded "svg" with defcustom org-roam-graph-filetype ### Fixed - [#1281](https://github.com/org-roam/org-roam/pull/1281) fixed idle-timer not instantiated on `org-roam-mode` diff --git a/org-roam-graph.el b/org-roam-graph.el index e1dbe1c..d115cf2 100644 --- a/org-roam-graph.el +++ b/org-roam-graph.el @@ -61,6 +61,12 @@ It may be one of the following: :type 'string :group 'org-roam) +(defcustom org-roam-graph-filetype "svg" + "File type to generate when producing graphs." + :type 'string + :group 'org-roam) + + (defcustom org-roam-graph-extra-config nil "Extra options passed to graphviz. Example: @@ -238,12 +244,12 @@ CALLBACK is passed the graph file as its sole argument." :group :by file])) (graph (org-roam-graph--dot node-query)) (temp-dot (make-temp-file "graph." nil ".dot" graph)) - (temp-graph (make-temp-file "graph." nil ".svg"))) + (temp-graph (make-temp-file "graph." nil (concat "." org-roam-graph-filetype)))) (org-roam-message "building graph") (make-process :name "*org-roam-graph--build-process*" :buffer "*org-roam-graph--build-process*" - :command `(,org-roam-graph-executable ,temp-dot "-Tsvg" "-o" ,temp-graph) + :command `(,org-roam-graph-executable ,temp-dot "-T" ,org-roam-graph-filetype "-o" ,temp-graph) :sentinel (when callback (lambda (process _event) (when (= 0 (process-exit-status process)) From f754160402ccc12b6e0e8bc6b607d7deef5c5b60 Mon Sep 17 00:00:00 2001 From: Leo Vivier Date: Wed, 12 May 2021 09:06:11 +0200 Subject: [PATCH 3/3] (fix): Fix chronology issue between renaming notes and updating links (#1517) --- org-roam-capture.el | 3 ++- org-roam-db.el | 3 ++- org-roam-faces.el | 2 +- org-roam-link.el | 2 +- org-roam.el | 31 +++++++++++++++++++++++++------ 5 files changed, 31 insertions(+), 10 deletions(-) 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)))