mirror of
https://github.com/protesilaos/denote.git
synced 2026-09-15 09:46:24 -04:00
fix(denote-get-path-by-id): #135
Reference: https://github.com/protesilaos/denote/issues/135 This patch change function 'denote-get-path-by-id' to allow for the following: - A single ID points to multiple files with different extensions - Denote needs to find a single file out of the multiple files - This is not necessarily a user error (export an Org file to an HTML) - Denote should let user decide their "primary" file extension The case the patch is intended to fix goes something like this: - You have 20230216__mynotes--tag.org. - You export it to 20230216__mynotes--tag.html. - Both files are in denote-directory - This means you have two files with the same ID with different extensions denote-link-find-file, denote-link-find-backlink, and xref integration might find the html file INSTEAD OF the .org file This is because html is earlier in the alphabetical order than org. Because the function uses seq-find, it will find the .html file first and returns it.
This commit is contained in:
parent
29680f9583
commit
9ce9a245cc
16
denote.el
16
denote.el
|
|
@ -730,11 +730,17 @@ whatever matches `denote-excluded-directories-regexp'."
|
|||
|
||||
(defun denote-get-path-by-id (id)
|
||||
"Return absolute path of ID string in `denote-directory-files'."
|
||||
(seq-find
|
||||
(lambda (file)
|
||||
(and (denote-file-has-identifier-p file)
|
||||
(string-prefix-p id (file-name-nondirectory file))))
|
||||
(denote-directory-files)))
|
||||
(let ((files
|
||||
(seq-filter
|
||||
(lambda (file)
|
||||
(and (denote-file-has-identifier-p file)
|
||||
(string-prefix-p id (file-name-nondirectory file))))
|
||||
(denote-directory-files))))
|
||||
(if (length< files 2) (car files)
|
||||
(seq-find (lambda (file) (and (denote-file-is-note-p file)
|
||||
(or (string= denote-file-type (file-name-extension file))
|
||||
(string= "org" (file-name-extension file)))))
|
||||
files))))
|
||||
|
||||
(define-obsolete-function-alias
|
||||
'denote--get-note-path-by-id
|
||||
|
|
|
|||
Loading…
Reference in a new issue