From e0aee184a76c1940b520023474793f433f1c0f5f Mon Sep 17 00:00:00 2001 From: N V <44036031+progfolio@users.noreply.github.com> Date: Sun, 17 May 2020 03:41:40 -0400 Subject: [PATCH] (fix): prevent org-roam-version from loading org-roam-dev (#659) Instead of visiting file, insert library into temp buffer. Prevents loading .dir-local dev environment, accompanying unsafe-variable prompt. Prevents interference with org-roam.el if already open. --- org-roam.el | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/org-roam.el b/org-roam.el index 6e8fc9d..60ba867 100644 --- a/org-roam.el +++ b/org-roam.el @@ -1026,13 +1026,14 @@ Otherwise, behave as if called interactively." "Return `org-roam' version. Interactively, or when MESSAGE is non-nil, show in the echo area." (interactive) - (let ((version (with-current-buffer (find-file-noselect (locate-library "org-roam.el")) - (save-excursion - (save-match-data - (goto-char (point-min)) - (if (re-search-forward "\\(?:;; Version: \\([^z-a]*?$\\)\\)" nil nil) - (substring-no-properties (match-string 1)) - "N/A")))))) + (let* ((version + (with-temp-buffer + (insert-file-contents-literally (locate-library "org-roam.el")) + (goto-char (point-min)) + (save-match-data + (if (re-search-forward "\\(?:;; Version: \\([^z-a]*?$\\)\\)" nil nil) + (substring-no-properties (match-string 1)) + "N/A"))))) (if (or message (called-interactively-p 'interactive)) (message "%s" version) version)))