From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: gregory@dynapse.com (Gregory J. Grubbs) Newsgroups: gmane.emacs.help Subject: How do you pre-evaluate a function passed to a macro? Date: Fri, 13 Nov 2009 07:18:44 -0700 Message-ID: <87skcipkxn.fsf@dynapse.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1258121997 2838 80.91.229.12 (13 Nov 2009 14:19:57 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 13 Nov 2009 14:19:57 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Nov 13 15:19:50 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1N8x04-0002LS-Dd for geh-help-gnu-emacs@m.gmane.org; Fri, 13 Nov 2009 15:19:44 +0100 Original-Received: from localhost ([127.0.0.1]:59297 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N8x03-0007TG-PS for geh-help-gnu-emacs@m.gmane.org; Fri, 13 Nov 2009 09:19:43 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N8wzh-0007S8-2C for help-gnu-emacs@gnu.org; Fri, 13 Nov 2009 09:19:21 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N8wzb-0007Nx-DZ for help-gnu-emacs@gnu.org; Fri, 13 Nov 2009 09:19:19 -0500 Original-Received: from [199.232.76.173] (port=56952 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N8wzb-0007Nt-34 for help-gnu-emacs@gnu.org; Fri, 13 Nov 2009 09:19:15 -0500 Original-Received: from lo.gmane.org ([80.91.229.12]:51136) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1N8wza-0008Ci-J4 for help-gnu-emacs@gnu.org; Fri, 13 Nov 2009 09:19:14 -0500 Original-Received: from list by lo.gmane.org with local (Exim 4.50) id 1N8wzY-00026Y-8z for help-gnu-emacs@gnu.org; Fri, 13 Nov 2009 15:19:12 +0100 Original-Received: from 72.42.83.192 ([72.42.83.192]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 13 Nov 2009 15:19:12 +0100 Original-Received: from gregory by 72.42.83.192 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 13 Nov 2009 15:19:12 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 23 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 72.42.83.192 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) Cancel-Lock: sha1:gL4I+AAZKvZaWLNpu8qMWAHCf5M= X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) 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:69712 Archived-At: I'm calling a function, wanting to pass nil instead of the empty string when the string argument is zero length. But the function is defined as a macro, so the argument gets passed in unevaluated, which fails. How do I force evaluation of the argument before it is passed in? --8<---------------cut here---------------start------------->8--- ;; myname is a string taken from user input (bbdb-search (bbdb-records) (if (> (length myname) 0) myname nil) nil nil) --8<---------------cut here---------------end--------------->8--- The above call produces the following backtrace: --8<---------------cut here---------------start------------->8--- signal(error ("name must be atomic")) error("name must be atomic") (or (stringp name) (symbolp name) (error "name must be atomic")) (let (clauses) (or (stringp name) (symbolp name) (error "name must be atomic")) (or (stringp company) (symbolp company) (error "company must be atomic")) (or (stringp net) (symbolp net) (error "net must be atomic")) (or (stringp notes) (symbolp notes) (error "notes must be atomic")) (or (stringp phone) (symbolp phone) (error "phone must be atomic")) (if phone (setq clauses ...)) (if notes (setq clauses ...)) (if name (setq clauses ...)) (if net (setq clauses ...)) (if company (setq clauses ...)) (\` (let ... ... ...))) (lambda (records &optional name company net notes phone) "Search RECORDS for optional arguments NAME, COMPANY, NET, NOTES, PHONE.\nThis macro only emits code for those things being searched for;\nliteral nils at compile-time cause no code to be emitted.\n\nIf you want to reverse the search, bind `bbdb-search-invert' to t." (let (clauses) (or ... ... ...) (or ... ... ...) (or ... ... ...) (or ... ... ...) (or ... ... ...) (if phone ...) (if notes ...) (if name ...) (if net ...) (if company ...) (\` ...)))((bbdb-records) (if (> (length myname) 0) myname nil) nil nil) (bbdb-search (bbdb-records) (if (> ... 0) myname nil) nil nil) eval((bbdb-search (bbdb-records) (if (> ... 0) myname nil) nil nil)) eval-expression((bbdb-search (bbdb-records) (if (> ... 0) myname nil) nil nil) nil) call-interactively(eval-expression nil nil) --8<---------------cut here---------------end--------------->8---