calfw capture: prompt for time range (empty=all-day)

This commit is contained in:
2026-02-25 15:44:13 +01:00
parent 82bb1658ef
commit 05516c8e9e

View File

@@ -321,7 +321,7 @@
("c" "Calendar event" entry
(file ,(ms/org-file "calendar_outbox.org"))
"* %?\n%(calfw-org-capture-day)\n"
"* %?\n%(my/calfw-capture-timestamp)\n"
:empty-lines 1))))
@@ -1593,10 +1593,23 @@ Skip for beamer exports — beamer uses adjustbox on plain tabular."
:demand t
:config
;; org-capture integration: "a" to add event on selected date
;; Prompts for time range; empty = all-day event
(defun my/calfw-capture-timestamp ()
"Build org timestamp for selected calfw date with optional time prompt."
(let* ((date (calfw-cursor-to-nearest-date))
(y (calendar-extract-year date))
(m (calendar-extract-month date))
(d (calendar-extract-day date))
(dow (calendar-day-name (encode-time 0 0 0 d m y) nil t))
(time (read-string "Time (e.g. 14:00-15:30, empty=all-day): ")))
(if (string-empty-p time)
(format "<%04d-%02d-%02d %s>" y m d dow)
(format "<%04d-%02d-%02d %s %s>" y m d dow time))))
(setq calfw-org-capture-template
'("c" "Calendar event" entry
(file "~/org/calendar_outbox.org")
"* %?\n%(calfw-org-capture-day)\n"))
"* %?\n%(my/calfw-capture-timestamp)\n"))
;; Evil normal state for calfw (SPC = Doom leader works)
(evil-set-initial-state 'calfw-calendar-mode 'normal)