[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/denote ee53a100f8: Ensure that 'denote' doesn't create
From: |
ELPA Syncer |
Subject: |
[elpa] externals/denote ee53a100f8: Ensure that 'denote' doesn't create dir via Lisp |
Date: |
Sat, 16 Jul 2022 16:57:28 -0400 (EDT) |
branch: externals/denote
commit ee53a100f8615078ab06fe0bcd66706ca152f548
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Ensure that 'denote' doesn't create dir via Lisp
This is another attempt at a change I made earlier today but reverted
soon thereafter (commit 75d63e, reverted by f279395). The previous
implementation would break the interactive usage of 'denote'.
---
denote.el | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/denote.el b/denote.el
index d1482e1d0f..b778252827 100644
--- a/denote.el
+++ b/denote.el
@@ -721,6 +721,13 @@ Optional DEFAULT-TITLE is used as the default value."
;;;;; The `denote' command
+(defun denote--dir-in-denote-directory-p (directory)
+ "Return DIRECTORY if in variable `denote-directory', else nil."
+ (when-let* ((dir directory)
+ ((string-match-p (expand-file-name (denote-directory))
+ (expand-file-name dir))))
+ dir))
+
;;;###autoload
(defun denote (&optional title keywords file-type subdirectory date)
"Create a new note with the appropriate metadata and file name.
@@ -737,9 +744,11 @@ When called from Lisp, all arguments are optional.
- FILE-TYPE is a symbol among those described in `denote-file-type'.
-- SUBDIRECTORY is a string representing the path to either the value of
- the variable `denote-directory' or a subdirectory thereof. The
- subdirectory must exist: Denote will not create it.
+- SUBDIRECTORY is a string representing the path to either the
+ value of the variable `denote-directory' or a subdirectory
+ thereof. The subdirectory must exist: Denote will not create
+ it. If SUBDIRECTORY does not resolve to a valid path, the
+ variable `denote-directory' is used instead.
- DATE is a string representing a date like 2022-06-30 or a date
and time like 2022-06-16 14:30. A nil value or an empty string
@@ -759,7 +768,8 @@ 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--dir-in-denote-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)))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/denote ee53a100f8: Ensure that 'denote' doesn't create dir via Lisp,
ELPA Syncer <=