[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: searching in Diary
From: |
Glenn Morris |
Subject: |
Re: searching in Diary |
Date: |
Fri, 15 Apr 2005 20:50:10 +0100 |
User-agent: |
Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) |
Raimund Kohl-Fuechsle wrote:
> is there a way to search the diary and have the result shown in a
> fancy-diary-buffer?
I just wrote the following, FWIW. Cons:
1) it's really slow (but everything in my Emacs seems to be slow at
the moment...).
2) the search is anchored from a specific date (ie "search the N day
period after such-and-such a date").
(defvar diary-grep-ndays 30
"Default number of days for `diary-grep' to search.")
(defun diary-grep (regexp &optional ndays)
"Generate a fancy diary buffer with entries matching REGEXP.
Searches diary entries over the next NDAYS (default
`diary-grep-ndays') from either the current date, or the date
indicated by the cursor position in the calendar (if called from
the calendar buffer)."
(interactive (list (read-string "Enter regexp: ")))
(let ((diary-display-hook 'diary-grep-display)
(diary-grep-re regexp))
(list-diary-entries
(if (string-equal (buffer-name) calendar-buffer)
(save-excursion
(calendar-cursor-to-nearest-date))
(calendar-current-date))
(if current-prefix-arg
(prefix-numeric-value current-prefix-arg)
diary-grep-ndays))))
(defun diary-grep-display ()
"Generate a fancy diary buffer with entries matching `diary-grep-re'."
(let ((dlist diary-entries-list)
diary-entries-list holidays-in-diary-buffer)
(dolist (entry dlist)
(if (string-match diary-grep-re (cadr entry))
(setq diary-entries-list
(append diary-entries-list (list entry)))))
(if diary-entries-list
(fancy-diary-display)
(error "No diary entries match `%s'" diary-grep-re))))
- searching in Diary, Raimund Kohl-Fuechsle, 2005/04/13
- Re: searching in Diary,
Glenn Morris <=