Karena pertanyaan saya sendiri, saya melihat fungsi org-agenda-add-time-grid-maybe
yang menciptakan grid waktu. Kode yang diposting di sana (yang tidak ditulis oleh saya) tidak menghapus garis kisi jika waktu sibuk seperti yang diminta dalam komentar OP.
Seperti Anda, saya ingin membuat blok visual dalam beberapa cara. Dengan mencampur kode asli org-agenda-add-time-grid-maybe
dan defadvice oleh Michael Ekstrand diposting di utas lainnya saya datang dengan kode berikut untuk org-agenda-add-time-grid-maybe
. Ini akan menampilkan garis grid dalam warna yang berbeda (untuk saat ini saya menggunakan wajah org-archived
) dan waktu akan diikuti oleh string yang berbeda. Keduanya dapat diubah sesuai keinginan Anda.
(defun org-agenda-add-time-grid-maybe (list ndays todayp)
"Add a time-grid for agenda items which need it.
LIST is the list of agenda items formatted by `org-agenda-list'.
NDAYS is the span of the current agenda view.
TODAYP is t when the current agenda view is on today."
(catch 'exit
(cond ((not org-agenda-use-time-grid) (throw 'exit list))
((and todayp (member 'today (car org-agenda-time-grid))))
((and (= ndays 1) (member 'daily (car org-agenda-time-grid))))
((member 'weekly (car org-agenda-time-grid)))
(t (throw 'exit list)))
(let* ((blocks (mapcar (lambda (x)
(let ((start (get-text-property 1 'time-of-day x))
(dur (get-text-property 1 'duration x)))
(cond
((and start dur) (cons start
(org-time-from-minutes
(truncate
(+ dur (org-time-to-minutes start))))))
(start start)
(t nil))))
list))
(have (delq nil (mapcar
(lambda (x) (get-text-property 1 'time-of-day x))
list)))
(string (nth 3 org-agenda-time-grid))
(gridtimes (nth 1 org-agenda-time-grid))
(req (car org-agenda-time-grid))
(remove (member 'remove-match req))
new time)
(if (and (member 'require-timed req) (not have))
;; don't show empty grid
(throw 'exit list))
(while (setq time (pop gridtimes))
(unless (and remove (member time have))
(let* ((windows (delq nil blocks))
(hit nil))
(dolist (busy windows)
(unless hit
(when (and (>= time (car busy))
(< time (cdr busy)))
(setq hit t))))
(setq time (replace-regexp-in-string " " "0" (format "%04s" time)))
(if hit
(progn
(push (org-agenda-format-item
(concat string " dito") string nil "" nil
(concat (substring time 0 -2) ":" (substring time -2)))
new)
(put-text-property 2 (length (car new)) 'face 'org-archived (car new)))
(progn
(push (org-agenda-format-item
nil string nil "" nil
(concat (substring time 0 -2) ":" (substring time -2)))
new)
(put-text-property 2 (length (car new)) 'face 'org-time-grid (car new))))
(setq hit nil))))
(when (and todayp org-agenda-show-current-time-in-grid)
(push (org-agenda-format-item
nil org-agenda-current-time-string nil "" nil
(format-time-string "%H:%M "))
new)
(put-text-property
2 (length (car new)) 'face 'org-agenda-current-time (car new)))
(if (member 'time-up org-agenda-sorting-strategy-selected)
(append new list)
(append list new)))))
(defun org-time-to-minutes (time)
"Convert an HHMM TIME to minutes."
(+ (* (/ time 100) 60) (% time 100)))
(defun org-time-from-minutes (minutes)
"Convert a number of MINUTES to an HHMM time."
(+ (* (/ minutes 60) 100) (% minutes 60)))
Jelas, akan lebih elegan untuk menggunakan defadvice, tetapi saya tidak bisa mencari tahu di mana tepatnya untuk campur tangan. Fungsi itu sendiri melewati setiap waktu kisi (ditetapkan org-agenda-time-grid
) dan membuat daftar baru dengan kisi akhir termasuk wajah (baru).
org-agenda-time-grid
tidak cukup untuk kebutuhan Anda? gnu.org/software/emacs/manual/html_node/org/…