From 6ba209704d1562abf2f41da775e527d40f601986 Mon Sep 17 00:00:00 2001 From: Marco Baringer Date: Sat, 23 May 2026 16:15:10 +0200 Subject: [PATCH 1/2] Fix file-prompt crash when denote-directory contains files like __.js Using denote in a directory that includes files matching '*/__.js' breaks with "Wrong type argument: stringp, nil" on the file prompt. lodash ships such files in node_modules, so accidentally pointing denote at a lodash checkout (or having one under denote-directory) triggers the error. These files pass denote-file-has-denoted-filename-p because the empty keywords section matches denote-keywords-regexp, but they have no identifier, so denote-file-prompt--format-identifier passed nil to propertize during affixation. Return nil in that case; denote-file-prompt-affixate already substitutes "" for a nil prefix. Co-Authored-By: Claude Opus 4.7 (1M context) --- denote.el | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/denote.el b/denote.el index 390c4e2..30e336f 100644 --- a/denote.el +++ b/denote.el @@ -1492,10 +1492,9 @@ there.") (defun denote-file-prompt--format-identifier (file) "Return identifier of FILE for `denote-file-prompt-affixate'." - (let* ((identifier (denote-retrieve-filename-identifier file)) - (date-or-id (or (ignore-errors (denote-id-to-date identifier)) identifier)) - (propertized (propertize date-or-id 'face 'completions-annotations))) - (format "%s " propertized))) + (when-let* ((identifier (denote-retrieve-filename-identifier file)) + (date-or-id (or (ignore-errors (denote-id-to-date identifier)) identifier))) + (format "%s " (propertize date-or-id 'face 'completions-annotations)))) (defun denote-file-prompt--format-keywords-and-signature (file) "Return keywords and signature of FILE for `denote-file-prompt-affixate'." From d47464e23b19a46efd8d21aa870a2ffe82e2b219 Mon Sep 17 00:00:00 2001 From: Marco Baringer Date: Sat, 23 May 2026 16:20:49 +0200 Subject: [PATCH 2/2] Require non-empty captures in the four field regexps denote-{identifier,signature,title,keywords}-regexp used a lazy zero-or-more capture ([^.]*?), so they matched the bare separator followed by an extension, e.g. __.js, --.org, ==.org, @@.org. Combined with denote-file-has-denoted-filename-p, this meant such files were treated as valid denote notes. lodash's node_modules ships __.js files, which made a denote-directory containing a lodash checkout enumerate junk candidates in the file prompt (and previously crash, see preceding commit). Switch to a non-empty lazy capture ([^.]+?) so the field must contain at least one character. Co-Authored-By: Claude Opus 4.7 (1M context) --- denote.el | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/denote.el b/denote.el index 30e336f..3755969 100644 --- a/denote.el +++ b/denote.el @@ -906,16 +906,16 @@ The note's ID is derived from the date and time of its creation.") (defconst denote-date-identifier-regexp "\\([0-9]\\{8\\}\\)\\(T[0-9]\\{6\\}\\)" "Regular expression to match `denote-date-identifier-format'.") -(defconst denote-identifier-regexp "@@\\([^.]*?\\)\\(==.*\\|--.*\\|__.*\\|@@.*\\|\\..*\\)*$" +(defconst denote-identifier-regexp "@@\\([^.]+?\\)\\(==.*\\|--.*\\|__.*\\|@@.*\\|\\..*\\)*$" "Regular expression to match the IDENTIFIER field in a file name.") -(defconst denote-signature-regexp "==\\([^.]*?\\)\\(==.*\\|--.*\\|__.*\\|@@.*\\|\\..*\\)*$" +(defconst denote-signature-regexp "==\\([^.]+?\\)\\(==.*\\|--.*\\|__.*\\|@@.*\\|\\..*\\)*$" "Regular expression to match the SIGNATURE field in a file name.") -(defconst denote-title-regexp "--\\([^.]*?\\)\\(==.*\\|__.*\\|@@.*\\|\\..*\\)*$" +(defconst denote-title-regexp "--\\([^.]+?\\)\\(==.*\\|__.*\\|@@.*\\|\\..*\\)*$" "Regular expression to match the TITLE field in a file name.") -(defconst denote-keywords-regexp "__\\([^.]*?\\)\\(==.*\\|--.*\\|__.*\\|@@.*\\|\\..*\\)*$" +(defconst denote-keywords-regexp "__\\([^.]+?\\)\\(==.*\\|--.*\\|__.*\\|@@.*\\|\\..*\\)*$" "Regular expression to match the KEYWORDS field in a file name.") (make-obsolete-variable