all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* elisp: can a function/defun return two strings..? prompt for two strings??
@ 2011-02-27  9:24 ken
  2011-02-27 10:39 ` Andrea Crotti
  0 siblings, 1 reply; 5+ messages in thread
From: ken @ 2011-02-27  9:24 UTC (permalink / raw
  To: GNU Emacs List

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.



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-02-27 21:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.2.1298798656.16925.help-gnu-emacs@gnu.org>
2011-02-27 10:31 ` elisp: can a function/defun return two strings..? prompt for two strings?? Harald Hanche-Olsen
2011-02-27 11:07 ` Pascal J. Bourguignon
2011-02-27 21:10 ` Tim X
2011-02-27  9:24 ken
2011-02-27 10:39 ` Andrea Crotti

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.