[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/denote 9ce9a245cc 1/2: fix(denote-get-path-by-id): #135
From: |
ELPA Syncer |
Subject: |
[elpa] externals/denote 9ce9a245cc 1/2: fix(denote-get-path-by-id): #135 |
Date: |
Tue, 7 Mar 2023 07:58:05 -0500 (EST) |
branch: externals/denote
commit 9ce9a245cc70723dbe8d7a65bf980abf62252b10
Author: Noboru Ota <me@nobiot.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
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.
---
denote.el | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/denote.el b/denote.el
index 543e40c27d..3ead50a7d8 100644
--- a/denote.el
+++ b/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