fix calfw sort: cfw:event struct start-time (month view nemá čas v textu, string parse nefungoval)
This commit is contained in:
28
config.el
28
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á).
|
||||
|
||||
Reference in New Issue
Block a user