6086 comments
2357 subscribers
6228 on Twitter
Subscribe! Feed reader E-mail

Emacs Org: Display a subset of tasks by context

I wanted to get a quick preview of my top three tasks by context. Since org-tags-view didn’t seem to have a built-in way to limit the
number of displayed items, I used defadvice to add my own. Here’s the relevant code from my Emacs configuration:

(defvar sacha/org-agenda-limit-items nil "Number of items to show in agenda to-do views; nil if unlimited.")
(defadvice org-agenda-finalize-entries (around sacha activate)
  (if sacha/org-agenda-limit-items
      (progn
        (setq list (mapcar 'org-agenda-highlight-todo list))
        (if nosort
          (setq ad-return-value
            (subseq list 0 sacha/org-agenda-limit-items))
          (when org-agenda-before-sorting-filter-function
            (setq list (delq nil (mapcar org-agenda-before-sorting-filter-function list))))
          (setq ad-return-value
                (mapconcat 'identity
                           (subseq
                            (sort list 'org-entries-lessp)
                            0
                            sacha/org-agenda-limit-items)
                           "\n"))))
    ad-do-it))

and the snippet from my org-agenda-custom-commands:

(setq org-agenda-custom-commands
  '(
    ;; ... other commands go here
    ("0" "Block agenda"
         ((tags-todo "+@phone")
          (tags-todo "+@work")
          (tags-todo "+@drawing")
          (tags-todo "+@coding")
          (tags-todo "+@writing")
          (tags-todo "+@computer")
          (tags-todo "+@home"))
         ((org-agenda-sorting-strategy '(priority-up effort-down))
          (sacha/org-agenda-limit-items 3)))
        (")" "Block agenda"
         ((tags-todo "+@phone")
          (tags-todo "+@work")
          (tags-todo "+@drawing")
          (tags-todo "+@coding")
          (tags-todo "+@writing")
          (tags-todo "+@computer")
          (tags-todo "+@home"))
         ((org-agenda-sorting-strategy '(priority-down effort-down))
          (sacha/org-agenda-limit-items nil)))
        ("9" "Unscheduled by context"
         ((tags-todo "+@phone")
          (tags-todo "+@work")
          (tags-todo "+@drawing")
          (tags-todo "+@coding")
          (tags-todo "+@writing")
          (tags-todo "+@computer")
          (tags-todo "+@home"))
         ((org-agenda-skip-function
           (lambda nil
             (org-agenda-skip-entry-if (quote scheduled) (quote deadline)
                                       (quote regexp) "\n]+>")))
          (org-agenda-sorting-strategy '(priority-down effort-down))
          (sacha/org-agenda-limit-items 3)))
    ;; ... more after this
))

This way, I can see all of my common contexts on one screen, and I can decide what I want to work on first.

Short URL: http://sachachua.com/blog/p/24310

On This Day...

  • 2011: Figuring out my CSS workflow — Yesterday’s coding session with CSS was fantastic. I used WinWarden to make my browser translucent, and I overlaid it on [...]
  • 2010: Thinking about housework — I’ve been thinking about the ideas in the book “168 Hours”, which strongly recommends personal outsourcing as a way of [...]
  • 2009: What will you stop doing? — New Year’s Day is just a day, a chronological convention. The long holiday season is a good time to reflect [...]
  • 2008: Websites that write websites — “So nat’ralists observe, a flea Hath smaller fleas that on him prey, [...]
  • 2006: I give up on WPA and WPC11! — After several days of compiling and recompiling kernels and tracking down HOWTOs and fiddling with configuration files, I officially give up on [...]
  • 2005: The five-year journal — Check out Cool Tools: The 5 Year Journal for a journal that promotes seredipitous discovery and reflection. =) Maybe I [...]
  • 2005: Fire — There was a big fire right next to our house. We all got out safely, including the pets. Fire In the meantime, [...]
  • 2004: More open source work — sachac: you'd be remiss if you don't include pmana's work. ;) and of course, iptraf is by a pinoy.
  • 2004: And the rest of the year passed by in a blur — August Turned 21. Threw birthday party/send-off party. Didn’t blog much; was very busy. September, 2004.10.01 Japanese language studies. Lots of lectures blogged. November Training at [...]
  • 2004: July — 7/21 Made it to the shortlist of the AOTS program, then 7/28 finally got confirmed. 7/30 Said goodbye. 7/30 Also [...]
  • 2004: June — Many notes on cooking and teaching. - 6/27: The start of my life as a street performer / amateur arsonist
  • 2004: May — - 5/12: Reflections on the Getting Things Done methodology Boring month. ;)
  • 2004: April — - 4/3: Assigned ERC copyright to GNU. Yay! - 4/8: Sand cats - 4/13: Started aikido - 4/14: Posted teaching evaluations - 4/15: 2nd [...]
  • 2004: March — Lots of Planner hacking. - 3/7: Techie dinner with William, Miguel and Jijo. Told him about fai. It made his Shopwise [...]
  • 2004: More Filipinos into open source development — sachac: there’s also my former work colleague – pol babao III - he’s the author of phpmylibrary.
  • 2003: Chickened out — So much for thoughts of a hard disk transplant – I shake too much and am too uncertain about hardware to [...]
  • 2003: Refreshing my Linux install — - Download http://http.us.debian.org/debian/dists/woody/main/disks-i386/current/images-1.44/bf2.4/root.bin - Download http://http.us.debian.org/debian/dists/woody/main/disks-i386/current/bf2.4/linux.bin - Boot grub with the following commands: kernel (hd0,2)/root/root.bin ide0=ata66 initrd=/root/root.bin initrd (hd0,2)/root/root.bin - Gleefully delete the [...]
  • 2003: Sleepy cat — Groggily the cat stirs, curled up on the ergonomic chair. She licks herself before settling back into a comfortable position, yellow-green eyes [...]

Get the highlights as a PDF!

Stories from my Twenties: Highlights from a Decade of Blogging