branch: externals/denote
commit 1c771bd012c5f6336cbbd24af10ae3caad10f51b
Author: Noboru Ota <[email protected]>
Commit: Protesilaos Stavrou <[email protected]>
fix: 9ce9a24, which has error in determining the file ext
Follow-up patch for GitHub issue #135 and this thread on "Issue with
linking non-text files"
<https://lists.sr.ht/~protesilaos/denote/%3C871qm9vagf.fsf%40protesilaos.com%3E#%[email protected]%3E>
This patch addresses two issues:
1) The previous related commit 9ce9a24 does not correctly determine the
file extension for the case when 'denote-file-type' is explicitly
defined.
When 'denote-file-type' is not org such as markdown-yaml, its extension
is ".md", not the same as denote-file-type (markdown-yaml)
2) 9ce9a24 does not address the case where you (rather edge one)
(a) do not explicitly define 'denote-file-type' (thus org is
assumed)
(b) you create a denote file other than org
(c) you create a non-denote file(s) with the same ID as (b).
In the patch "or" expression is used so that we can prioritize
'denote-file-type' and org file types, and then as a secondary priority
look at 'denote--extensions'. The sequence within this list is not
explicitly define (I would assume it's the alphabetical order).
---
denote.el | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/denote.el b/denote.el
index d662f292e1..3db2e7800d 100644
--- a/denote.el
+++ b/denote.el
@@ -779,9 +779,12 @@ whatever matches `denote-excluded-directories-regexp'."
(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)))))
+ (let ((file-extension (file-name-extension file :period)))
+ (and (denote-file-is-note-p file)
+ (or (string= (denote--file-extension denote-file-type)
+ file-extension)
+ (string= ".org" file-extension)
+ (member file-extension (denote--extensions))))))
files))))
(define-obsolete-function-alias