calfw capture: store date before capture to avoid cfw:component error

calfw-cursor-to-nearest-date fails in capture buffer context.
Fix: my/calfw-capture saves date first, then starts org-capture.
This commit is contained in:
2026-02-25 15:50:27 +01:00
parent 218a38d819
commit 2d07377d42

View File

@@ -1598,6 +1598,15 @@ Skip for beamer exports — beamer uses adjustbox on plain tabular."
:demand t
:config
;; org-capture integration: "a" to add event on selected date
;; Store date from calfw before capture starts
(defvar my/calfw-capture-date nil "Date selected in calfw for capture.")
(defun my/calfw-capture ()
"Start org-capture with calfw date context."
(interactive)
(setq my/calfw-capture-date (calfw-cursor-to-nearest-date))
(org-capture nil "c"))
;; Prompts for start/end time; empty = all-day event
;; Uses active timestamp with time range for timed events,
;; or date-range (-->--) for multi-day events.
@@ -1608,7 +1617,7 @@ Formats matching what org-caldav/ox-icalendar export correctly:
- Timed single day: <2026-02-26 Thu 14:00-15:30>
- All-day multi: <2026-02-26 Thu>--<2026-02-28 Sat>
- Timed multi-day: <2026-02-26 Thu 15:00>--<2026-02-28 Sat 22:00>"
(let* ((date (calfw-cursor-to-nearest-date))
(let* ((date (or my/calfw-capture-date (calendar-current-date)))
(y (calendar-extract-year date))
(m (calendar-extract-month date))
(d (calendar-extract-day date))
@@ -1669,7 +1678,7 @@ Formats matching what org-caldav/ox-icalendar export correctly:
"M" #'calfw-change-view-month
"D" #'calfw-change-view-day
"TAB" #'calfw-navi-next-item-command
"a" #'org-capture
"a" #'my/calfw-capture
"q" #'bury-buffer
"x" #'calfw-org-clean-exit
"RET" #'calfw-org-open-agenda-day