[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Orgmode] showing lists in agenda, and writing org-agenda to a file
From: |
Eric Schulte |
Subject: |
[Orgmode] showing lists in agenda, and writing org-agenda to a file |
Date: |
Sun, 6 Jan 2008 17:17:40 -0800 |
Hi,
I've started using tools to display my org-agenda as part of my
desktop (geektool http://projects.tynsoe.org/en/geektool/ on my Mac,
and conky http://conky.sourceforge.net/ on my linux box). In doing so
I put together the following little function (below), which I though I
would share in the hope that either someone finds it useful, or
someone has already done this and can share a better method of
accomplishing the same (I'm in the early stages of learning elisp).
Also, In some cases I would like to display the entire body of a
subtree in my custom org-agenda view. Specifically subtrees where the
body is a checkbox list...
** TODO Chores [/] at [2008-01-06 Sun 11:40]
- [ ] dishes/kitchen
- [ ] walk patton
- [ ] MITRE (2 hours)
...
Any suggestions for accomplishing this?
Thanks,
Eric
;; dump agenda to file
(defmacro line-length()
"Length of a line in number of characters"
(length (buffer-substring (save-excursion (beginning-of-line) (point))
(save-excursion (end-of-line) (point)))))
(defun org-agenda-to-file (key file-path &optional max-width)
"Write the org-agenda to a specified file. Can be useful for
displaying the agenda outside of emacs. 'key' will be the key
passed to org-agenda, file-path is the path to which the agenda
will be written, and 'max-width' optionally specifies a maximum
line width for the text in the resulting file."
(interactive)
(save-excursion
(save-window-excursion
(let ((org-agenda-window-setup 'reorganize-frame))
(org-agenda "a" key)
(switch-to-buffer "*Org Agenda*")
(write-file file-path)
(org-agenda-quit)
(if max-width
(progn
(find-file file-path)
(dotimes (line (count-lines (point-min) (point-max)))
(goto-line (1+ line))
(if (> (line-length) max-width)
(progn
(move-beginning-of-line 1)
(forward-char max-width)
(delete-char (- (line-length) max-width)))))
(save-buffer)
(kill-buffer (current-buffer))))))))
;; execute with a shell command like this
;; (org-agenda-to-file "a" "~/.desktop-display" 60)