From 6f9a72f1fcf73aba5a3e0c688a8b4bf1749ac09e Mon Sep 17 00:00:00 2001 From: Daneel Date: Tue, 24 Feb 2026 23:34:33 +0100 Subject: [PATCH] =?UTF-8?q?fix=20calfw=20sort:=20cfw:event=20struct=20star?= =?UTF-8?q?t-time=20(month=20view=20nem=C3=A1=20=C4=8Das=20v=20textu,=20st?= =?UTF-8?q?ring=20parse=20nefungoval)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.el | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/config.el b/config.el index 7123fa0..85ed3f0 100644 --- a/config.el +++ b/config.el @@ -1958,15 +1958,25 @@ current frame." "<" #'calfw-navi-prev-view ">" #'calfw-navi-next-view) - ;; Universal sorter: time-of-day prop (agenda source) NEBO "HH:MM " prefix (file source) - (defun my/calfw-extract-time (str) - (when (string-match "^\\([0-9]\\{2\\}\\):\\([0-9]\\{2\\}\\) " str) - (+ (* (string-to-number (match-string 1 str)) 100) - (string-to-number (match-string 2 str))))) - (defun my/calfw-sorter (t1 t2) - (let ((a (or (get-text-property 0 'time-of-day t1) (my/calfw-extract-time t1))) - (b (or (get-text-property 0 'time-of-day t2) (my/calfw-extract-time t2)))) - (cond ((and a b) (< a b)) (a t) (b nil) (t (string-lessp t1 t2))))) + ;; Universal sorter pro cross-source (agenda + file-source): + ;; - file-source: cfw:event struct má :start-time (H M) — to je autoritativní + ;; - agenda source: time-of-day property (HHMM integer) + ;; - month view formát je "%t" bez času, takže string parsing nefunguje + (defun my/calfw-sorter (x y) + (let* ((ex (get-text-property 0 'cfw:event x)) + (ey (get-text-property 0 'cfw:event y)) + (tx (or (and ex (calfw-event-start-time ex)) ; file-source: (H M) + (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 () "Calfw: org-agenda (SeaGreen) + CalDAV soubory (Suky=modrá, Klára=žlutá, Rodina=zelená).