From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/55823 Path: main.gmane.org!not-for-mail From: Katsumi Yamaoka Newsgroups: gmane.emacs.gnus.general Subject: Re: how to turn this Gnus function into a macro? Date: Thu, 08 Jan 2004 11:13:52 +0900 Organization: Emacsen advocacy group Sender: ding-owner@lists.math.uh.edu Message-ID: References: <4noetfo10c.fsf@collins.bwh.harvard.edu> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1073528085 5030 80.91.224.253 (8 Jan 2004 02:14:45 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 8 Jan 2004 02:14:45 +0000 (UTC) Original-X-From: ding-owner+M4363@lists.math.uh.edu Thu Jan 08 03:14:42 2004 Return-path: Original-Received: from malifon.math.uh.edu ([129.7.128.13]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1AePh4-0006yt-00 for ; Thu, 08 Jan 2004 03:14:42 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by malifon.math.uh.edu with smtp (Exim 3.20 #1) id 1AePgX-0002ub-00; Wed, 07 Jan 2004 20:14:09 -0600 Original-Received: from justine.libertine.org ([66.139.78.221] ident=postfix) by malifon.math.uh.edu with esmtp (Exim 3.20 #1) id 1AePgQ-0002uV-00 for ding@lists.math.uh.edu; Wed, 07 Jan 2004 20:14:02 -0600 Original-Received: from washington.hostforweb.net (washington.hostforweb.net [69.61.11.2]) by justine.libertine.org (Postfix) with ESMTP id 728493A0050 for ; Wed, 7 Jan 2004 20:14:00 -0600 (CST) Original-Received: from yamaoka by washington.hostforweb.net with local (Exim 4.24) id 1AePgU-00032q-AB for ding@gnus.org; Wed, 07 Jan 2004 21:14:06 -0500 Original-To: ding@gnus.org X-Face: #kKnN,xUnmKia.'[pp`;Omh}odZK)?7wQSl"4o04=EixTF+V[""w~iNbM9ZL+.b*_CxUmFk B#Fu[*?MZZH@IkN:!"\w%I_zt>[$nm7nQosZ<3eu;B:$Q_:p!',P.c0-_Cy[dz4oIpw0ESA^D*1Lw= L&i*6&( User-Agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux) Cancel-Lock: sha1:6yrrQHc+ywPCFkA7oGIYR8G/qyw= X-Hashcash: 0:040108:ding@gnus.org:9a8ef236644b567b X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - washington.hostforweb.net X-AntiAbuse: Original Domain - gnus.org X-AntiAbuse: Originator/Caller UID/GID - [32041 32041] / [47 12] X-AntiAbuse: Sender Address Domain - washington.hostforweb.net Precedence: bulk Xref: main.gmane.org gmane.emacs.gnus.general:55823 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:55823 >>>>> In <4noetfo10c.fsf@collins.bwh.harvard.edu> >>>>> Ted Zlatanov wrote: > I tried to make this function into a macro but failed. How about it? (defmacro spam-fetch-field-fast (article field) "Fetch a field quickly, using the internal gnus-data-list function" (let ((macro (cond ((eq field 'from) 'mail-header-from) ((eq field 'message-id) 'mail-header-message-id) ((eq field 'subject) 'mail-header-subject) ((eq field 'references) 'mail-header-references) ((eq field 'date) 'mail-header-date) ((eq field 'xref) 'mail-header-xref) ((eq field 'extra) 'mail-header-extra)))) (if macro `(let ((article ,article)) (if (numberp article) (let* ((header (assoc article (gnus-data-list nil))) (data-header (if header (gnus-data-header header)))) (,macro data-header))))))) (macroexpand '(spam-fetch-field-fast ART from)) => (let ((article ART)) (if (numberp article) (let* ((header (assoc article (gnus-data-list nil))) (data-header (if header (gnus-data-header header)))) (mail-header-from data-header)))) If the arg `article' is always not a cons form (i.e., a number or a symbol), it can be simplified as follows: (defmacro spam-fetch-field-fast (article field) "Fetch a field quickly, using the internal gnus-data-list function" (let ((macro (cond ((eq field 'from) 'mail-header-from) ((eq field 'message-id) 'mail-header-message-id) ((eq field 'subject) 'mail-header-subject) ((eq field 'references) 'mail-header-references) ((eq field 'date) 'mail-header-date) ((eq field 'xref) 'mail-header-xref) ((eq field 'extra) 'mail-header-extra)))) (if macro `(if (numberp ,article) (let* ((header (assoc ,article (gnus-data-list nil))) (data-header (if header (gnus-data-header header)))) (,macro data-header)))))) (macroexpand '(spam-fetch-field-fast ART from)) => (if (numberp ART) (let* ((header (assoc ART (gnus-data-list nil))) (data-header (if header (gnus-data-header header)))) (mail-header-from data-header))) -- Katsumi Yamaoka