help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: not-instantly-obvious method to get output of shell command to varia


From: Eli Zaretskii
Subject: Re: not-instantly-obvious method to get output of shell command to variable
Date: Thu, 31 Jul 2014 07:54:54 +0300

> From: Emanuel Berg <address@hidden>
> 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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]