all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Andrea Crotti <andrea.crotti.0@gmail.com>
To: gebser@mousecar.com
Cc: GNU Emacs List <help-gnu-emacs@gnu.org>
Subject: Re: elisp: can a function/defun return two strings..? prompt for two strings??
Date: Sun, 27 Feb 2011 11:39:57 +0100	[thread overview]
Message-ID: <CD741946-BB43-461C-A390-863B7016DC7F@gmail.com> (raw)
In-Reply-To: <4D6A1830.2010008@mousecar.com>


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.
> 
> 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

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)


  reply	other threads:[~2011-02-27 10:39 UTC|newest]

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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CD741946-BB43-461C-A390-863B7016DC7F@gmail.com \
    --to=andrea.crotti.0@gmail.com \
    --cc=gebser@mousecar.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.