Skip to content

Commit

Permalink
Make 'default-directory' safe for denote-directory
Browse files Browse the repository at this point in the history
This relates to the example we cover in the manual, which was updated in
commit 47a9024.

Thanks to Sven Seebeck for reporting the bug in issue 16 over at the
GitHub mirror: <#16>.
  • Loading branch information
protesilaos committed Jun 17, 2022
1 parent 47a9024 commit d09249d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion denote.el
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ If you intend to reference this variable in Lisp, consider using
the function `denote-directory' instead: it returns the path as a
directory."
:group 'denote
:safe (lambda (val)
(and (symbolp val) (eq val 'default-directory)))
:type 'directory)

(defcustom denote-known-keywords
Expand Down Expand Up @@ -230,7 +232,10 @@ We consider those characters illigal for our purposes.")

(defun denote-directory ()
"Return path of variable `denote-directory' as a proper directory."
(let ((path denote-directory))
(let ((path (or (buffer-local-value 'denote-directory (current-buffer))
denote-directory)))
(when (and (symbolp path) (eq path 'default-directory))
(setq path (buffer-local-value 'default-directory (current-buffer))))
(unless (file-directory-p path)
(make-directory path t))
(file-name-as-directory path)))
Expand Down

0 comments on commit d09249d

Please sign in to comment.