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

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

[elpa] externals/denote 75d63e54e2 3/6: Ensure that 'denote' doesn't cre


From: ELPA Syncer
Subject: [elpa] externals/denote 75d63e54e2 3/6: Ensure that 'denote' doesn't create dir via Lisp
Date: Sat, 16 Jul 2022 03:57:28 -0400 (EDT)

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

    Ensure that 'denote' doesn't create dir via Lisp
---
 denote.el | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/denote.el b/denote.el
index d1482e1d0f..00c04e3410 100644
--- a/denote.el
+++ b/denote.el
@@ -721,6 +721,18 @@ Optional DEFAULT-TITLE is used as the default value."
 
 ;;;;; The `denote' command
 
+;; TODO 2022-07-16: Should we check for an absolute path?  Now it is
+;; relative, so "testing" is true if ~/testing exists when called from
+;; $HOME.
+(defun denote--path-to-directory-p (directory)
+  "Return DIRECTORY if it exists, else throw an `error'.
+This is to ensure that `denote' does not create file paths when
+called from Lisp."
+  (if (and (file-exists-p directory)
+           (file-directory-p directory))
+      directory
+    (error "`%s' does not exist; Denote will not create it; do it manually" 
directory)))
+
 ;;;###autoload
 (defun denote (&optional title keywords file-type subdirectory date)
   "Create a new note with the appropriate metadata and file name.
@@ -759,7 +771,7 @@ When called from Lisp, all arguments are optional.
                    (current-time)
                  (denote--valid-date date)))
          (id (format-time-string denote--id-format date))
-         (denote-directory (or subdirectory (denote-directory))))
+         (denote-directory (or (denote--path-to-directory-p subdirectory) 
(denote-directory))))
     (denote--barf-duplicate-id id)
     (denote--prepare-note (or title "") keywords nil date id)
     (denote--keywords-add-to-history keywords)))



reply via email to

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