fix calfw sort: cfw:event struct start-time (month view nemá čas v textu, string parse nefungoval)

This commit is contained in:
2026-02-24 23:34:33 +01:00
parent f6dc7ca679
commit 6f9a72f1fc

View File

@@ -1958,15 +1958,25 @@ current frame."
"<" #'calfw-navi-prev-view "<" #'calfw-navi-prev-view
">" #'calfw-navi-next-view) ">" #'calfw-navi-next-view)
;; Universal sorter: time-of-day prop (agenda source) NEBO "HH:MM " prefix (file source) ;; Universal sorter pro cross-source (agenda + file-source):
(defun my/calfw-extract-time (str) ;; - file-source: cfw:event struct má :start-time (H M) — to je autoritativní
(when (string-match "^\\([0-9]\\{2\\}\\):\\([0-9]\\{2\\}\\) " str) ;; - agenda source: time-of-day property (HHMM integer)
(+ (* (string-to-number (match-string 1 str)) 100) ;; - month view formát je "%t" bez času, takže string parsing nefunguje
(string-to-number (match-string 2 str))))) (defun my/calfw-sorter (x y)
(defun my/calfw-sorter (t1 t2) (let* ((ex (get-text-property 0 'cfw:event x))
(let ((a (or (get-text-property 0 'time-of-day t1) (my/calfw-extract-time t1))) (ey (get-text-property 0 'cfw:event y))
(b (or (get-text-property 0 'time-of-day t2) (my/calfw-extract-time t2)))) (tx (or (and ex (calfw-event-start-time ex)) ; file-source: (H M)
(cond ((and a b) (< a b)) (a t) (b nil) (t (string-lessp t1 t2))))) (let ((v (get-text-property 0 'time-of-day x))) ; agenda: HHMM int
(and v (list (/ v 100) (% v 100))))))
(ty (or (and ey (calfw-event-start-time ey))
(let ((v (get-text-property 0 'time-of-day y)))
(and v (list (/ v 100) (% v 100))))))
(ta (and tx (+ (* 100 (car tx)) (cadr tx)))) ; → HHMM int
(tb (and ty (+ (* 100 (car ty)) (cadr ty)))))
(cond ((and ta tb) (< ta tb))
(ta t)
(tb nil)
(t (string-lessp x y)))))
(defun my/open-calendar () (defun my/open-calendar ()
"Calfw: org-agenda (SeaGreen) + CalDAV soubory (Suky=modrá, Klára=žlutá, Rodina=zelená). "Calfw: org-agenda (SeaGreen) + CalDAV soubory (Suky=modrá, Klára=žlutá, Rodina=zelená).