Debido a esta pregunta , miré la función org-agenda-add-time-grid-maybe
que crea la cuadrícula de tiempo. El código publicado allí (que no está escrito por mí) elimina una línea de la cuadrícula si el tiempo está ocupado como se solicita en el comentario del OP.
Como tú, quería crear un bloque visual de alguna manera. Al mezclar el código original org-agenda-add-time-grid-maybe
y el desajuste de Michael Ekstrand publicado en el otro hilo, se me ocurrió el siguiente código org-agenda-add-time-grid-maybe
. Producirá las líneas de la cuadrícula en un color diferente (por el momento que uso la cara org-archived
) y los tiempos serán seguidos por una cadena diferente. Ambos se pueden cambiar a su gusto.
(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)))
Obviamente, sería más elegante usar defadvice, pero no pude averiguar exactamente dónde intervenir. La función en sí pasa por cada tiempo de cuadrícula (establecido org-agenda-time-grid
) y crea una nueva lista con la cuadrícula final que incluye caras (nuevo).
org-agenda-time-grid
No es suficiente para sus necesidades? gnu.org/software/emacs/manual/html_node/org/…