[Top][All Lists]

[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 (, GNU 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))
     (if (string-equal (buffer-name) calendar-buffer)
     (if current-prefix-arg
         (prefix-numeric-value current-prefix-arg)

(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
      (error "No diary entries match `%s'" diary-grep-re))))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]