emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Michael Ekstrand <michael@elehack.net>
To: emacs-orgmode@gnu.org
Subject: Re: Feature request: skip blocked lines in agenda view grid
Date: Mon, 20 Oct 2008 21:24:48 -0500	[thread overview]
Message-ID: <87wsg2y9an.fsf@elehack.net> (raw)
In-Reply-To: 873aiuosow.fsf@elehack.net


[-- Attachment #1.1: Type: text/plain, Size: 3371 bytes --]

Michael Ekstrand <michael@elehack.net> writes:
> I'd find it quite helpful in reviewing my agenda if there was an option
> to skip displaying grid lines which happen in the middle of timed
> appointments.  Right now, I see the following:
>
> Saturday   18 October 2008
>                8:00...... ----------------
>               10:00...... ----------------
>               12:00...... ----------------
>               14:00...... ----------------
>               16:00...... ----------------
>   Church:     17:30-19:00 Saturday service
>               18:00...... ----------------
>   master:     19:00...... People over for supper
>               20:00...... ----------------
>
> If it could optionally and intelligently drop the 18:00 grid line
> because there is a previous timed appointment overlapping it, the
> resulting display would show me more clearly that I don't have time
> between it and the next event.

After doing some poking around in the org-mode sources, I found out that
the particular behavior described above isn't overly difficult to
implement; in fact, half the work is already done (at least in the
org-mode in Emacs CVS).  The first element of the `org-agenda-time-grid'
variable (the time grid options) supports an undocumented option
`remove-match' which causes `org-agenda-add-time-grid-maybe' to remove
grid lines which exactly correspond to the start time of an event.  It
is rather trivial to extend this logic to also remove grid lines
occluded by the duration of an event.

I have implemented this as a defadvice for
`org-agenda-add-time-grid-maybe' (I like to implement my org-mode logic
changes as defadvice so that they work on top of pristine org-mode and I
don't have to keep patches in sync or installed).  Code follows, if
anyone wants to throw it in their .emacs:

(defadvice org-agenda-add-time-grid-maybe (around mde-org-agenda-grid-tweakify
                                                  (list ndays todayp))
  (if (member 'remove-match (car org-agenda-time-grid))
      (flet ((extract-window
              (line)
              (let ((start (get-text-property 1 'time-of-day line))
                    (dur (get-text-property 1 'duration line)))
                (cond
                 ((and start dur) (cons start dur))
                 (start start)
                 (t nil)))))
        (let* ((windows (delq nil (mapcar 'extract-window list)))
               (org-agenda-time-grid
                (list (car org-agenda-time-grid)
                      (cadr org-agenda-time-grid)
                      (remove-if
                       (lambda (time)
                         (find-if (lambda (w)
                                    (if (numberp w)
                                        (equal w time)
                                      (and (>= time (car w))
                                           (< time (+ (car w) (cdr w))))))
                                  windows))
                       (caddr org-agenda-time-grid)))))
          ad-do-it))
    ad-do-it))
(ad-activate 'org-agenda-add-time-grid-maybe)

- Michael

-- 
mouse, n: A device for pointing at the xterm in which you want to type.
Confused by the strange files?  I cryptographically sign my messages.
For more information see <http://www.elehack.net/resources/gpg>.

[-- Attachment #1.2: Type: application/pgp-signature, Size: 196 bytes --]

[-- Attachment #2: Type: text/plain, Size: 204 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

  parent reply	other threads:[~2008-10-21  3:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-18 14:59 Feature request: skip blocked lines in agenda view grid Michael Ekstrand
2008-10-20 10:56 ` Carsten Dominik
2008-10-20 13:37 ` Chris McMahan
2008-10-20 21:14   ` Wes Hardaker
2008-10-20 21:19   ` Wes Hardaker
2008-10-21  2:24 ` Michael Ekstrand [this message]
2008-10-21  6:31   ` Carsten Dominik
2008-10-21 13:21     ` Michael Ekstrand
2008-10-21 21:43       ` Carsten Dominik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wsg2y9an.fsf@elehack.net \
    --to=michael@elehack.net \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).