feat calfw: multi-source (Agenda+Suky+Klára+Rodina), universal sorter, calfw-org-create-file-source pro caldav
This commit is contained in:
33
config.el
33
config.el
@@ -1958,10 +1958,39 @@ 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)))))
|
||||
|
||||
(defun my/open-calendar ()
|
||||
"Calfw — stabilní verze, org-agenda-files."
|
||||
"Calfw: org-agenda (SeaGreen) + CalDAV soubory (Suky=modrá, Klára=žlutá, Rodina=zelená).
|
||||
org-caldav ukládá plain active timestamps → calfw-org-create-file-source je správná volba."
|
||||
(interactive)
|
||||
(calfw-org-open-calendar))
|
||||
(condition-case err
|
||||
(let* ((cd (expand-file-name "~/org/caldav/"))
|
||||
(sources (delq nil
|
||||
(list
|
||||
(calfw-org-create-source nil "Agenda" "SeaGreen4")
|
||||
(when (file-exists-p (concat cd "suky.org"))
|
||||
(calfw-org-create-file-source "Suky" (concat cd "suky.org") "SteelBlue"))
|
||||
(when (file-exists-p (concat cd "klara.org"))
|
||||
(calfw-org-create-file-source "Klára" (concat cd "klara.org") "Gold"))
|
||||
(when (file-exists-p (concat cd "family.org"))
|
||||
(calfw-org-create-file-source "Rodina" (concat cd "family.org") "ForestGreen"))))))
|
||||
(calfw-open-calendar-buffer
|
||||
:contents-sources sources
|
||||
:view 'month
|
||||
:custom-map calfw-org-custom-map
|
||||
:sorter #'my/calfw-sorter))
|
||||
(error
|
||||
(message "calfw multi-source: %s → fallback" (error-message-string err))
|
||||
(calfw-org-open-calendar))))
|
||||
|
||||
(map! :leader "o C" #'my/open-calendar))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user