branch: externals/denote commit 3d2e1d5aabf9b5d89bbe1cf90b05033d89469ee2 Author: Protesilaos Stavrou <i...@protesilaos.com> Commit: Protesilaos Stavrou <i...@protesilaos.com>
Simplify denote--silo-p with dir-locals-find-file --- denote.el | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/denote.el b/denote.el index 2fe8e5e675..2a33249ac3 100644 --- a/denote.el +++ b/denote.el @@ -514,15 +514,14 @@ things accordingly.") (defun denote--silo-p (path) "Return path to silo if PATH is a silo." - (when (and path (file-directory-p path)) - (with-temp-buffer - (when-let* ((files (directory-files path)) - ((member ".dir-locals.el" files)) - (val (buffer-local-value - 'denote-directory - ;; TODO 2023-02-12: Clean up the created buffer - (get-buffer-create (find-file-noselect path))))) - path)))) + (when-let (((and path (file-directory-p path))) + (dir-locals (dir-locals-find-file path))) + (cond + ((listp dir-locals) + (car dir-locals)) + ((stringp dir-locals) + dir-locals) + (t nil)))) (defun denote--get-silo-path (&optional file levels) "Try to determine if FILE belongs to a silo.