emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/denote 916344321a 01/14: Support permutations of file n


From: ELPA Syncer
Subject: [elpa] externals/denote 916344321a 01/14: Support permutations of file names
Date: Sat, 9 Jul 2022 02:57:35 -0400 (EDT)

branch: externals/denote
commit 916344321a59b0e350fade5963aa3049733b2bbe
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>

    Support permutations of file names
    
    Testing with these:
    
        ;; Identifier only: 20220707T172335.txt
        (denote nil nil)
    
        ;; No title field, but with keywords: 20220707T172349__test.txt
        (denote nil '("test"))
        (denote nil '("test" "two"))
    
        ;; Title, no keywords: 20220707T172458--test.txt
        (denote "test" nil)
    
        ;; Title and keywords (what we always had): 
20220707T172525--test__test.txt
        (denote "test" '("test"))
        (denote "test" '("test" "two"))
---
 denote.el | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/denote.el b/denote.el
index 9729286b91..eb5aec037a 100644
--- a/denote.el
+++ b/denote.el
@@ -466,16 +466,25 @@ output is sorted with `string-lessp'."
     ('text ".txt")
     (_ ".org")))
 
-(defun denote--format-file (path id keywords slug extension)
+(defun denote--format-file (path id keywords title-slug extension)
   "Format file name.
-PATH, ID, KEYWORDS, SLUG are expected to be supplied by `denote'
-or equivalent: they will all be converted into a single string.
-EXTENSION is the file type extension, either a string which
-include the starting dot or the return value of
+PATH, ID, KEYWORDS, TITLE-SLUG are expected to be supplied by
+`denote' or equivalent: they will all be converted into a single
+string.  EXTENSION is the file type extension, either a string
+which include the starting dot or the return value of
 `denote--file-extension'."
   (let ((kws (denote--keywords-combine keywords))
-        (ext (or extension (denote--file-extension))))
-    (format "%s%s--%s__%s%s" path id slug kws ext)))
+        (ext (or extension (denote--file-extension)))
+        (empty-title (string-empty-p title-slug)))
+    (cond
+     ((and keywords title-slug (not empty-title))
+      (format "%s%s--%s__%s%s" path id title-slug kws ext))
+     ((and keywords empty-title)
+      (format "%s%s__%s%s" path id kws ext))
+     ((and title-slug (not empty-title))
+      (format "%s%s--%s%s" path id title-slug ext))
+     (t
+      (format "%s%s%s" path id ext)))))
 
 (defun denote--map-quote-downcase (seq)
   "Quote and downcase elements in SEQ."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]