branch: externals/denote commit c76b313352f0b693ef72c9ccad012518681d6477 Author: Kierin Bell <ferns...@fernseed.me> Commit: Kierin Bell <ferns...@fernseed.me>
Fix false matches in 'denote-sequence-get-all-sequences-with-prefix' Change the prefix match test from 'string-prefix-p' to an algorithm that compares entire prefix components individually. --- denote-sequence.el | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/denote-sequence.el b/denote-sequence.el index 40073a7500..858c311a0a 100644 --- a/denote-sequence.el +++ b/denote-sequence.el @@ -380,10 +380,18 @@ With optional SEQUENCES operate on those, else use the return value of `denote-sequence-get-all-sequences'. A sequence is a Denote signature that conforms with `denote-sequence-p'." - (seq-filter - (lambda (string) - (string-prefix-p sequence string)) - (or sequences (denote-sequence-get-all-sequences)))) + (let* ((prefix (denote-sequence-split sequence)) + (depth (length prefix))) + (seq-filter + (lambda (string) + (let ((value (denote-sequence-split string)) + (matched 0)) + (while (and value + (< matched depth) + (string-equal (pop value) (nth matched prefix))) + (setq matched (1+ matched))) + (= matched depth))) + (or sequences (denote-sequence-get-all-sequences))))) (defun denote-sequence-get-all-sequences-with-max-depth (depth &optional sequences) "Get sequences up to DEPTH (inclusive).