emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/denote 8eb27246a5 267/355: Refine buffer-local 'denote-


From: ELPA Syncer
Subject: [elpa] externals/denote 8eb27246a5 267/355: Refine buffer-local 'denote-directory'; update doc
Date: Sun, 26 Jun 2022 23:58:31 -0400 (EDT)

branch: externals/denote
commit 8eb27246a51197306bcc5928b36ffff127c87f36
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>

    Refine buffer-local 'denote-directory'; update doc
---
 README.org | 15 ++++++++-------
 denote.el  | 22 +++++++++++++++-------
 2 files changed, 23 insertions(+), 14 deletions(-)

diff --git a/README.org b/README.org
index 9e9867a570..019b51a959 100644
--- a/README.org
+++ b/README.org
@@ -919,13 +919,14 @@ default used by regular ~denote~.
 Given Denote's composable code, you can tweak the output however you
 like, including the contents of the file 
([[#h:f69371d5-1843-493d-9ff5-c1ab3b43024e][Tweaking the front matter]]).
 
-If you do place different types of notes in their own directories,
-consider introducing directory-local variables to keep things working
-seamlessly.  An obvious candidate for such a local variable is the
-~denote-directory~: you want notes in =~/Documents/blog/= to treat their
-directory as the canonical one; while those in =~/Documents/random/= to
-do the same for that path.  Write a =.dir-locals.el= file with the
-following contents and place it in each of those directories:
+If you do place different types of notes in their own directories, you
+must introduce directory-local variables to keep things working
+seamlessly.  Otherwise you cannot create notes, retrieve backlinks, and
+so on.  To that end, the ~denote-directory~ variable considers the
+symbols =default-directory= or =local= as safe local variables.  Write a
+=.dir-locals.el= file in each of your non-default notes directories with
+the following contents (replacing =default-directory= with =local=, if
+you prefer):
 
 #+begin_src emacs-lisp
 ;;; Directory Local Variables
diff --git a/denote.el b/denote.el
index cb10570415..a5816179ff 100644
--- a/denote.el
+++ b/denote.el
@@ -90,14 +90,23 @@
 
 ;;;; User options
 
+;; About the autoload: (info "(elisp) File Local Variables")
+
+;;;###autoload (put 'denote-directory 'safe-local-variable (lambda (val) (or 
(eq val 'local) (eq val 'default-directory))))
 (defcustom denote-directory (expand-file-name "~/Documents/notes/")
   "Directory for storing personal notes.
+
+A safe local value of either `default-directory' or `local' can
+be added as a value in a .dir-local.el file.  Do this if you
+intend to use multiple directories for your notes while still
+relying on a global value (which is the value of this variable).
+The Denote manual has a sample (search for '.dir-locals.el').
+
 If you intend to reference this variable in Lisp, consider using
 the function `denote-directory' instead: it returns the path as a
-directory."
+directory and also checks if a safe local value should be used."
   :group 'denote
-  :safe (lambda (val)
-          (and (symbolp val) (eq val 'default-directory)))
+  :safe (lambda (val) (or (eq val 'local) (eq val 'default-directory)))
   :type 'directory)
 
 (defcustom denote-known-keywords
@@ -232,10 +241,9 @@ We consider those characters illigal for our purposes.")
 
 (defun denote-directory ()
   "Return path of variable `denote-directory' as a proper 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))))
+  (let* ((val (or (buffer-local-value 'denote-directory (current-buffer))
+                  denote-directory))
+         (path (if (or (eq val 'default-directory) (eq val 'local)) 
default-directory val)))
     (unless (file-directory-p path)
       (make-directory path t))
     (file-name-as-directory path)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]