feat calfw: barvy + universal sorter (Varianta B: agenda=create-source, caldav=file-source)
This commit is contained in:
41
config.el
41
config.el
@@ -1933,10 +1933,47 @@ current frame."
|
|||||||
(evil-set-initial-state 'calfw-calendar-mode 'emacs)
|
(evil-set-initial-state 'calfw-calendar-mode 'emacs)
|
||||||
(evil-set-initial-state 'calfw-details-mode 'emacs)
|
(evil-set-initial-state 'calfw-details-mode 'emacs)
|
||||||
|
|
||||||
|
;; Pomocná funkce: extrahuj čas z file-source stringu ("10:30 Event" → 1030)
|
||||||
|
(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)))))
|
||||||
|
|
||||||
|
;; Universal sorter: čte time-of-day property (agenda source) NEBO parsuje prefix "HH:MM " (file source)
|
||||||
|
(defun my/calfw-sorter (text1 text2)
|
||||||
|
(let ((t1 (or (get-text-property 0 'time-of-day text1) (my/calfw-extract-time text1)))
|
||||||
|
(t2 (or (get-text-property 0 'time-of-day text2) (my/calfw-extract-time text2))))
|
||||||
|
(cond ((and t1 t2) (< t1 t2))
|
||||||
|
(t1 t)
|
||||||
|
(t2 nil)
|
||||||
|
(t (string-lessp text1 text2)))))
|
||||||
|
|
||||||
(defun my/open-calendar ()
|
(defun my/open-calendar ()
|
||||||
"Otevři calfw org kalendář — stabilní verze bez barev."
|
"Calfw s barvami: Suky=modrá, Klára=žlutá, Rodina=zelená, Agenda=zelená (tmavá).
|
||||||
|
Agenda files → calfw-org-create-source (SCHEDULED/DEADLINE).
|
||||||
|
CalDAV soubory → calfw-org-create-file-source (plain timestamps, správné dny).
|
||||||
|
Universal sorter funguje pro oba typy."
|
||||||
(interactive)
|
(interactive)
|
||||||
(calfw-org-open-calendar))
|
(condition-case err
|
||||||
|
(let* ((cd (expand-file-name "~/org/caldav/"))
|
||||||
|
(sources (delq nil
|
||||||
|
(list
|
||||||
|
;; Agenda: org-agenda-files přes org-agenda machinery
|
||||||
|
(calfw-org-create-source nil "Agenda" "SeaGreen4")
|
||||||
|
;; CalDAV: file-source — plain timestamps, správné dny
|
||||||
|
(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
|
||||||
|
:sorter #'my/calfw-sorter))
|
||||||
|
(error
|
||||||
|
(message "calfw: %s — fallback" (error-message-string err))
|
||||||
|
(calfw-org-open-calendar))))
|
||||||
|
|
||||||
(map! :leader "o C" #'my/open-calendar))
|
(map! :leader "o C" #'my/open-calendar))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user