From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.help Subject: Re: Dude where is my car ? Date: Sat, 26 May 2012 10:51:26 +0800 Message-ID: <87aa0v4pu9.fsf@ericabrahamsen.net> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1338000721 12349 80.91.229.3 (26 May 2012 02:52:01 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 26 May 2012 02:52:01 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat May 26 04:52:00 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SY76j-0005Ux-Oy for geh-help-gnu-emacs@m.gmane.org; Sat, 26 May 2012 04:51:57 +0200 Original-Received: from localhost ([::1]:43984 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SY76j-0006RC-Gy for geh-help-gnu-emacs@m.gmane.org; Fri, 25 May 2012 22:51:57 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:45458) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SY76d-0006Qj-U2 for help-gnu-emacs@gnu.org; Fri, 25 May 2012 22:51:53 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SY76c-0007P5-5j for help-gnu-emacs@gnu.org; Fri, 25 May 2012 22:51:51 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:60694) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SY76b-0007Oo-VA for help-gnu-emacs@gnu.org; Fri, 25 May 2012 22:51:50 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1SY76Y-0004xt-JJ for help-gnu-emacs@gnu.org; Sat, 26 May 2012 04:51:46 +0200 Original-Received: from 114.250.120.35 ([114.250.120.35]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 26 May 2012 04:51:46 +0200 Original-Received: from eric by 114.250.120.35 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 26 May 2012 04:51:46 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 59 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 114.250.120.35 X-Pgp-Key: http://pgp.mit.edu:11371/pks/lookup?op=vindex&search=0xC98BAE7B99D0D373 X-Pgp-Fingerprint: 8E19 28A9 2B51 0C67 565D DB34 C98B AE7B 99D0 D373 User-Agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.1.50 (gnu/linux) Cancel-Lock: sha1:bhuOtFHcWOtTHA4x/fzJrgtkBqY= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:84984 Archived-At: On Sat, May 26 2012, Philippe M. Coatmeur wrote: > Hi everyone ; > > I have this function that loops trough a list of lists of email > elements to extract them. The list looks like this : > > (("" "Fri, 25 May 2012 23:49:58 +0200" "Re: plopz" "1648") > ("contact " "Fri, 25 May 2012 22:21:49 +0000" "tst" "1647")) > > (This is what you get if you C-h v with point over mail-bug-unseen-mails-one) > > (defun mail-bug-desktop-notify-one () > (mapcar > (lambda (x) > (if (not (member x mail-bug-advertised-mails-one)) > (progn > (mail-bug-desktop-notification > "Mew mail!" > (format "%s %s %s" ;; Produces the values below > (car (nthcdr 1 x)) ;; Fri, 25 May 2012 23:49:58 +0200 > (car (nthcdr 2 x)) ;; Re: plopz > (car (nthcdr 3 x))) ;; 1648 > "500000" mail-bug-new-mail-icon-one) > (add-to-list 'mail-bug-advertised-mails-one x)))) > mail-bug-unseen-mails-one)) > > And this works fine, so it follows that (car (car x)) is the first > element of each atomic list, right ? but when I try to extract it > emacs (24.1.50 cvs) insults me!? I spent more than a good hour trying > to figure this out > > (format "%s %s %s" > (car (car x)) ;; Should produce > (car (nthcdr 2 x)) ;; Re: encor un autre > (car (nthcdr 3 x))) ;; 1643 > > error in process sentinel: format: Wrong type argument: listp, "" > error in process sentinel: Wrong type argument: listp, "" Since x equals ("" "Fri, 25 May 2012 23:49:58 +0200" "Re: plopz" "1648") in your second example, the car of that is "", and you can't take the car of that again, because it fails to pass the listp test. I think where you're going wrong is that nthcdr returns a list, so you can car it. Car itself returns an atom, so you can't. Have I got that right? Also, the whole thing might be easier to read/debug if you use "first" "second" "third" "fourth" to extract the list elements. Or, if that seems too unscientific, then "nth", that also pulls a single element out of a list. Eric -- GNU Emacs 24.1.50.1 (i686-pc-linux-gnu, GTK+ Version 2.24.10) of 2012-05-25 on pellet