在组织模式的议程中显示空闲时间


12

我想轻松地在组织模式议程中找到空闲时间。

例如,如果我有两个约会,一个是9:30 am-10:30am,另一个是11:15 am-12:30pm,那么我想一眼就知道10:30 am-11:15am是免费的。

换句话说,我希望能够像在Google日历之类的图形议程中一样轻松地区分空闲时间。

有没有一种方法可以使空的时间段容易看清?也许要对超过给定分钟数的空块着色?


2
org-agenda-time-grid不是足以满足您的需求? gnu.org/software/emacs/manual/html_node/org/…–法律
列表

2
网格不够,因为即使在很忙的时候也会显示网格(例如,如果有9:30 am-10:30am会议,则在10:00 am会有网格线)。我希望很容易区分忙碌和不忙碌的时间。
scaramouche 2014年

1
我已经考虑了更多有关此功能的信息。我认为,最有用和最简单的实现方法是更改​​那些具有超过给定数量的时间块的时间块的颜色(仅更改时间块的名称,例如8:00-9:00)。空闲时间(例如,超过15分钟)。颜色和最小空闲时间都应该是用户可配置的。
scaramouche 2014年

3
@scaramouche,组织模式邮件列表(orgmode.org/worg/org-mailing-list.html)上的用户询问您是否尝试过calfwemacswiki.org/emacs/Calfw)。
daveloyall'1

2
@daveloyall,非常感谢您指向邮件列表讨论。我刚刚尝试过Calfw(它很漂亮!),但是它似乎没有我想要的功能(可以直观地看到白天的开放时间)。对于那些想尝试calfw + org的人(强烈建议):从Melpa取得calfw,在init.el,包含(require 'calfw-org)和调用日历do M-x cfw:open-org-calendar
scaramouche 2015年

Answers:


2

由于我自己的这个问题,我查看了org-agenda-add-time-grid-maybe创建时间网格的函数。如果OP注释中要求的时间很忙,则此处张贴的代码(不是我写的)确实会删除网格线。

像您一样,我想以某种方式创建可视块。通过将org-agenda-add-time-grid-maybeMichael Ekstrand 的原始代码和defadvice 混合在另一个线程中,我得出了的以下代码org-agenda-add-time-grid-maybe。它将以不同的颜色输出网格线(在我使用face的那一刻org-archived),时间后面将跟随一个不同的字符串。两者都可以根据您的喜好进行更改。

(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)))

显然,使用defadvice会更优雅,但是我无法弄清楚应该在哪里进行干预。函数本身会遍历每个网格时间(在中设置org-agenda-time-grid),并创建一个包含最终网格(包括面)的新列表(新)。


1
有用,但我真的希望有人提出一种解决方案,该解决方案不涉及直接覆盖中的功能org-agenda
holocronweaver

我绝对同意!不幸的是,我对elisp和组织模式代码的了解不足以提出可行的建议。也许其他人可以在这里提供帮助,可能使用一些“我的”代码。
Fabian
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.