From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Glenn Morris Newsgroups: gmane.emacs.help Subject: Re: searching in Diary Date: Fri, 15 Apr 2005 20:50:10 +0100 Organization: None Message-ID: <8tr7hbizv1.fsf@xpc14.ast.cam.ac.uk> References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1113594744 31809 80.91.229.2 (15 Apr 2005 19:52:24 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 15 Apr 2005 19:52:24 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Apr 15 21:52:22 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DMWqx-0007Kn-Aa for geh-help-gnu-emacs@m.gmane.org; Fri, 15 Apr 2005 21:51:47 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DMWuV-0004UR-N7 for geh-help-gnu-emacs@m.gmane.org; Fri, 15 Apr 2005 15:55:27 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!border1.nntp.dca.giganews.com!nntp.giganews.com!peer01.cox.net!cox.net!easynet-quince!easynet.net!feed4.jnfs.ja.net!feed2.jnfs.ja.net!jnfs.ja.net!gemini.csx.cam.ac.uk!news.cam.ac.uk!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 46 Original-NNTP-Posting-Host: xpc14.ast.cam.ac.uk X-Spook: data haven Mossad armor-piercing ARD remailer DES X-Ran: Wz&V$'+i"$B713}N?Vz6l>)'N4-tfa%?]+u`2!K4$lJ4!Ia@!\Ulz]sIq!?YbCw@Nm"_mL X-Hue: medium sea green X-Attribution: GM Mail-Copies-To: nobody User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) Cancel-Lock: sha1:g8xfSIFxEmaOlzHobbClHKtzo5E= Original-Xref: shelby.stanford.edu gnu.emacs.help:130169 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:25737 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:25737 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))))