From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: Re: [PATCH] sexp may retrurn a list Date: Tue, 26 Oct 2010 07:28:10 +0200 Message-ID: References: <87hbgicnfb.fsf@dasa3.iem.pw.edu.pl> <87d3qz8ims.fsf@kotik.lan> Mime-Version: 1.0 (Apple Message framework v936) Content-Type: text/plain; charset=UTF-8; format=flowed; delsp=yes Content-Transfer-Encoding: quoted-printable Return-path: Received: from [140.186.70.92] (port=51417 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PAcz6-0002rl-Su for emacs-orgmode@gnu.org; Tue, 26 Oct 2010 02:26:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PAcz5-0000LA-Fn for emacs-orgmode@gnu.org; Tue, 26 Oct 2010 02:26:12 -0400 Received: from mail-ew0-f41.google.com ([209.85.215.41]:64722) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PAcz5-0000L5-5d for emacs-orgmode@gnu.org; Tue, 26 Oct 2010 02:26:11 -0400 Received: by ewy25 with SMTP id 25so2207362ewy.0 for ; Mon, 25 Oct 2010 23:26:10 -0700 (PDT) In-Reply-To: <87d3qz8ims.fsf@kotik.lan> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: =?UTF-8?Q?=C5=81ukasz_Stelmach?= Cc: emacs-orgmode@gnu.org Applied, thanks. - Carsten On Oct 24, 2010, at 10:01 PM, =C5=81ukasz Stelmach wrote: > =C5=81ukasz Stelmach writes: > >> I've disovered, that %%(org-bbdb-anniversaries) returns (as every =20 >> other >> sexp) a string. Which is OK if there is only one. >> >> Anniversaries: John Doe's 10th wedding anniversary >> >> Unfortunately the agenda view becomes awful if we have noted Jane's >> weeding date too >> >> Anniversaries: John Doe's 10th wedding anniversary; Jane Doe's =20 >> 10th wedding anniversary >> >> And what if we know 3 Eves and 5 Adams and it's Christmas Eve? (Hint: >> their name day) > [...] > > As Thomas Bauman pointed out, there are functions that can be used in > sexps which return cons cells like this > > (nil . "Full Moon 3:35am (CEST)") > > (this one is diary-lunar-phases), these aren't properly supported by =20= > the > previous version of my patch. This one can distinguish between such a > cons cell and a "real" list. > > ("John Doe's 10th wedding anniversary" > "Jane Doe's 10th wedding anniversary") > > This is because > > (consp (cdr '(a . b))) ; =3D> nil > > so org-diary-sexp-entry can be made return (cdr result) only in case =20= > of > the former cons cell. The third condition in the `cond' block is IMHO > enough as it is now, but if you think adding > > (listp (cdr result)) > > may help then be it. > > --8<---------------cut here---------------start------------->8--- > diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el > index ede62e8..8544a62 100644 > --- a/lisp/org-agenda.el > +++ b/lisp/org-agenda.el > @@ -4499,17 +4499,20 @@ the documentation of `org-diary'." > category (org-get-category beg) > todo-state (org-get-todo-state)) > > - (if (string-match "\\S-" result) > - (setq txt result) > - (setq txt "SEXP entry returned empty string")) > - > - (setq txt (org-format-agenda-item > - "" txt category tags 'time)) > - (org-add-props txt props 'org-marker marker) > - (org-add-props txt nil > - 'org-category category 'date date 'todo-state todo-state > - 'type "sexp") > - (push txt ee)))) > + (dolist (r (if (stringp result) > + (list result) > + result)) ;; we expect a list here > + (if (string-match "\\S-" r) > + (setq txt r) > + (setq txt "SEXP entry returned empty string")) > + > + (setq txt (org-format-agenda-item > + "" txt category tags 'time)) > + (org-add-props txt props 'org-marker marker) > + (org-add-props txt nil > + 'org-category category 'date date 'todo-state todo-state > + 'type "sexp") > + (push txt ee))))) > (nreverse ee))) > > (defun org-diary-class (m1 d1 y1 m2 d2 y2 dayname &rest skip-weeks) > diff --git a/lisp/org-bbdb.el b/lisp/org-bbdb.el > index 53514f7..0d3134d 100644 > --- a/lisp/org-bbdb.el > +++ b/lisp/org-bbdb.el > @@ -338,8 +338,7 @@ This is used by Org to re-create the anniversary =20= > hash table." > (setq text (append text (list tmp))) > (setq text (list tmp))))) > )) > - (when text > - (mapconcat 'identity text "; ")))) > + text)) > > (defun org-bbdb-complete-link () > "Read a bbdb link with name completion." > diff --git a/lisp/org.el b/lisp/org.el > index b482b8e..c1d4e7d 100644 > --- a/lisp/org.el > +++ b/lisp/org.el > @@ -15024,7 +15024,10 @@ D may be an absolute day number, or a =20 > calendar-type list (month day year)." > (sleep-for 2)))))) > (cond ((stringp result) result) > ((and (consp result) > + (not (consp (cdr result))) > (stringp (cdr result))) (cdr result)) > + ((and (consp result) > + (stringp (car result))) result) > (result entry) > (t nil)))) > > --8<---------------cut here---------------end--------------->8--- > > > --=20 > Mi=C5=82ego dnia, > =C5=81ukasz Stelmach > > > _______________________________________________ > Emacs-orgmode mailing list > Please use `Reply All' to send replies to the list. > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode