From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andrea Crotti Newsgroups: gmane.emacs.help Subject: Re: elisp: can a function/defun return two strings..? prompt for two strings?? Date: Sun, 27 Feb 2011 11:39:57 +0100 Message-ID: References: <4D6A1830.2010008@mousecar.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (Apple Message framework v1082) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1298803259 24081 80.91.229.12 (27 Feb 2011 10:40:59 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 27 Feb 2011 10:40:59 +0000 (UTC) Cc: GNU Emacs List To: gebser@mousecar.com Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Feb 27 11:40:55 2011 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.69) (envelope-from ) id 1Pte3a-0000nR-DR for geh-help-gnu-emacs@m.gmane.org; Sun, 27 Feb 2011 11:40:54 +0100 Original-Received: from localhost ([127.0.0.1]:58757 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pte3Z-000569-Vo for geh-help-gnu-emacs@m.gmane.org; Sun, 27 Feb 2011 05:40:54 -0500 Original-Received: from [140.186.70.92] (port=59391 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pte2s-00051K-JH for help-gnu-emacs@gnu.org; Sun, 27 Feb 2011 05:40:16 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pte2j-0004Gi-GI for help-gnu-emacs@gnu.org; Sun, 27 Feb 2011 05:40:10 -0500 Original-Received: from mail-fx0-f41.google.com ([209.85.161.41]:53837) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pte2j-0004FB-7N for help-gnu-emacs@gnu.org; Sun, 27 Feb 2011 05:40:01 -0500 Original-Received: by fxm5 with SMTP id 5so3470821fxm.0 for ; Sun, 27 Feb 2011 02:39:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:subject:mime-version:content-type:from :in-reply-to:date:cc:content-transfer-encoding:message-id:references :to:x-mailer; bh=URMUAhCXwPXSfO20a2amTI/2ti0Mt2HAPejIl6hzazk=; b=wUG9Eq3g56aNPbF6ex6vQUbQSg7dCs/FGPyqt5yIyX5UewbCVGaubJWBx79uy97id7 /zCyITnXXZ6ElnhyXIR/NWFPxtZ90aHgDXJof6dY4HA3H/N7BYWXiCXLL9qmh9KsSETn 9iSXINeeHDvmz5fkIjVH0ODZm+qyrX/hn0n9g= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer; b=b2CIpe7Fp2nXIMaMcKhFUXmZxBrWQA/ESOK1PIC3kstDPl/kdW+V/YfgH7X/BT/lY+ /dMmRti9Zwn7d7DTqYGlAdB3Pfx8DljMAXjQI56Hb7xyYF+mNUvGJcW5tCN+SG0PYbXM 2lwC3nZGPl99AX4t1zI/vW1wauBLRXG5ahS/M= Original-Received: by 10.223.97.140 with SMTP id l12mr429879fan.65.1298803199542; Sun, 27 Feb 2011 02:39:59 -0800 (PST) Original-Received: from ip1-201.halifax.rwth-aachen.de (ip1-201.halifax.RWTH-Aachen.DE [137.226.108.201]) by mx.google.com with ESMTPS id n2sm1040566fam.28.2011.02.27.02.39.57 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 27 Feb 2011 02:39:58 -0800 (PST) In-Reply-To: <4D6A1830.2010008@mousecar.com> X-Mailer: Apple Mail (2.1082) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.161.41 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:79523 Archived-At: Il giorno 27/feb/2011, alle ore 10.24, ken ha scritto: > In one line of a file/buffer (which might exist or might not) will be > two strings, both of which must be fetched and returned to the calling > function. I was going to write two separate functions, one for each > string, but since both strings are in the same line, it seemed highly > inefficient to search for the same line of text twice... made more = sense > to search for it once, and get both strings in the same function. >=20 > Here's pseudo-code: >=20 > ;; search buffer for line of interest. > ;; if the line exists > ;; does it specify str1? > ;; if it does, grab that str1, hold it for eventual return > ;; if it doesn't, prompt user for it, and hold it for eventual = return. > ;; does the same line specify str2? > ;; if it does, grab that str2, hold it for eventual return > ;; if it doesn't, prompt user for it, and hold it for eventual = return. > ;; if the line doesn't exist, > ;; prompt user for str1 and str2 > ;; create/insert new line in buffer, inserting str1 & str2 into = it. > ;; return str1 and str2 to calling function The easiest way in my opinion is just to return a list, and append to it = what you get. It looks quite long your procedure to look for strings anyway, I think = that if you use regular expressions it will be much much faster. If you write exactly the input and output that you expect maybe it will = be easier to help ;; pseudocode (let ((result ())) (if .... (add-to-list ... result) ... result)=