mirror of
https://github.com/protesilaos/denote.git
synced 2026-09-10 07:16:20 -04:00
Compare commits
437 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
110ced9999 | ||
|
|
32d83aa68b | ||
|
|
840ca21f92 | ||
|
|
0a157981e5 | ||
|
|
2c8cf137ac | ||
|
|
e401e70405 | ||
|
|
ec73303bff | ||
|
|
42085330f3 | ||
|
|
27cdd67b68 | ||
|
|
b90b26e938 | ||
|
|
5effab91ca | ||
|
|
9ae9d0e1ea | ||
|
|
8f7e988a67 | ||
|
|
7d0c06e0a4 | ||
|
|
9a354e4362 | ||
|
|
9083ad781e | ||
|
|
3718a60305 | ||
|
|
5b632ae958 | ||
|
|
b4978d83cb | ||
|
|
c8aa01c56a | ||
|
|
1004f735b7 | ||
|
|
65f1bbf1de | ||
|
|
8c80d91d06 | ||
|
|
72d90f474e | ||
|
|
cd422b1d22 | ||
|
|
04c39a157f | ||
|
|
35d3a2a724 | ||
|
|
9fd6692a32 | ||
|
|
420710fb17 | ||
|
|
77813e9956 | ||
|
|
cf1c81cba9 | ||
|
|
32960f828b | ||
|
|
197b0acd38 | ||
|
|
d47464e23b | ||
|
|
6ba209704d | ||
|
|
30c0d6536e | ||
|
|
13b2164369 | ||
|
|
e40bdc8cdc | ||
|
|
3ef7380190 | ||
|
|
ea398e9a2a | ||
|
|
dbfe4b189a | ||
|
|
3f5ede71d4 | ||
|
|
1aedcff2d7 | ||
|
|
59eea50d4b | ||
|
|
21b1c81d1a | ||
|
|
d7dab477a1 | ||
|
|
0ff9573362 | ||
|
|
8e6d83c652 | ||
|
|
06c520de36 | ||
|
|
9b8c96f5e8 | ||
|
|
d78ad3f74e | ||
|
|
8112e65bc3 | ||
|
|
c7723784b9 | ||
|
|
b5be053380 | ||
|
|
f113e49988 | ||
|
|
3cd8d47c00 | ||
|
|
348d851eb4 | ||
|
|
7babe195ee | ||
|
|
aedbb0cecd | ||
|
|
97ffb56320 | ||
|
|
7574b8cecd | ||
|
|
29fd39a4d4 | ||
|
|
87a4a02afa | ||
|
|
dd4551ad9c | ||
|
|
231d7d64e8 | ||
|
|
ee1ad314fc | ||
|
|
8b9a4e511d | ||
|
|
5281b7c3fc | ||
|
|
207a365b83 | ||
|
|
568c807d8d | ||
|
|
ec4fed24f7 | ||
|
|
383c52be8d | ||
|
|
5e995cfecc | ||
|
|
59e1304a67 | ||
|
|
aaa75e7f13 | ||
|
|
c3b60fcada | ||
|
|
f6499cbf5c | ||
|
|
0993df4fbc | ||
|
|
b77b926505 | ||
|
|
63c052e1ac | ||
|
|
160444b853 | ||
|
|
4483caee95 | ||
|
|
b4924c853d | ||
|
|
e5260315ec | ||
|
|
21b8c6d024 | ||
|
|
fd4d20b472 | ||
|
|
9dc7420031 | ||
|
|
beb698f632 | ||
|
|
1058caea0c | ||
|
|
dcb3daf81a | ||
|
|
3e8c2c835d | ||
|
|
37beb39c3b | ||
|
|
5e4b95a1b7 | ||
|
|
d0252aff0c | ||
|
|
15415e7956 | ||
|
|
2dae5773f2 | ||
|
|
7b9be290e5 | ||
|
|
acadd80426 | ||
|
|
53bb758384 | ||
|
|
ded4c50b8c | ||
|
|
9d5711ea50 | ||
|
|
90d84d6501 | ||
|
|
627ed49989 | ||
|
|
75ef0f827a | ||
|
|
8dfadbc085 | ||
|
|
7852585578 | ||
|
|
e6f6111d3d | ||
|
|
7f92fd4af3 | ||
|
|
d93056137f | ||
|
|
6c0fb263c8 | ||
|
|
d8c2488622 | ||
|
|
76c2e27e80 | ||
|
|
e1d16ba77b | ||
|
|
2ca985d57b | ||
|
|
6f3649eff4 | ||
|
|
e7478b1627 | ||
|
|
3d24ea54eb | ||
|
|
9f5a16f625 | ||
|
|
da0685d48d | ||
|
|
e5d5a4f2d9 | ||
|
|
2a542e20ff | ||
|
|
3af6cbeb39 | ||
|
|
0db5c56a8d | ||
|
|
8a573f8247 | ||
|
|
7b5fb18fab | ||
|
|
9f70a619db | ||
|
|
9a9f71d109 | ||
|
|
51cbb47311 | ||
|
|
6ffa6881ce | ||
|
|
e9c44eec58 | ||
|
|
927c862685 | ||
|
|
159134fee1 | ||
|
|
0f71f126cc | ||
|
|
3563d2b3fe | ||
|
|
7649f42c88 | ||
|
|
a31969fea2 | ||
|
|
07dcaeebb9 | ||
|
|
bcbc805f4f | ||
|
|
1d1732fb57 | ||
|
|
eaedec7463 | ||
|
|
7ab5f4e9b5 | ||
|
|
8a88fcde81 | ||
|
|
e9e8f6f91e | ||
|
|
b92f185818 | ||
|
|
47207e9cb2 | ||
|
|
c94a8484ca | ||
|
|
23e1e8642b | ||
|
|
1786ebcd0f | ||
|
|
d90f3633de | ||
|
|
0afdc6af14 | ||
|
|
b9ff7e6617 | ||
|
|
301575c318 | ||
|
|
a0b834f53b | ||
|
|
0a076981a9 | ||
|
|
89875abad6 | ||
|
|
46c49e51ee | ||
|
|
9e02bf4bd0 | ||
|
|
786c86f567 | ||
|
|
65255f46df | ||
|
|
b8be7d7bf0 | ||
|
|
cf2a6b082b | ||
|
|
40192c9fcc | ||
|
|
dc50c92ac8 | ||
|
|
2d83bf12a3 | ||
|
|
3a66793dd0 | ||
|
|
d8cd571f91 | ||
|
|
d16465816e | ||
|
|
f55b84317a | ||
|
|
730d3d9734 | ||
|
|
b42fc5fea4 | ||
|
|
9b907d5457 | ||
|
|
2aacd8f90d | ||
|
|
7f91907a79 | ||
|
|
54494edf5a | ||
|
|
a576d8917c | ||
|
|
06cc35ab80 | ||
|
|
e3a363f367 | ||
|
|
1c3f4042f9 | ||
|
|
1d0b6fb5d4 | ||
|
|
bea7718049 | ||
|
|
be6e713d88 | ||
|
|
5203bc00cf | ||
|
|
916dde6ba7 | ||
|
|
6751c1b999 | ||
|
|
0dfaf46a68 | ||
|
|
09a382fc46 | ||
|
|
badafe9782 | ||
|
|
f6243f1ecb | ||
|
|
fde5e924fc | ||
|
|
cdfffbaeaa | ||
|
|
5f082c5a07 | ||
|
|
75c75a90e3 | ||
|
|
ce86684870 | ||
|
|
1064cc2f38 | ||
|
|
bc5f10d963 | ||
|
|
8ea5ac5cd9 | ||
|
|
cc83feb3ba | ||
|
|
f7e6f4d442 | ||
|
|
ee0685ccc7 | ||
|
|
d9537e2c9d | ||
|
|
d9ecf5a988 | ||
|
|
a2476e9ac7 | ||
|
|
7cc62eb5fb | ||
|
|
68a5c712d5 | ||
|
|
4fe3cf165e | ||
|
|
220644d97c | ||
|
|
72e3c01a7b | ||
|
|
04f604877e | ||
|
|
4497f11b35 | ||
|
|
74c7aeeb1b | ||
|
|
42a3f393e2 | ||
|
|
e45fde09c1 | ||
|
|
d86cb70426 | ||
|
|
529148eba6 | ||
|
|
133439ba1e | ||
|
|
c4a6ec07e6 | ||
|
|
a3109ed9b4 | ||
|
|
b30cfcb5c9 | ||
|
|
df76615cf9 | ||
|
|
0f93eee66f | ||
|
|
7851a3b97e | ||
|
|
dda6c5a9f7 | ||
|
|
eff64968fa | ||
|
|
37e9a74f77 | ||
|
|
9f1042f4f6 | ||
|
|
c4cb46f592 | ||
|
|
d94e942ac0 | ||
|
|
252908697a | ||
|
|
cce09d2a25 | ||
|
|
c3675d20e3 | ||
|
|
0fb25e6770 | ||
|
|
84aa0d3bb7 | ||
|
|
8dd6f868be | ||
|
|
50f9496734 | ||
|
|
cd6dd03f80 | ||
|
|
13a4de04c8 | ||
|
|
9e638cc72f | ||
|
|
d69a679b2c | ||
|
|
fcf5bccfd5 | ||
|
|
c1250c9434 | ||
|
|
ff373d18e4 | ||
|
|
d4ba0eb290 | ||
|
|
0cc7a0d918 | ||
|
|
e9bfd528d5 | ||
|
|
451e5009fb | ||
|
|
b89d30de21 | ||
|
|
679c13c5d9 | ||
|
|
0d5ce4f22b | ||
|
|
7482fbc487 | ||
|
|
d509565e6b | ||
|
|
f42b6d663b | ||
|
|
444db90dab | ||
|
|
e1fe1278eb | ||
|
|
d1dcab874e | ||
|
|
e19538b5c5 | ||
|
|
73c2ada5d2 | ||
|
|
fafe2b610f | ||
|
|
83dd0fefb1 | ||
|
|
747bbb914f | ||
|
|
02193f9477 | ||
|
|
89b5275a52 | ||
|
|
9960ca320f | ||
|
|
a39a0e0d1d | ||
|
|
c9a13ee59e | ||
|
|
fec1a41e2e | ||
|
|
e8eb15625d | ||
|
|
667dc1eb9b | ||
|
|
5d5c29dd77 | ||
|
|
a4d6f321b4 | ||
|
|
f4b9028178 | ||
|
|
d58a684f0f | ||
|
|
51fb9c7a4c | ||
|
|
0d696e7c35 | ||
|
|
4905da57ae | ||
|
|
76c13454ae | ||
|
|
7f5d9974f2 | ||
|
|
9b6f3ecee7 | ||
|
|
12090237bc | ||
|
|
70a473d41b | ||
|
|
ef31105cd8 | ||
|
|
80be3d309b | ||
|
|
0b3fdcecb6 | ||
|
|
947f0be070 | ||
|
|
54d9946333 | ||
|
|
85ccf5998d | ||
|
|
1fa853acc0 | ||
|
|
658659c83e | ||
|
|
a234f7a592 | ||
|
|
307db01003 | ||
|
|
955618e75c | ||
|
|
49246e443f | ||
|
|
a416c5b114 | ||
|
|
e2c77a5476 | ||
|
|
94546c048f | ||
|
|
29e9436349 | ||
|
|
2a6bbd5ede | ||
|
|
81d392bf33 | ||
|
|
2103ee198c | ||
|
|
a7c562e4bc | ||
|
|
7707c2681d | ||
|
|
6c3423fc85 | ||
|
|
35fb700d8c | ||
|
|
32eb10d2e7 | ||
|
|
8fc130cec6 | ||
|
|
4d4a8c57e0 | ||
|
|
447930e410 | ||
|
|
e8fa213409 | ||
|
|
38c7c8f195 | ||
|
|
9f0d027609 | ||
|
|
46d1825bf2 | ||
|
|
ef97da673c | ||
|
|
f3f10462f4 | ||
|
|
5f9dd9a90d | ||
|
|
444836c396 | ||
|
|
20dc124e88 | ||
|
|
24b88f1fb5 | ||
|
|
b9ee610cbe | ||
|
|
ad1537d22a | ||
|
|
f704b49df4 | ||
|
|
486abe9dbf | ||
|
|
491ad9a788 | ||
|
|
76ecfd24d6 | ||
|
|
99d5eda377 | ||
|
|
b43149df38 | ||
|
|
5ae68fcc19 | ||
|
|
7c73cbbd52 | ||
|
|
7d82c434e9 | ||
|
|
770c5e41f2 | ||
|
|
91c32fb3c1 | ||
|
|
8ab4fac181 | ||
|
|
a1148a5da5 | ||
|
|
dd662876d4 | ||
|
|
79fc1d2cff | ||
|
|
5a473f9a8b | ||
|
|
ba9f164b8b | ||
|
|
693c43ede8 | ||
|
|
35f79506d1 | ||
|
|
e37c18d843 | ||
|
|
73456765f1 | ||
|
|
c6c02ef2df | ||
|
|
5b0a02d162 | ||
|
|
9885bc6a08 | ||
|
|
0728da8a28 | ||
|
|
d8fd1cb253 | ||
|
|
afb4a9807e | ||
|
|
dfe3608857 | ||
|
|
b8f1a589e1 | ||
|
|
c69210be6c | ||
|
|
cad687b9e6 | ||
|
|
a419ce1c47 | ||
|
|
0001bc9d8c | ||
|
|
8694b092b7 | ||
|
|
fb5b4e31f6 | ||
|
|
a49aa81cfe | ||
|
|
3785194e0e | ||
|
|
5d8738f4bb | ||
|
|
318e10d8e7 | ||
|
|
272e939417 | ||
|
|
d3a8582c91 | ||
|
|
3dc772f683 | ||
|
|
877252b77e | ||
|
|
4c20bf0a57 | ||
|
|
9549d977d5 | ||
|
|
dd86eebffb | ||
|
|
48338bce07 | ||
|
|
1181c734b5 | ||
|
|
6dd9a135b7 | ||
|
|
0dc8cb710c | ||
|
|
1299a416ed | ||
|
|
9f91b9b6a9 | ||
|
|
a4d50fbf71 | ||
|
|
d03f323a39 | ||
|
|
dde56db8c0 | ||
|
|
6e8e321c1b | ||
|
|
2551221933 | ||
|
|
11bbb6b9a1 | ||
|
|
40f2bf5569 | ||
|
|
d4804f87ab | ||
|
|
55e3f9b6b3 | ||
|
|
5c7208e4ed | ||
|
|
e57f38f25b | ||
|
|
d54c41e179 | ||
|
|
2f9ef0cad8 | ||
|
|
e0a4bb42b1 | ||
|
|
2b1625a9c6 | ||
|
|
77ecfa0805 | ||
|
|
e1954dda30 | ||
|
|
da5b7f360a | ||
|
|
3f1e934f2b | ||
|
|
5b0eee109d | ||
|
|
d7c4046f16 | ||
|
|
86ee5cbc4a | ||
|
|
5a0cfd07dc | ||
|
|
11726dae4b | ||
|
|
b54229c724 | ||
|
|
6c2295e75e | ||
|
|
be2eb704a0 | ||
|
|
8f7099eeb8 | ||
|
|
afa3b9495f | ||
|
|
ffb65405e7 | ||
|
|
0150e8ed94 | ||
|
|
5f262d0541 | ||
|
|
8e1341d946 | ||
|
|
e8f9e22892 | ||
|
|
5e144fc77e | ||
|
|
b6e8701f29 | ||
|
|
0900b9461f | ||
|
|
a99d59ad58 | ||
|
|
0f99c17e23 | ||
|
|
34103b2b3a | ||
|
|
77371ac78a | ||
|
|
5dbc394316 | ||
|
|
a6925b1edf | ||
|
|
5ce665d9e4 | ||
|
|
14259e58ca | ||
|
|
354d29db27 | ||
|
|
4abffa78c3 | ||
|
|
a9621ff851 | ||
|
|
8a61780089 | ||
|
|
921cb936f3 | ||
|
|
fcf83579a6 | ||
|
|
f543f305ad | ||
|
|
ffd3bef12b | ||
|
|
807395fcb1 | ||
|
|
7d18f17a19 | ||
|
|
aaa5d30a7c | ||
|
|
5b7157019b | ||
|
|
8e973f12ad | ||
|
|
590787e148 | ||
|
|
7b50b22f63 | ||
|
|
b78efdcab8 | ||
|
|
861f544562 | ||
|
|
d964b567f2 | ||
|
|
34fd0bfc64 | ||
|
|
266207d8b9 | ||
|
|
81e529d8f3 | ||
|
|
cdb44a2d31 |
992
CHANGELOG.org
992
CHANGELOG.org
File diff suppressed because it is too large
Load diff
4
COPYING
4
COPYING
|
|
@ -632,7 +632,7 @@ state the exclusion of warranty; and each file should have at least
|
|||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) 2021 Protesilaos Stavrou
|
||||
Copyright (C) 2021 Protesilaos
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -652,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail.
|
|||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) 2021 Protesilaos Stavrou
|
||||
<program> Copyright (C) 2021 Protesilaos
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,10 @@
|
|||
# denote: Simple notes with an efficient file-naming scheme
|
||||
|
||||
New to Denote? Start reading this from the manual:
|
||||
<https://protesilaos.com/emacs/denote#h:c54bedb4-5377-4dbd-853c-5870ace6eb33>.
|
||||
|
||||
* * *
|
||||
|
||||
Denote is a simple note-taking tool for Emacs. It is based on the idea
|
||||
that notes should follow a predictable and descriptive file-naming
|
||||
scheme. The file name must offer a clear indication of what the note is
|
||||
|
|
|
|||
1802
README.org
1802
README.org
File diff suppressed because it is too large
Load diff
|
|
@ -1,9 +1,9 @@
|
|||
;;; denote-test.el --- Unit tests for Denote -*- lexical-binding: t -*-
|
||||
|
||||
;; Copyright (C) 2023-2025 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 2023-2026 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Protesilaos Stavrou <info@protesilaos.com>
|
||||
;; Maintainer: Protesilaos Stavrou <info@protesilaos.com>
|
||||
;; Author: Protesilaos <info@protesilaos.com>
|
||||
;; Maintainer: Protesilaos <info@protesilaos.com>
|
||||
;; URL: https://github.com/protesilaos/denote
|
||||
|
||||
;; This file is NOT part of GNU Emacs.
|
||||
|
|
@ -37,21 +37,68 @@
|
|||
|
||||
(require 'denote)
|
||||
|
||||
(ert-deftest dt-denote-directories--get-paths ()
|
||||
"Test that `denote-directories--get-paths' returns a list of paths."
|
||||
(let ((path "~/Documents/notes"))
|
||||
(should (equal
|
||||
(denote-directories--get-paths path)
|
||||
(list (file-name-as-directory (expand-file-name path))))))
|
||||
(let ((paths (list "~/Documents/notes" "~/Documents/books")))
|
||||
(should (equal
|
||||
(denote-directories--get-paths paths)
|
||||
(mapcar
|
||||
(lambda (path)
|
||||
(file-name-as-directory (expand-file-name path)))
|
||||
paths)))
|
||||
(should (seq-every-p
|
||||
(lambda (path)
|
||||
(string-suffix-p "/" path))
|
||||
(denote-directories--get-paths paths)))
|
||||
(should-not (null (denote-directories--get-paths paths))))
|
||||
(should-error (denote-directories--get-paths 'hello))
|
||||
(should-error (denote-directories--get-paths '(hello)))
|
||||
(should-error (denote-directories--get-paths '(1 2 3))))
|
||||
|
||||
(ert-deftest dt-denote--make-denote-directory ()
|
||||
"Test that `denote--make-denote-directory' creates the directory."
|
||||
(should (null (denote--make-denote-directory))))
|
||||
(let* ((names (list "denote-test-made-directory-1" "denote-test-made-directory-2"))
|
||||
(directories (mapcar
|
||||
(lambda (directory)
|
||||
(file-name-as-directory (expand-file-name directory temporary-file-directory)))
|
||||
names)))
|
||||
(should-not (denote-directories--make-paths directories))
|
||||
(should (seq-every-p #'file-name-directory directories))
|
||||
(dolist (directory directories)
|
||||
(delete-directory directory))))
|
||||
|
||||
(ert-deftest dt-denote-directory ()
|
||||
"Test that variable `denote-directory' returns an absolute directory name."
|
||||
(let ((path (denote-directory)))
|
||||
(should (and (file-directory-p path)
|
||||
(file-name-absolute-p path)))))
|
||||
(ert-deftest dt-denote-directories ()
|
||||
"Test that `denote-directories' returns list of directories.
|
||||
It does so by expanding the value of the user option `denote-directory'.
|
||||
|
||||
Also see `denote-test--denote--make-denote-directory',
|
||||
`denote-test---denote-directories--get-paths'."
|
||||
(let ((denote-directory "/tmp/denote-test-notes"))
|
||||
(should
|
||||
(equal
|
||||
(denote-directories)
|
||||
(list (file-name-as-directory (expand-file-name denote-directory)))))
|
||||
(should (and (file-directory-p denote-directory)
|
||||
(file-name-absolute-p denote-directory))))
|
||||
(let ((denote-directory (list "/tmp/denote-test-notes-1" "/tmp/denote-test-notes-2")))
|
||||
(should
|
||||
(equal
|
||||
(denote-directories)
|
||||
(mapcar
|
||||
(lambda (directory)
|
||||
(file-name-as-directory (expand-file-name directory)))
|
||||
denote-directory)))
|
||||
(should (and (seq-every-p #'file-directory-p denote-directory)
|
||||
(seq-every-p #'file-name-absolute-p denote-directory)))))
|
||||
|
||||
(ert-deftest dt-denote-sluggify-title ()
|
||||
"Test that `denote-sluggify-title' removes punctuation from the string.
|
||||
Concretely, remove anything specified in `denote-sluggify-title'."
|
||||
(should (equal (denote-sluggify-title "this-is-!@#test")
|
||||
"this-is-test")))
|
||||
(should (equal (denote-sluggify-title "this-is-!@#test") "this-is-test")))
|
||||
|
||||
(ert-deftest dt-denote-slug-keep-only-ascii ()
|
||||
"Test that `denote-slug-keep-only-ascii' removes non-ASCII characters."
|
||||
|
|
@ -63,101 +110,89 @@ Concretely, remove anything specified in `denote-sluggify-title'."
|
|||
"Test that `denote-slug-hyphenate' hyphenates the string.
|
||||
Also replace multiple hyphens with a single one and remove any
|
||||
leading and trailing hyphen."
|
||||
(should (equal (denote-slug-hyphenate "__ This is a test __ ")
|
||||
"This-is-a-test")))
|
||||
(should (equal (denote-slug-hyphenate "__ This is a test __ ") "This-is-a-test")))
|
||||
|
||||
(ert-deftest dt-denote-sluggify ()
|
||||
"Test that `denote-sluggify' sluggifies the string.
|
||||
To sluggify is to (i) downcase, (ii) hyphenate, (iii) de-punctuate, and (iv) remove spaces from the string."
|
||||
(should (equal (denote-sluggify 'title " ___ !~!!$%^ This iS a tEsT ++ ?? ")
|
||||
"this-is-a-test")))
|
||||
(should (equal (denote-sluggify 'title " ___ !~!!$%^ This iS a tEsT ++ ?? ") "this-is-a-test")))
|
||||
|
||||
(ert-deftest Ddenote--slug-put-equals ()
|
||||
"Test that `denote-slug-put-equals' replaces spaces/underscores with =.
|
||||
Otherwise do the same as what is described in
|
||||
`dt-denote-slug-hyphenate'.
|
||||
`denote-test--denote-slug-hyphenate'.
|
||||
|
||||
The use of the equals sign is for the SIGNATURE field of the
|
||||
Denote file name."
|
||||
(should (equal (denote-slug-put-equals "__ This is a test __ ")
|
||||
"This=is=a=test")))
|
||||
(should (equal (denote-slug-put-equals "__ This is a test __ ") "This=is=a=test")))
|
||||
|
||||
(ert-deftest dt-denote-sluggify-signature ()
|
||||
"Test that `denote-sluggify-signature' sluggifies the string for file signatures.
|
||||
This is like `dt-denote-sluggify', except that it also
|
||||
accounts for what we describe in `dt-denote-slug-put-equals'."
|
||||
(should (equal (denote-sluggify-signature "--- ___ !~!!$%^ This -iS- a tEsT ++ ?? ")
|
||||
"this=is=a=test")))
|
||||
This is like `denote-test--denote-sluggify', except that it also
|
||||
accounts for what we describe in `denote-test--denote-slug-put-equals'."
|
||||
(should (equal (denote-sluggify-signature "--- ___ !~!!$%^ This -iS- a tEsT ++ ?? ") "this=is=a=test")))
|
||||
|
||||
(ert-deftest dt-denote-sluggify-keyword ()
|
||||
"Test that `denote-sluggify-keyword' sluggifies the string while joining words.
|
||||
In this context, to join words is to elimitate any space or
|
||||
delimiter between them.
|
||||
|
||||
Otherwise, this is like `dt-denote-sluggify'."
|
||||
(should (equal (denote-sluggify-keyword "--- ___ !~!!$%^ This iS a - tEsT ++ ?? ")
|
||||
"thisisatest")))
|
||||
Otherwise, this is like `denote-test--denote-sluggify'."
|
||||
(should (equal (denote-sluggify-keyword "--- ___ !~!!$%^ This iS a - tEsT ++ ?? ") "thisisatest")))
|
||||
|
||||
(ert-deftest dt-denote-sluggify-keywords ()
|
||||
"Test that `denote-sluggify-keywords' sluggifies a list of strings.
|
||||
The function also account for the value of the user option
|
||||
`denote-allow-multi-word-keywords'."
|
||||
(should
|
||||
(equal (denote-sluggify-keywords '("one !@# --- one" " two" "__ three __"))
|
||||
'("oneone" "two" "three"))))
|
||||
(should (equal (denote-sluggify-keywords '("one !@# --- one" " two" "__ three __")) '("oneone" "two" "three"))))
|
||||
|
||||
(ert-deftest dt-denote-slug-remove-accents ()
|
||||
"Test that `denote-slug-remove-accents' removed diacretics."
|
||||
(should (string= (denote-slug-remove-accents "ê") "e"))
|
||||
(should (string= (denote-slug-remove-accents "ñ") "n")))
|
||||
|
||||
(ert-deftest dt-denote--file-empty-p ()
|
||||
"Test that `denote--file-empty-p' returns non-nil on empty file."
|
||||
;; (should (null (denote--file-empty-p user-init-file))
|
||||
(should (let ((file (make-temp-file "denote-test")))
|
||||
(prog1
|
||||
(denote--file-empty-p file)
|
||||
(delete-file file)))))
|
||||
(let ((file (make-temp-file "denote-test")))
|
||||
(should (denote--file-empty-p file))
|
||||
(with-current-buffer (find-file-noselect file)
|
||||
(insert "Hello world, this is not empty anymore!")
|
||||
(save-buffer))
|
||||
(should-not (denote--file-empty-p file))
|
||||
(delete-file file)))
|
||||
|
||||
(ert-deftest dt-denote-file-is-note-p ()
|
||||
"Test that `denote-file-is-note-p' checks that files is a Denote note.
|
||||
For our purposes, a note must note be a directory, must satisfy
|
||||
`file-regular-p', its path must be part of the variable
|
||||
`denote-directory', it must have a Denote identifier in its name,
|
||||
and use one of the extensions implied by the variable `denote-file-type'."
|
||||
(should (let* ((tmp (temporary-file-directory))
|
||||
(denote-directory tmp)
|
||||
(file (concat tmp "20230522T154900--test__keyword.txt")))
|
||||
(with-current-buffer (find-file-noselect file)
|
||||
(write-file file))
|
||||
(prog1
|
||||
(denote-file-is-note-p file)
|
||||
(delete-file file)))))
|
||||
(ert-deftest dt-denote-file-has-denoted-filename-p ()
|
||||
"Test that `denote-file-has-denoted-filename-p' validates a Denote file name."
|
||||
(should (denote-file-has-denoted-filename-p "20230522T154900--test__keyword.txt"))
|
||||
(should-not (denote-file-has-denoted-filename-p "hello")))
|
||||
|
||||
(ert-deftest dt-denote-file-has-identifier-p ()
|
||||
"Test that `denote-file-has-identifier-p' checks for a Denote identifier."
|
||||
(should (denote-file-has-identifier-p "20230522T154900--test__keyword.txt"))
|
||||
(should (null (denote-file-has-identifier-p "T154900--test__keyword.txt"))))
|
||||
(should-not (denote-file-has-identifier-p "T154900--test__keyword.txt")))
|
||||
|
||||
(ert-deftest dt-denote-file-has-signature-p ()
|
||||
"Test that `denote-file-has-signature-p' checks for a Denote signature."
|
||||
(should (denote-file-has-signature-p "20230522T154900==sig--test__keyword.txt"))
|
||||
(should (null (denote-file-has-signature-p "20230522T154900--test__keyword.txt"))))
|
||||
(should-not (denote-file-has-signature-p "20230522T154900--test__keyword.txt")))
|
||||
|
||||
(ert-deftest dt-denote-file-has-supported-extension-p ()
|
||||
"Test that `denote-file-has-supported-extension-p' matches a supported extension."
|
||||
(should
|
||||
(member
|
||||
(file-name-extension "20230522T154900==sig--test__keyword.txt" :period)
|
||||
(denote-file-type-extensions-with-encryption)))
|
||||
(should
|
||||
(null
|
||||
(member
|
||||
(file-name-extension "20230522T154900==sig--test__keyword" :period)
|
||||
(denote-file-type-extensions-with-encryption)))))
|
||||
(let ((extensions (denote-file-type-extensions-with-encryption)))
|
||||
(should
|
||||
(member
|
||||
(file-name-extension "20230522T154900==sig--test__keyword.txt" :period)
|
||||
extensions))
|
||||
(should-not
|
||||
(member
|
||||
(file-name-extension "20230522T154900==sig--test__keyword" :period)
|
||||
extensions))))
|
||||
|
||||
(ert-deftest dt-denote-file-type-extensions ()
|
||||
"Test that `denote-file-type-extensions' returns file extensions.
|
||||
We check for the common file type extensions, though the user can
|
||||
theoretically set `denote-file-types' to nil and handle things on
|
||||
their own. We do not have to test for that scenario, because
|
||||
such a user will be redefining large parts of Denote's behaviour
|
||||
with regard to file types."
|
||||
We check for the common file type extensions, though the user can set
|
||||
`denote-file-types' to nil and handle things on their own or, anyhow,
|
||||
modify that variable."
|
||||
(let ((extensions (denote-file-type-extensions)))
|
||||
(should (or (member ".md" extensions)
|
||||
(member ".org" extensions)
|
||||
|
|
@ -165,7 +200,7 @@ with regard to file types."
|
|||
|
||||
(ert-deftest dt-denote-file-type-extensions-with-encryption ()
|
||||
"Test that `denote-file-type-extensions-with-encryption' covers encryption.
|
||||
Extend what we do in `dt-denote-file-type-extensions'."
|
||||
Extend what we do in `denote-test--denote-file-type-extensions'."
|
||||
(let ((extensions (denote-file-type-extensions-with-encryption)))
|
||||
(should (or (member ".md" extensions)
|
||||
(member ".org" extensions)
|
||||
|
|
@ -183,360 +218,263 @@ To make the test reproducible, set `denote-date-format' to a value that
|
|||
does not involve the time zone."
|
||||
(let ((denote-date-format "%Y-%m-%d")
|
||||
(denote-front-matter-components-present-even-if-empty-value '(title keywords signature date identifier)))
|
||||
(should (and (equal (denote--format-front-matter "" (date-to-time "20240101T120000") '("") "" "" 'text)
|
||||
(mapconcat #'identity
|
||||
'("title: "
|
||||
"date: 2024-01-01"
|
||||
"tags: "
|
||||
"identifier: "
|
||||
"signature: "
|
||||
"---------------------------\n\n")
|
||||
"\n"))
|
||||
|
||||
(equal
|
||||
(denote--format-front-matter
|
||||
"Some test" (date-to-time "2023-06-05") '("one" "two")
|
||||
"20230605T102234" "sig" 'text)
|
||||
(mapconcat #'identity
|
||||
'("title: Some test"
|
||||
"date: 2023-06-05"
|
||||
"tags: one two"
|
||||
"identifier: 20230605T102234"
|
||||
"signature: sig"
|
||||
"---------------------------\n\n")
|
||||
"\n"))))
|
||||
|
||||
(should (and (equal (denote--format-front-matter "" (date-to-time "20240101T120000") nil "" "" 'org)
|
||||
(mapconcat #'identity
|
||||
'("#+title: "
|
||||
"#+date: 2024-01-01"
|
||||
"#+filetags: "
|
||||
"#+identifier: "
|
||||
"#+signature: "
|
||||
"\n")
|
||||
"\n"))
|
||||
|
||||
(equal
|
||||
(denote--format-front-matter
|
||||
"Some test" (date-to-time "2023-06-05") '("one" "two")
|
||||
"20230605T102234" "sig" 'org)
|
||||
(mapconcat #'identity
|
||||
'("#+title: Some test"
|
||||
"#+date: 2023-06-05"
|
||||
"#+filetags: :one:two:"
|
||||
"#+identifier: 20230605T102234"
|
||||
"#+signature: sig"
|
||||
"\n")
|
||||
"\n"))))
|
||||
|
||||
(should (and (equal (denote--format-front-matter "" (date-to-time "20240101T120000") nil "" "" 'markdown-yaml)
|
||||
(mapconcat #'identity
|
||||
'("---"
|
||||
"title: \"\""
|
||||
"date: 2024-01-01"
|
||||
"tags: []"
|
||||
"identifier: \"\""
|
||||
"signature: \"\""
|
||||
"---"
|
||||
"\n")
|
||||
"\n"))
|
||||
|
||||
(equal
|
||||
(denote--format-front-matter
|
||||
"Some test" (date-to-time "2023-06-05") '("one" "two")
|
||||
"20230605T102234" "sig" 'markdown-yaml)
|
||||
(mapconcat #'identity
|
||||
'("---"
|
||||
"title: \"Some test\""
|
||||
"date: 2023-06-05"
|
||||
"tags: [\"one\", \"two\"]"
|
||||
"identifier: \"20230605T102234\""
|
||||
"signature: \"sig\""
|
||||
"---"
|
||||
"\n")
|
||||
"\n"))))
|
||||
|
||||
(should (and (equal (denote--format-front-matter "" (date-to-time "20240101T120000") nil "" "" 'markdown-toml)
|
||||
(mapconcat #'identity
|
||||
'("+++"
|
||||
"title = \"\""
|
||||
"date = 2024-01-01"
|
||||
"tags = []"
|
||||
"identifier = \"\""
|
||||
"signature = \"\""
|
||||
"+++"
|
||||
"\n")
|
||||
"\n"))
|
||||
|
||||
(equal
|
||||
(denote--format-front-matter
|
||||
"Some test" (date-to-time "2023-06-05") '("one" "two")
|
||||
"20230605T102234" "sig" 'markdown-toml)
|
||||
(mapconcat #'identity
|
||||
'("+++"
|
||||
"title = \"Some test\""
|
||||
"date = 2023-06-05"
|
||||
"tags = [\"one\", \"two\"]"
|
||||
"identifier = \"20230605T102234\""
|
||||
"signature = \"sig\""
|
||||
"+++"
|
||||
"\n")
|
||||
"\n"))))))
|
||||
(should (equal (denote--format-front-matter "" (date-to-time "20240101T120000") '("") "" "" 'text)
|
||||
(string-join
|
||||
'("title: "
|
||||
"date: 2024-01-01"
|
||||
"tags: "
|
||||
"identifier: "
|
||||
"signature: "
|
||||
"---------------------------\n\n")
|
||||
"\n")))
|
||||
(should (equal (denote--format-front-matter "Some test" (date-to-time "2023-06-05") '("one" "two") "20230605T102234" "sig" 'text)
|
||||
(string-join
|
||||
'("title: Some test"
|
||||
"date: 2023-06-05"
|
||||
"tags: one two"
|
||||
"identifier: 20230605T102234"
|
||||
"signature: sig"
|
||||
"---------------------------\n\n")
|
||||
"\n")))
|
||||
(should (equal (denote--format-front-matter "" (date-to-time "20240101T120000") nil "" "" 'org)
|
||||
(string-join
|
||||
'("#+title: "
|
||||
"#+date: 2024-01-01"
|
||||
"#+filetags: "
|
||||
"#+identifier: "
|
||||
"#+signature: "
|
||||
"\n")
|
||||
"\n")))
|
||||
(should (equal
|
||||
(denote--format-front-matter
|
||||
"Some test" (date-to-time "2023-06-05") '("one" "two")
|
||||
"20230605T102234" "sig" 'org)
|
||||
(string-join
|
||||
'("#+title: Some test"
|
||||
"#+date: 2023-06-05"
|
||||
"#+filetags: :one:two:"
|
||||
"#+identifier: 20230605T102234"
|
||||
"#+signature: sig"
|
||||
"\n")
|
||||
"\n")))
|
||||
(should (equal (denote--format-front-matter "" (date-to-time "20240101T120000") nil "" "" 'markdown-yaml)
|
||||
(string-join
|
||||
'("---"
|
||||
"title: \"\""
|
||||
"date: 2024-01-01"
|
||||
"tags: []"
|
||||
"identifier: \"\""
|
||||
"signature: \"\""
|
||||
"---"
|
||||
"\n")
|
||||
"\n")))
|
||||
(should (equal (denote--format-front-matter "Some test" (date-to-time "2023-06-05") '("one" "two") "20230605T102234" "sig" 'markdown-yaml)
|
||||
(string-join
|
||||
'("---"
|
||||
"title: \"Some test\""
|
||||
"date: 2023-06-05"
|
||||
"tags: [\"one\", \"two\"]"
|
||||
"identifier: \"20230605T102234\""
|
||||
"signature: \"sig\""
|
||||
"---"
|
||||
"\n")
|
||||
"\n")))
|
||||
(should (equal (denote--format-front-matter "" (date-to-time "20240101T120000") nil "" "" 'markdown-toml)
|
||||
(string-join
|
||||
'("+++"
|
||||
"title = \"\""
|
||||
"date = 2024-01-01"
|
||||
"tags = []"
|
||||
"identifier = \"\""
|
||||
"signature = \"\""
|
||||
"+++"
|
||||
"\n")
|
||||
"\n")))
|
||||
(should (equal (denote--format-front-matter "Some test" (date-to-time "2023-06-05") '("one" "two") "20230605T102234" "sig" 'markdown-toml)
|
||||
(string-join
|
||||
'("+++"
|
||||
"title = \"Some test\""
|
||||
"date = 2023-06-05"
|
||||
"tags = [\"one\", \"two\"]"
|
||||
"identifier = \"20230605T102234\""
|
||||
"signature = \"sig\""
|
||||
"+++"
|
||||
"\n")
|
||||
"\n")))))
|
||||
|
||||
(ert-deftest dt-denote-format-file-name ()
|
||||
"Test that `denote-format-file-name' returns all expected paths."
|
||||
(let* ((title "Some test")
|
||||
(id (format-time-string denote-id-format (denote-valid-date-p "2023-11-28 05:53:11")))
|
||||
(id (format-time-string denote-date-identifier-format (denote-valid-date-p "2023-11-28 05:53:11")))
|
||||
(denote-directory "/tmp/test-denote")
|
||||
(dir (car (denote-directories)))
|
||||
(ext (denote--file-extension 'org))
|
||||
(kws '("one" "two")))
|
||||
(should-error (denote-format-file-name
|
||||
nil
|
||||
id
|
||||
kws
|
||||
title
|
||||
(denote--file-extension 'org)
|
||||
""))
|
||||
|
||||
(should-error (denote-format-file-name
|
||||
""
|
||||
id
|
||||
kws
|
||||
title
|
||||
(denote--file-extension 'org)
|
||||
""))
|
||||
|
||||
(should-error (denote-format-file-name
|
||||
denote-directory ; notice this is the `let' bound value without the suffix
|
||||
id
|
||||
kws
|
||||
title
|
||||
(denote--file-extension 'org)
|
||||
""))
|
||||
|
||||
(should-error (denote-format-file-name
|
||||
(denote-directory)
|
||||
""
|
||||
nil
|
||||
""
|
||||
(denote--file-extension 'org)
|
||||
""))
|
||||
|
||||
(should (equal (denote-format-file-name
|
||||
(denote-directory)
|
||||
nil
|
||||
kws
|
||||
title
|
||||
(denote--file-extension 'org)
|
||||
"")
|
||||
"/tmp/test-denote/--some-test__one_two.org"))
|
||||
|
||||
(should (equal (denote-format-file-name
|
||||
(denote-directory)
|
||||
""
|
||||
kws
|
||||
title
|
||||
(denote--file-extension 'org)
|
||||
"")
|
||||
"/tmp/test-denote/--some-test__one_two.org"))
|
||||
|
||||
(should (equal (denote-format-file-name
|
||||
(denote-directory)
|
||||
"0123456"
|
||||
kws
|
||||
title
|
||||
(denote--file-extension 'org)
|
||||
"")
|
||||
"/tmp/test-denote/@@0123456--some-test__one_two.org"))
|
||||
|
||||
(should (equal (denote-format-file-name
|
||||
(denote-directory)
|
||||
id
|
||||
kws
|
||||
title
|
||||
(denote--file-extension 'org)
|
||||
"")
|
||||
"/tmp/test-denote/20231128T055311--some-test__one_two.org"))
|
||||
|
||||
(should (equal (denote-format-file-name
|
||||
(denote-directory)
|
||||
id
|
||||
nil
|
||||
""
|
||||
(denote--file-extension 'org)
|
||||
"")
|
||||
"/tmp/test-denote/20231128T055311.org"))
|
||||
|
||||
(should (equal (denote-format-file-name
|
||||
(denote-directory)
|
||||
id
|
||||
nil
|
||||
nil
|
||||
(denote--file-extension 'org)
|
||||
nil)
|
||||
"/tmp/test-denote/20231128T055311.org"))
|
||||
|
||||
(should (equal (denote-format-file-name
|
||||
(denote-directory)
|
||||
id
|
||||
kws
|
||||
title
|
||||
(denote--file-extension 'org)
|
||||
"sig")
|
||||
"/tmp/test-denote/20231128T055311==sig--some-test__one_two.org"))))
|
||||
(should-error (denote-format-file-name nil id kws title ext ""))
|
||||
(should-error (denote-format-file-name "" id kws title ext ""))
|
||||
;; NOTE that `denote-directory' is the `let' bound value without the suffix
|
||||
(should-error (denote-format-file-name denote-directory id kws title ext ""))
|
||||
(should-error (denote-format-file-name dir "" nil "" ext ""))
|
||||
(should (equal (denote-format-file-name dir nil kws title ext "") "/tmp/test-denote/--some-test__one_two.org"))
|
||||
(should (equal (denote-format-file-name dir "" kws title ext "") "/tmp/test-denote/--some-test__one_two.org"))
|
||||
(should (equal (denote-format-file-name dir "0123456" kws title ext "") "/tmp/test-denote/@@0123456--some-test__one_two.org"))
|
||||
(should (equal (denote-format-file-name dir id kws title ext "") "/tmp/test-denote/20231128T055311--some-test__one_two.org"))
|
||||
(should (equal (denote-format-file-name dir id nil "" ext "") "/tmp/test-denote/20231128T055311.org"))
|
||||
(should (equal (denote-format-file-name dir id nil nil ext nil) "/tmp/test-denote/20231128T055311.org"))
|
||||
(should (equal (denote-format-file-name dir id kws title ext "sig") "/tmp/test-denote/20231128T055311==sig--some-test__one_two.org"))))
|
||||
|
||||
(ert-deftest dt-denote-get-file-extension ()
|
||||
"Test that `denote-get-file-extension' gets the correct file extension."
|
||||
(should (and (equal (denote-get-file-extension "20231010T105034--some-test-file__denote_testing") "")
|
||||
(equal (denote-get-file-extension "20231010T105034--some-test-file__denote_testing.org") ".org")
|
||||
(equal (denote-get-file-extension "20231010T105034--some-test-file__denote_testing.org.gpg") ".org.gpg")
|
||||
(equal (denote-get-file-extension "20231010T105034--some-test-file__denote_testing.org.age") ".org.age"))))
|
||||
(should (equal (denote-get-file-extension "20231010T105034--some-test-file__denote_testing") ""))
|
||||
(should (equal (denote-get-file-extension "20231010T105034--some-test-file__denote_testing.org") ".org"))
|
||||
(should (equal (denote-get-file-extension "20231010T105034--some-test-file__denote_testing.org.gpg") ".org.gpg"))
|
||||
(should (equal (denote-get-file-extension "20231010T105034--some-test-file__denote_testing.org.age") ".org.age")))
|
||||
|
||||
(ert-deftest dt-denote-get-file-extension-sans-encryption ()
|
||||
"Test that `denote-get-file-extension-sans-encryption' gets the file extension without encryption."
|
||||
(should (and (equal (denote-get-file-extension-sans-encryption "20231010T105034--some-test-file__denote_testing") "")
|
||||
(equal (denote-get-file-extension-sans-encryption "20231010T105034--some-test-file__denote_testing.org") ".org")
|
||||
(equal (denote-get-file-extension-sans-encryption "20231010T105034--some-test-file__denote_testing.org.gpg") ".org")
|
||||
(equal (denote-get-file-extension-sans-encryption "20231010T105034--some-test-file__denote_testing.org.age") ".org"))))
|
||||
(should (equal (denote-get-file-extension-sans-encryption "20231010T105034--some-test-file__denote_testing") ""))
|
||||
(should (equal (denote-get-file-extension-sans-encryption "20231010T105034--some-test-file__denote_testing.org") ".org"))
|
||||
(should (equal (denote-get-file-extension-sans-encryption "20231010T105034--some-test-file__denote_testing.org.gpg") ".org"))
|
||||
(should (equal (denote-get-file-extension-sans-encryption "20231010T105034--some-test-file__denote_testing.org.age") ".org")))
|
||||
|
||||
;; TODO 2026-04-06: For the `denote-file-type'.
|
||||
|
||||
(ert-deftest dt-denote-filetype-heuristics ()
|
||||
"Test that `denote-filetype-heuristics' gets the correct file type."
|
||||
(should (and (eq (denote-filetype-heuristics "20231010T105034--some-test-file__denote_testing") nil)
|
||||
(eq (denote-filetype-heuristics "20231010T105034--some-test-file__denote_testing.org") 'org)
|
||||
(eq (denote-filetype-heuristics "20231010T105034--some-test-file__denote_testing.org.gpg") 'org)
|
||||
(eq (denote-filetype-heuristics "20231010T105034--some-test-file__denote_testing.org.age") 'org)
|
||||
(eq (denote-filetype-heuristics "20231010T105034--some-test-file__denote_testing.txt") 'text)
|
||||
(eq (denote-filetype-heuristics "20231010T105034--some-test-file__denote_testing.txt.gpg") 'text)
|
||||
(eq (denote-filetype-heuristics "20231010T105034--some-test-file__denote_testing.txt.age") 'text)
|
||||
;; NOTE 2023-10-11: It returns `markdown-yaml' as a fallback. In
|
||||
;; an actual file, it reads the file contents to determine what
|
||||
;; it is and can return `markdown-toml'. In principle, we should
|
||||
;; be testing this here, though I prefer to keep things simple.
|
||||
(eq (denote-filetype-heuristics "20231010T105034--some-test-file__denote_testing.md") 'markdown-yaml)
|
||||
(eq (denote-filetype-heuristics "20231010T105034--some-test-file__denote_testing.md.gpg") 'markdown-yaml)
|
||||
(eq (denote-filetype-heuristics "20231010T105034--some-test-file__denote_testing.md.age") 'markdown-yaml))))
|
||||
|
||||
(ert-deftest dt-denote-get-identifier ()
|
||||
"Test that `denote-get-identifier' returns an identifier."
|
||||
(should (and (equal (denote-get-identifier nil) "")
|
||||
(equal (denote-get-identifier 1705644188) "20240119T080308")
|
||||
(equal (denote-get-identifier '(26026 4251)) "20240119T080307"))))
|
||||
(should-not (denote-filetype-heuristics "20231010T105034--some-test-file__denote_testing"))
|
||||
(should (eq (denote-filetype-heuristics "20231010T105034--some-test-file__denote_testing.org") 'org))
|
||||
(should (eq (denote-filetype-heuristics "20231010T105034--some-test-file__denote_testing.org.gpg") 'org))
|
||||
(should (eq (denote-filetype-heuristics "20231010T105034--some-test-file__denote_testing.org.age") 'org))
|
||||
(should (eq (denote-filetype-heuristics "20231010T105034--some-test-file__denote_testing.txt") 'text))
|
||||
(should (eq (denote-filetype-heuristics "20231010T105034--some-test-file__denote_testing.txt.gpg") 'text))
|
||||
(should (eq (denote-filetype-heuristics "20231010T105034--some-test-file__denote_testing.txt.age") 'text))
|
||||
(should (eq (denote-filetype-heuristics "20231010T105034--some-test-file__denote_testing.md")
|
||||
(caar (denote--file-types-with-extension ".md"))))
|
||||
(should (eq (denote-filetype-heuristics "20231010T105034--some-test-file__denote_testing.md.gpg")
|
||||
(caar (denote--file-types-with-extension ".md"))))
|
||||
(should (eq (denote-filetype-heuristics "20231010T105034--some-test-file__denote_testing.md.age")
|
||||
(caar (denote--file-types-with-extension ".md")))))
|
||||
|
||||
(ert-deftest dt-denote-retrieve-filename-identifier ()
|
||||
"Test that `denote-retrieve-filename-identifier' returns only the identifier."
|
||||
(should (and (null
|
||||
(denote-retrieve-filename-identifier "/path/to/testing/--this-is-a-test-reordered__denote_testing.org"))
|
||||
(equal
|
||||
(denote-retrieve-filename-identifier "/path/to/testing/20240610T194654--this-is-a-test-reordered__denote_testing.org")
|
||||
"20240610T194654")
|
||||
(equal
|
||||
(denote-retrieve-filename-identifier "/path/to/testing/20240610T194654==signature--this-is-a-test-reordered__denote_testing.org")
|
||||
"20240610T194654")
|
||||
(equal
|
||||
(denote-retrieve-filename-identifier "/path/to/testing/--this-is-a-test-reordered__denote_testing@@20240610T194654.org")
|
||||
"20240610T194654")
|
||||
(equal
|
||||
(denote-retrieve-filename-identifier "/path/to/testing/__denote_testing--this-is-a-test-reordered@@20240610T194654.org")
|
||||
"20240610T194654")
|
||||
(equal
|
||||
(denote-retrieve-filename-identifier "/path/to/testing/__denote_testing@@20240610T194654--this-is-a-test-reordered.org")
|
||||
"20240610T194654")
|
||||
(equal
|
||||
(denote-retrieve-filename-identifier "/path/to/testing/==signature__denote_testing@@20240610T194654--this-is-a-test-reordered.org")
|
||||
"20240610T194654"))))
|
||||
(should (null (denote-retrieve-filename-identifier "/path/to/testing/--this-is-a-test-reordered__denote_testing.org")))
|
||||
(should (equal (denote-retrieve-filename-identifier "/path/to/testing/20240610T194654--this-is-a-test-reordered__denote_testing.org") "20240610T194654"))
|
||||
(should (equal (denote-retrieve-filename-identifier "/path/to/testing/20240610T194654==signature--this-is-a-test-reordered__denote_testing.org") "20240610T194654"))
|
||||
(should (equal (denote-retrieve-filename-identifier "/path/to/testing/--this-is-a-test-reordered__denote_testing@@20240610T194654.org") "20240610T194654"))
|
||||
(should (equal (denote-retrieve-filename-identifier "/path/to/testing/__denote_testing--this-is-a-test-reordered@@20240610T194654.org") "20240610T194654"))
|
||||
(should (equal (denote-retrieve-filename-identifier "/path/to/testing/__denote_testing@@20240610T194654--this-is-a-test-reordered.org") "20240610T194654"))
|
||||
(should (equal (denote-retrieve-filename-identifier "/path/to/testing/==signature__denote_testing@@20240610T194654--this-is-a-test-reordered.org") "20240610T194654")))
|
||||
|
||||
(ert-deftest dt-denote-retrieve-filename-title ()
|
||||
"Test that `denote-retrieve-filename-title' returns only the title."
|
||||
(should (and (null
|
||||
(denote-retrieve-filename-title "/path/to/testing/20240610T194654__denote_testing.org"))
|
||||
(equal
|
||||
(denote-retrieve-filename-title "/path/to/testing/20240610T194654--this-is-a-test-reordered__denote_testing.org")
|
||||
"this-is-a-test-reordered")
|
||||
(equal
|
||||
(denote-retrieve-filename-title "/path/to/testing/20240610T194654==signature--this-is-a-test-reordered__denote_testing.org")
|
||||
"this-is-a-test-reordered")
|
||||
(equal
|
||||
(denote-retrieve-filename-title "/path/to/testing/--this-is-a-test-reordered__denote_testing@@20240610T194654.org")
|
||||
"this-is-a-test-reordered")
|
||||
(equal
|
||||
(denote-retrieve-filename-title "/path/to/testing/__denote_testing--this-is-a-test-reordered@@20240610T194654.org")
|
||||
"this-is-a-test-reordered")
|
||||
(equal
|
||||
(denote-retrieve-filename-title "/path/to/testing/__denote_testing@@20240610T194654--this-is-a-test-reordered.org")
|
||||
"this-is-a-test-reordered")
|
||||
(equal
|
||||
(denote-retrieve-filename-title "/path/to/testing/==signature__denote_testing@@20240610T194654--this-is-a-test-reordered.org")
|
||||
"this-is-a-test-reordered"))))
|
||||
(should (null (denote-retrieve-filename-title "/path/to/testing/20240610T194654__denote_testing.org")))
|
||||
(should (equal (denote-retrieve-filename-title "/path/to/testing/20240610T194654--this-is-a-test-reordered__denote_testing.org") "this-is-a-test-reordered"))
|
||||
(should (equal (denote-retrieve-filename-title "/path/to/testing/20240610T194654==signature--this-is-a-test-reordered__denote_testing.org") "this-is-a-test-reordered"))
|
||||
(should (equal (denote-retrieve-filename-title "/path/to/testing/--this-is-a-test-reordered__denote_testing@@20240610T194654.org") "this-is-a-test-reordered"))
|
||||
(should (equal (denote-retrieve-filename-title "/path/to/testing/__denote_testing--this-is-a-test-reordered@@20240610T194654.org") "this-is-a-test-reordered"))
|
||||
(should (equal (denote-retrieve-filename-title "/path/to/testing/__denote_testing@@20240610T194654--this-is-a-test-reordered.org") "this-is-a-test-reordered"))
|
||||
(should (equal (denote-retrieve-filename-title "/path/to/testing/==signature__denote_testing@@20240610T194654--this-is-a-test-reordered.org") "this-is-a-test-reordered")))
|
||||
|
||||
(ert-deftest dt-denote-retrieve-filename-keywords ()
|
||||
"Test that `denote-retrieve-filename-keywords' returns only the keywords."
|
||||
(should (and (null
|
||||
(denote-retrieve-filename-keywords "/path/to/testing/20240610T194654--this-is-a-test-reordered.org"))
|
||||
(equal
|
||||
(denote-retrieve-filename-keywords "/path/to/testing/20240610T194654--this-is-a-test-reordered__denote_testing.org")
|
||||
"denote_testing")
|
||||
(equal
|
||||
(denote-retrieve-filename-keywords "/path/to/testing/20240610T194654==signature--this-is-a-test-reordered__denote_testing.org")
|
||||
"denote_testing")
|
||||
(equal
|
||||
(denote-retrieve-filename-keywords "/path/to/testing/--this-is-a-test-reordered__denote_testing@@20240610T194654.org")
|
||||
"denote_testing")
|
||||
(equal
|
||||
(denote-retrieve-filename-keywords "/path/to/testing/__denote_testing--this-is-a-test-reordered@@20240610T194654.org")
|
||||
"denote_testing")
|
||||
(equal
|
||||
(denote-retrieve-filename-keywords "/path/to/testing/__denote_testing@@20240610T194654--this-is-a-test-reordered.org")
|
||||
"denote_testing")
|
||||
(equal
|
||||
(denote-retrieve-filename-keywords "/path/to/testing/==signature__denote_testing@@20240610T194654--this-is-a-test-reordered.org")
|
||||
"denote_testing"))))
|
||||
(should (null (denote-retrieve-filename-keywords "/path/to/testing/20240610T194654--this-is-a-test-reordered.org")))
|
||||
(should (equal (denote-retrieve-filename-keywords "/path/to/testing/20240610T194654--this-is-a-test-reordered__denote_testing.org") "denote_testing"))
|
||||
(should (equal (denote-retrieve-filename-keywords "/path/to/testing/20240610T194654==signature--this-is-a-test-reordered__denote_testing.org") "denote_testing"))
|
||||
(should (equal (denote-retrieve-filename-keywords "/path/to/testing/--this-is-a-test-reordered__denote_testing@@20240610T194654.org") "denote_testing"))
|
||||
(should (equal (denote-retrieve-filename-keywords "/path/to/testing/__denote_testing--this-is-a-test-reordered@@20240610T194654.org") "denote_testing"))
|
||||
(should (equal (denote-retrieve-filename-keywords "/path/to/testing/__denote_testing@@20240610T194654--this-is-a-test-reordered.org") "denote_testing"))
|
||||
(should (equal (denote-retrieve-filename-keywords "/path/to/testing/==signature__denote_testing@@20240610T194654--this-is-a-test-reordered.org") "denote_testing")))
|
||||
|
||||
(ert-deftest dt-denote-retrieve-filename-signature ()
|
||||
"Test that `denote-retrieve-filename-signature' returns only the signature."
|
||||
(should (and (null
|
||||
(denote-retrieve-filename-signature "/path/to/testing/20240610T194654--this-is-a-test-reordered__denote_testing.org"))
|
||||
(equal
|
||||
(denote-retrieve-filename-signature "/path/to/testing/20240610T194654==signature--this-is-a-test-reordered__denote_testing.org")
|
||||
"signature")
|
||||
(equal
|
||||
(denote-retrieve-filename-signature "/path/to/testing/--this-is-a-test-reordered==signature__denote_testing@@20240610T194654.org")
|
||||
"signature")
|
||||
(equal
|
||||
(denote-retrieve-filename-signature "/path/to/testing/__denote_testing--this-is-a-test-reordered==signature@@20240610T194654.org")
|
||||
"signature")
|
||||
(equal
|
||||
(denote-retrieve-filename-signature "/path/to/testing/__denote_testing@@20240610T194654--this-is-a-test-reordered==signature.org")
|
||||
"signature")
|
||||
(equal
|
||||
(denote-retrieve-filename-signature "/path/to/testing/==signature__denote_testing@@20240610T194654--this-is-a-test-reordered.org")
|
||||
"signature"))))
|
||||
(should (null (denote-retrieve-filename-signature "/path/to/testing/20240610T194654--this-is-a-test-reordered__denote_testing.org")))
|
||||
(should (equal (denote-retrieve-filename-signature "/path/to/testing/20240610T194654==signature--this-is-a-test-reordered__denote_testing.org") "signature"))
|
||||
(should (equal (denote-retrieve-filename-signature "/path/to/testing/--this-is-a-test-reordered==signature__denote_testing@@20240610T194654.org") "signature"))
|
||||
(should (equal (denote-retrieve-filename-signature "/path/to/testing/__denote_testing--this-is-a-test-reordered==signature@@20240610T194654.org") "signature"))
|
||||
(should (equal (denote-retrieve-filename-signature "/path/to/testing/__denote_testing@@20240610T194654--this-is-a-test-reordered==signature.org") "signature"))
|
||||
(should (equal (denote-retrieve-filename-signature "/path/to/testing/==signature__denote_testing@@20240610T194654--this-is-a-test-reordered.org") "signature")))
|
||||
|
||||
(ert-deftest dt-denote-identifier-p ()
|
||||
"Test that `denote-identifier-p' works for Denote identifiers."
|
||||
(should (and (denote-identifier-p "20240901T090910")
|
||||
(null (denote-identifier-p "20240901T090910-not-identifier-format")))))
|
||||
(ert-deftest dt-denote-date-identifier-p ()
|
||||
"Test that `denote-date-identifier-p' works for Denote identifiers."
|
||||
(should (denote-date-identifier-p "20240901T090910"))
|
||||
(should-not (denote-date-identifier-p "20240901T090910-not-identifier-format")))
|
||||
|
||||
(ert-deftest dt-denote--id-to-date ()
|
||||
"Test that `denote--id-to-date' returns the date from an identifier."
|
||||
(should (equal (denote--id-to-date "20240901T090910") "2024-09-01"))
|
||||
(should-error (denote--id-to-date "20240901T090910-not-identifier-format")))
|
||||
(ert-deftest dt-denote-id-to-date ()
|
||||
"Test that `denote-id-to-date' returns the date from an identifier."
|
||||
(should (equal (denote-id-to-date "20240901T090910") "2024-09-01"))
|
||||
(should-error (denote-id-to-date "20240901T090910-not-identifier-format")))
|
||||
|
||||
(ert-deftest dt-denote--date-convert ()
|
||||
"Test that `denote--date-convert' works with dates."
|
||||
(should (and
|
||||
(equal (denote--date-convert '(26454 45206 461174 657000) :list)
|
||||
'(26454 45206 461174 657000))
|
||||
|
||||
(equal (denote--date-convert '(26454 45206 461174 657000) :string)
|
||||
"2024-12-09 10:55:50")
|
||||
|
||||
(equal (denote--date-convert nil :string)
|
||||
"")
|
||||
|
||||
(equal (denote--date-convert nil :list)
|
||||
nil)))
|
||||
(should (equal (denote--date-convert '(26454 45206 461174 657000) :list) '(26454 45206 461174 657000)))
|
||||
(should (equal (denote--date-convert '(26454 45206 461174 657000) :string) "2024-12-09 10:55:50"))
|
||||
(should (equal (denote--date-convert nil :string) ""))
|
||||
(should (equal (denote--date-convert nil :list) nil))
|
||||
(should-error (denote--date-convert '(26454 45206 461174 657000) :not-valid-type))
|
||||
(should-error (denote--date-convert nil :not-valid-type)))
|
||||
|
||||
;; TODO 2026-02-23: Add support for Windows paths. But I need somebody who has a Windows machine...
|
||||
(ert-deftest dt-denote--get-common-root-directory ()
|
||||
"Test that `denote--get-common-root-directory' returns the right path."
|
||||
(should (string=
|
||||
(denote--get-common-root-directory
|
||||
'("/home/prot/Documents/notes/"
|
||||
"/home/prot/Documents/notes/attachments"))
|
||||
"/home/prot/Documents/notes/"))
|
||||
(should (string=
|
||||
(denote--get-common-root-directory
|
||||
'("/home/prot/Documents/"
|
||||
"/home/prot/Documents/notes/attachments"))
|
||||
"/home/prot/Documents/"))
|
||||
(should (string=
|
||||
(denote--get-common-root-directory
|
||||
'("/home/prot/Books/"
|
||||
"/home/prot/Documents/notes/"))
|
||||
"/home/prot/"))
|
||||
(should (string=
|
||||
(denote--get-common-root-directory
|
||||
'("/tmp/notes/"
|
||||
"/home/prot/Documents/notes/"))
|
||||
"/"))
|
||||
(should (string=
|
||||
(denote--get-common-root-directory
|
||||
'("/home/prot/Documents/notes/"))
|
||||
"/home/prot/Documents/notes/"))
|
||||
(should-error (denote--get-common-root-directory '("~/Documents/notes/"))))
|
||||
|
||||
(ert-deftest dt-denote-query--keywords-as-regexp ()
|
||||
"Test that `denote-query--keywords-as-regexp' works as intended."
|
||||
(should (string= (denote-query--keywords-as-regexp '("one" "two")) "_\\(?:one\\|two\\)"))
|
||||
(should-error (denote-query--keywords-as-regexp "one"))
|
||||
(should-error (denote-query--keywords-as-regexp '("one" 1))))
|
||||
|
||||
(ert-deftest dt-denote-file-type ()
|
||||
"Test that function `denote-file-type' does what it is meant to."
|
||||
(let* ((create-file-fn (lambda (name extension)
|
||||
(expand-file-name
|
||||
(format "denote-test-file-type-%s.%s" name extension)
|
||||
(temporary-file-directory))))
|
||||
(modify-file-fn (lambda (file contents)
|
||||
(with-current-buffer (find-file-noselect file)
|
||||
(erase-buffer)
|
||||
(insert contents)
|
||||
(save-buffer))))
|
||||
(yaml-file (funcall create-file-fn "yaml" "md"))
|
||||
(toml-file (funcall create-file-fn "toml" "md"))
|
||||
(org-file (funcall create-file-fn "org" "org")))
|
||||
(progn
|
||||
(funcall modify-file-fn yaml-file denote-yaml-front-matter)
|
||||
(should (eq (denote-file-type yaml-file) 'markdown-yaml)))
|
||||
(progn
|
||||
(funcall modify-file-fn toml-file denote-toml-front-matter)
|
||||
(should (eq (denote-file-type toml-file) 'markdown-toml)))
|
||||
(progn
|
||||
(funcall modify-file-fn org-file denote-org-front-matter)
|
||||
(should (eq (denote-file-type org-file) 'org)))
|
||||
(should-not (denote-file-type "test"))
|
||||
(let ((denote-file-types nil))
|
||||
(should-not (denote-file-type "test.md")))))
|
||||
|
||||
(provide 'denote-test)
|
||||
;;; denote-test.el ends here
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue