summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2024-02-10 11:29:51 +0200
committerThanos Apollo <[email protected]>2024-02-10 11:29:51 +0200
commit925cdbe626639f54b9aa4c35f749a86160d66726 (patch)
treec2b040c973f82f09060fc2b07ffb9fda6a980149
parent5c711f345c0e1b113537fe15ebc78f7ba8b6749a (diff)
Add yeetueb--sort-date
This function is from Boruch-Baum fork: <https://github.com/Boruch-Baum/emacs-yeetube.el>
-rw-r--r--yeetube.el13
1 files changed, 13 insertions, 0 deletions
diff --git a/yeetube.el b/yeetube.el
index 67e9e69..02f27d1 100644
--- a/yeetube.el
+++ b/yeetube.el
@@ -515,6 +515,19 @@ column."
(< (string-to-number (replace-regexp-in-string ":" "" (aref (cadr a) 2)))
(string-to-number (replace-regexp-in-string ":" "" (aref (cadr b) 2)))))
+(defun yeetube--sort-date (a b)
+ "PREDICATE for function 'sort'.
+Used by variable 'tabulated-list-format' to sort the \"Date\"
+column."
+ (let* ((intervals '("second" "minute" "hour" "day" "week" "month" "year"))
+ (split-a (split-string (replace-regexp-in-string "s" "" (aref (cadr a) 3))))
+ (split-b (split-string (replace-regexp-in-string "s" "" (aref (cadr b) 3))))
+ (units-a (length (member (nth 1 split-a) intervals)))
+ (units-b (length (member (nth 1 split-b) intervals))))
+ (if (= units-a units-b)
+ (< (string-to-number (nth 0 split-a)) (string-to-number (nth 0 split-b)))
+ (> units-a units-b))))
+
(define-derived-mode yeetube-mode tabulated-list-mode "Yeetube"
"Yeetube mode."
:keymap yeetube-mode-map