From: Colin Walters <walters@cis.ohio-state.edu>
Subject: Re: Mechaincal question Show filename of # marked
Date: 22 Dec 2000 01:05:04 -0500 [thread overview]
Message-ID: <87n1dprnxr.church.of.emacs@meta.verbum.org> (raw)
In-Reply-To: <m24rzxoxcc.fsf@gnus-5.8.8-cvs.now.playing>
Harry Putnam <reader@newsguy.com> writes:
> OK trying to get in to this, but I have no clue how that list might
> be stored into a variable... In the shell, no problem but in
> lisp.. I'm lost.
Ok. By the way, I highly recommend Robert Chassell's "Programming in
Emacs Lisp: An Introduction". It's how I started to learn Emacs Lisp.
> Taking the first example, since I don't know how to generate a
> variable containing a list I try using a single file name instead,
> and insert something simple for a shell command `cat' (UUofC not
> withstanding)
Well, one way to (implicitly) create variables is with `setq', which
you've probably seen before.
Say you type
(setq foo '("/home/reader/Mail/tmp/awk-work/13"
"/home/reader/Mail/tmp/awk-work/14"))
This is sort of like saying
FOO="/home/reader/Mail/tmp/awk-work/13 /home/reader/Mail/tmp/awk-work/14"
in a shell, because you separate elements in a shell list with
whitespace. In the same way that you could then say (in bash)
for x in $FOO; do cat $x; done
you can say
(dolist (x foo)
(shell-command-to-string (concat "cat " x)))
Of course, Lisp lists are tons better, because they don't get confused
by whitespace, can store any kind of object, and get automatically
freed when you're done with them :)
> I'm guessing this is like a simple `for loop' and cat will be run on
> each member in turn. So with just 1 member then maybe just on it.
Right.
> (mapcar (lambda (x) (shell-command-to-string (concat "cat " x)))
> /home/reader/Mail/tmp/awk-work/13)
>
> So C-x C-e
> Symbol's value as variable is void: \
> /home/reader/Mail/tmp/awk-work/13
Well, what you want to say here is:
(mapcar (lambda (x) (shell-command-to-string (concat "cat " x)))
'("/home/reader/Mail/tmp/awk-work/13"))
So what you're doing here is creating a one-element list, with a
string as its single element.
> Well, I'm getting closer... May sound terribly lame, but I don't even
> have a clue on how to begin looking this up in the Into or Lisp
> manual.
The Elisp intro is very good, and worth reading.
> Good thing this isn't explosive... I'd have had a serious accident
> by now.
I still get that feeling pretty often :)
next prev parent reply other threads:[~2000-12-22 6:05 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-12-21 3:06 Harry Putnam
2000-12-21 10:02 ` Kai Großjohann
2000-12-21 14:28 ` Harry Putnam
2000-12-21 15:42 ` Kai Großjohann
2000-12-21 15:55 ` Harry Putnam
2000-12-22 3:15 ` Colin Walters
2000-12-22 5:10 ` Harry Putnam
2000-12-22 6:05 ` Colin Walters [this message]
2000-12-22 8:44 ` Kai Großjohann
2000-12-22 8:40 ` Kai Großjohann
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=87n1dprnxr.church.of.emacs@meta.verbum.org \
--to=walters@cis.ohio-state.edu \
--cc=ding@gnus.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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).