From: Andreas Politz <politza@fh-trier.de>
To: help-gnu-emacs@gnu.org
Subject: Re: break a chunk of text into a list of lines
Date: Fri, 14 Nov 2008 21:43:57 +0100 [thread overview]
Message-ID: <1226695506.850373@arno.fh-trier.de> (raw)
In-Reply-To: <mailman.359.1226672766.26697.help-gnu-emacs@gnu.org>
Matt Price wrote:
> On Thu, 2008-11-13 at 07:50 -0800, Xah wrote:
>
>> Can you make your question into one specific question?
>>
>> if you can make just one specific question, as much as possible to
>> your problem, it's likely to get much useful replies.
>>
>> from scanning several replies, here's what i think might be helpful.
>>
>> if you want to write elisp to call some other script and process the
>> result, it's fairly easy. If you can be specific about what command
>> you want to call and how you want to parse the result, we can help
>> better.
>>
>> The following tutorial will probably help:
>>
>> • Elisp Wrapper For Perl Scripts
>> http://xahlee.org/emacs/elisp_perl_wrapper.html
>> (you can use your existing knowledge of a scripting lang and turn them
>> into elisp command)
>>
>> • Elisp Lesson: Writing image-linkify Function
>> http://xahlee.org/emacs/elisp_image_tag.html
>> (contains example of calling external script and process its result)
>>
>
> Xah,
>
> thanks for the helpful links -- also thanks to other folks who have been
> helping on this thread. I think i have two questions, so i'll write
> them in two seperate emails.
>
> I have a python script that queries my evolution database and returns a
> series of lines, with one address per line:
>
> matt@gont:~$ python evo-query.py matt
> 14 matches in 874 entries
> matt@mdke.org Matthew East
> matt.price@utoronto.ca Matt Price
> moptop99@gmail.com Matt Price
> mdz@canonical.com Matt Zimmerman
> Matty_fontaine@hotmail.com Matt Fontaine
> matt.price@utoronto.ca Matt Price
> mjg59@srcf.ucam.org Matthew Garrett
> myatesmyates@yahoo.com Matthew Yates
> matthias.doerries@gersulp.u-strasbg.fr Matthias Dörries
> matthew.flaschen@gatech.edu Matthew Flaschen
> mcdavey@mrao.cam.ac.uk Matt Davey
> matt@madhaus.cns.utoronto.ca Matt Wilks
> MattVermeulen@gmail.com Matthew Vermeulen
> matthewreedy@yahoo.com matthewreedy
>
> (note the not-so-well-maintained duplicates!)
>
> i've written a short function based on one of your examples that grabs
> this output -- i imagine it needs some fixing up, but here it is:
> (defun query-python-addressbook (name)
> (interactive "s To:" )
> (setq cmd-name "python /home/matt/evo-query.py")
> (setq sh-output (shell-command-to-string (concat cmd-name " " name)))
> (message "%s" sh-output)
> )
>
> (query-python-addressbook "matt") now returns a message with the this
> text. instead i'd like it to return a list of names. i'm sure someone
> will point me to the right info node, but i'm having some difficulty
> navigating the immense amounts of documentation -- is there a simple way
> to take each line of a text block and turn it into a list of lines?
>
> thanks much! -- second quesiton to follow...
>
> matt
>
As Xah pointed out `split-string' is the way to go. Btw `cmd-name' and `sh-output'
will become global variables with your code. I doubt that's what you want. Better use
let-forms.
(defun query-python-addressbook (name)
(interactive "s To:")
(let ((cmd-name "python /home/matt/evo-query.py"))
(split-string (shell-command-to-string (concat cmd-name " " name)) "\n" t)))
In this case the variable is probably superficial anyway.
-ap
next prev parent reply other threads:[~2008-11-14 20:43 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.201.1226528857.26697.help-gnu-emacs@gnu.org>
2008-11-12 23:08 ` starting an external command from emacs Dan Espen
2008-11-13 3:48 ` Matt Price
[not found] ` <mailman.217.1226563070.26697.help-gnu-emacs@gnu.org>
2008-11-13 13:54 ` Dan Espen
2008-11-13 15:50 ` Xah
2008-11-14 13:24 ` break a chunk of text into a list of lines Matt Price
2008-11-14 15:33 ` starting an external command from emacs Matt Price
[not found] ` <mailman.359.1226672766.26697.help-gnu-emacs@gnu.org>
2008-11-14 19:33 ` break a chunk of text into a list of lines Xah
2008-11-14 20:43 ` Andreas Politz [this message]
2008-11-15 16:35 ` interactive function: generate tab-completion list with another function Matt Price
2008-11-16 3:42 ` syntax: anonymous vs. named functions Matt Price
2008-11-16 8:01 ` Drew Adams
2008-11-16 15:48 ` Matt Price
2008-11-17 1:06 ` Drew Adams
[not found] ` <mailman.552.1226883997.26697.help-gnu-emacs@gnu.org>
2008-11-17 8:08 ` Andreas Politz
[not found] ` <mailman.365.1226676836.26697.help-gnu-emacs@gnu.org>
2008-11-14 19:43 ` starting an external command from emacs Xah
2008-11-14 20:31 ` Andreas Politz
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=1226695506.850373@arno.fh-trier.de \
--to=politza@fh-trier.de \
--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.