From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ken Newsgroups: gmane.emacs.help Subject: elisp: can a function/defun return two strings..? prompt for two strings?? Date: Sun, 27 Feb 2011 04:24:00 -0500 Message-ID: <4D6A1830.2010008@mousecar.com> Reply-To: gebser@mousecar.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1298798695 4829 80.91.229.12 (27 Feb 2011 09:24:55 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 27 Feb 2011 09:24:55 +0000 (UTC) To: GNU Emacs List Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Feb 27 10:24:51 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 1Ptcrx-0001vN-VY for geh-help-gnu-emacs@m.gmane.org; Sun, 27 Feb 2011 10:24:50 +0100 Original-Received: from localhost ([127.0.0.1]:55729 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ptcrx-0005Uz-Fy for geh-help-gnu-emacs@m.gmane.org; Sun, 27 Feb 2011 04:24:49 -0500 Original-Received: from [140.186.70.92] (port=42761 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PtcrK-0005Qx-HX for help-gnu-emacs@gnu.org; Sun, 27 Feb 2011 04:24:15 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PtcrF-0002bC-FK for help-gnu-emacs@gnu.org; Sun, 27 Feb 2011 04:24:10 -0500 Original-Received: from mout.perfora.net ([74.208.4.195]:53658) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PtcrF-0002b1-Ax for help-gnu-emacs@gnu.org; Sun, 27 Feb 2011 04:24:05 -0500 Original-Received: from dellap.mousecar.net (dsl093-011-016.cle1.dsl.speakeasy.net [66.93.11.16]) by mrelay.perfora.net (node=mrus2) with ESMTP (Nemesis) id 0M85w9-1QG5eS2v8D-00w5b6; Sun, 27 Feb 2011 04:24:03 -0500 User-Agent: Thunderbird 2.0.0.24 (X11/20101213) X-Enigmail-Version: 0.96.0 OpenPGP: id=5AD091E7 X-Provags-ID: V02:K0:wffrLJjM4QWI7s/3GBHyiK9AEVEPrk5IQx8JGHmzQ1z MxSqdWwtwaTTrHYneXpPW0L7k6vL0ZJNCPDh4k1nThw8r2ovAX XJTEzWVWeCwXA/4GhQW/nVUYe1FW0UoXcQ0vk7AjxdWbDZVOyX N9YhetkS4jtgkzimOQoR9e7uJZBJNb7qKcE2wQfSYPmyVF6wSe Rpz4LcXvI3kwjIdK88uhMVZzbenYQR0ZCiI+EiDRdY= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 74.208.4.195 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:79520 Archived-At: 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. Here's pseudo-code: ;; 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 Most of the coding for the above will busy itself with finding the line of interest-- or determining that it doesn't exist. So why should I do that twice, once for each string? Sure, I could save to a variable the location of the line of interest to avoid having to search for it again, but then I'm back to working with two variables, the location and just one string. So that's a non-solution. So how to "return" two variables to a calling function, possibly have to prompt for one or both of them? (I can think of a half dozen ways to do this in C, but this is elisp.) Thanks.