* not-instantly-obvious method to get output of shell command to variable
@ 2014-07-30 22:39 Emanuel Berg
2014-07-31 4:54 ` Eli Zaretskii
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Emanuel Berg @ 2014-07-30 22:39 UTC (permalink / raw)
To: help-gnu-emacs
Just wrote this to load the configuration files from
.emacs.
Did spend some (pleasant) time getting the output of
the shell (zsh) command "ls" into the variable `files'
(check it out).
Perhaps that is yet another thing to add for everyone
to use from the holster?
I agree silly configuration and cool hacks shouldn't be
added (unless they are really cool) but such basic
building blocks are great. It boosts creativity if
people don't have to get stuck on details all the time
when they want to do creative stuff.
(let ((files (with-temp-buffer
(call-process-shell-command
"ls ~/.emacs.d/emacs-init/**/*.elc ~/.emacs-no-bc"
nil ; no INFILE
t) ; BUFFER (t = current buffer, i.e. the temp one)
(buffer-substring (point-min) (point-max)) )))
(dolist (f (split-string files)) (load-file f)) )
--
underground experts united
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: not-instantly-obvious method to get output of shell command to variable
2014-07-30 22:39 not-instantly-obvious method to get output of shell command to variable Emanuel Berg
@ 2014-07-31 4:54 ` Eli Zaretskii
2014-07-31 8:28 ` Nicolas Richard
[not found] ` <mailman.6325.1406795217.1147.help-gnu-emacs@gnu.org>
2 siblings, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2014-07-31 4:54 UTC (permalink / raw)
To: help-gnu-emacs
> From: Emanuel Berg <embe8573@student.uu.se>
> Date: Thu, 31 Jul 2014 00:39:48 +0200
>
> Just wrote this to load the configuration files from
> .emacs.
>
> Did spend some (pleasant) time getting the output of
> the shell (zsh) command "ls" into the variable `files'
> (check it out).
>
> Perhaps that is yet another thing to add for everyone
> to use from the holster?
No need to add it, see below.
> (let ((files (with-temp-buffer
> (call-process-shell-command
> "ls ~/.emacs.d/emacs-init/**/*.elc ~/.emacs-no-bc"
> nil ; no INFILE
> t) ; BUFFER (t = current buffer, i.e. the temp one)
> (buffer-substring (point-min) (point-max)) )))
> (dolist (f (split-string files)) (load-file f)) )
Emacs has the shell-command-to-string function to do this. No need to
roll your own.
We also have the find-lisp package that can recursively traverse
directories, so no need to employ zsh-specific features.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: not-instantly-obvious method to get output of shell command to variable
2014-07-30 22:39 not-instantly-obvious method to get output of shell command to variable Emanuel Berg
2014-07-31 4:54 ` Eli Zaretskii
@ 2014-07-31 8:28 ` Nicolas Richard
[not found] ` <mailman.6325.1406795217.1147.help-gnu-emacs@gnu.org>
2 siblings, 0 replies; 4+ messages in thread
From: Nicolas Richard @ 2014-07-31 8:28 UTC (permalink / raw)
To: help-gnu-emacs
> (dolist (f (split-string files)) (load-file f)) )
If you have filenames with spaces in them, this will fail.
--
Nico.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: not-instantly-obvious method to get output of shell command to variable
[not found] ` <mailman.6325.1406795217.1147.help-gnu-emacs@gnu.org>
@ 2014-07-31 20:14 ` Emanuel Berg
0 siblings, 0 replies; 4+ messages in thread
From: Emanuel Berg @ 2014-07-31 20:14 UTC (permalink / raw)
To: help-gnu-emacs
Nicolas Richard <theonewiththeevillook@yahoo.fr>
writes:
>> (dolist (f (split-string files)) (load-file f)) )
>
> If you have filenames with spaces in them, this will
> fail.
Of course I don't have that.
--
underground experts united
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-07-31 20:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-30 22:39 not-instantly-obvious method to get output of shell command to variable Emanuel Berg
2014-07-31 4:54 ` Eli Zaretskii
2014-07-31 8:28 ` Nicolas Richard
[not found] ` <mailman.6325.1406795217.1147.help-gnu-emacs@gnu.org>
2014-07-31 20:14 ` Emanuel Berg
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 read-only IMAP folder(s) and NNTP newsgroup(s).