Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a largish tex project that is separated into several tex files. Everytime I want to work on it I open emacs and manually C-x C-f all the files that I want to work on.

I was wondering if there is a way to open files (from command line) from a file containing a list of filenames, something like

filelist.txt:

file1.tex file2.tex file3.tex

then do

cat files | emacs -nw

except that emacs doesn't support the command used as it doesn't like that stdin is reassigned.

any ideas?

share|improve this question
1  
Check out emacs client so you don't start a new emacs every time, but simply open the files in an already running emacs. – Tom Mar 25 '12 at 6:14

Pass it through xargs instead:

cat files | xargs emacs

xargs takes text from stdin and passes it as arguments to the program specified. Piping the files file into is causes it to call emacs something like:

emacs file1.tex file2.tex file3.tex
share|improve this answer

An alternative to Collin Hockey's suggestion is to use command substitution in your shell. The following syntax works in Bourne like shells (sh, bash, zsh &c.).

emacs $( cat files )

or equivalently (but less readably and more ambiguously)

emacs ` cat files `

Still not an elegant solution, though. I'm not generally an emacs user, but I guess some of the answers here might be what you really want. Have a look!

PS
Neither mine nor Collin's solution will work properly if the list of filenames is longer than getconf ARG_MAX bytes. On my system that is approximately 2 MiB.

share|improve this answer

This really wont solve your issue but will be a potential alternative. Check out desktop-save-mode If you have certain buffers open when you close emacs, on reopening emacs it will reopen all of the buffers you had.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .