From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Herbert Euler" Newsgroups: gmane.emacs.help,gmane.emacs.devel Subject: Calling different kinds of functions, which finish the same job Date: Tue, 11 Apr 2006 16:12:56 +0800 Message-ID: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; format=flowed X-Trace: sea.gmane.org 1144743201 29806 80.91.229.2 (11 Apr 2006 08:13:21 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 11 Apr 2006 08:13:21 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Apr 11 10:13:19 2006 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1FTDzt-0005B9-Ru for geh-help-gnu-emacs@m.gmane.org; Tue, 11 Apr 2006 10:13:14 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FTDzt-0003iT-8B for geh-help-gnu-emacs@m.gmane.org; Tue, 11 Apr 2006 04:13:13 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FTDzg-0003hu-3S for help-gnu-emacs@gnu.org; Tue, 11 Apr 2006 04:13:00 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FTDze-0003hV-HB for help-gnu-emacs@gnu.org; Tue, 11 Apr 2006 04:12:59 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FTDze-0003hS-Eo; Tue, 11 Apr 2006 04:12:58 -0400 Original-Received: from [64.4.56.15] (helo=hotmail.com) by monty-python.gnu.org with esmtp (Exim 4.52) id 1FTE4T-0006ro-GL; Tue, 11 Apr 2006 04:17:57 -0400 Original-Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Tue, 11 Apr 2006 01:12:57 -0700 Original-Received: from 64.4.56.200 by by101fd.bay101.hotmail.msn.com with HTTP; Tue, 11 Apr 2006 08:12:56 GMT X-Originating-IP: [202.165.107.100] X-Originating-Email: [herberteuler@hotmail.com] X-Sender: herberteuler@hotmail.com Original-To: help-gnu-emacs@gnu.org, emacs-devel@gnu.org X-OriginalArrivalTime: 11 Apr 2006 08:12:57.0142 (UTC) FILETIME=[BD91F560:01C65D3F] 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:34301 gmane.emacs.devel:52646 Archived-At: Hello, Assume there are some functions, for instance, f1, f2, f3, all of them are doing the same job, but with different arguments. If I want to call one of them, but don't know which one is actually called, how can I do that? I've written two macros like (defmacro xgp-casi2-safe-call-iter (func largs) `(if ,largs (condition-case nil (apply ,func (car ,largs)) (error (xgp-casi2-safe-call-iter ,func (cdr ,largs)))))) (defmacro xgp-casi2-safe-call (func largs) "Call function FUNC, try each element of LARGS, which is a list of list, as argument to FUNC. First call without arguments." `(condition-case nil (apply ,func) (error (xgp-casi2-safe-call-iter ,func ,largs)))) And I will call it with (xgp-casi2-safe-call function '((args of f1) (args of f2) (args of f3))) This is my solution. Any suggestions? Thanks in advance. Regards, Guanpeng Xu _________________________________________________________________ Don’t just search. Find. Check out the new MSN Search! http://search.msn.click-url.com/go/onm00200636ave/direct/01/