简体   繁体   中英

How to open files automatically when starting emacs?

A newbie question and probably very bingable (had to use that word once :-)), but as I gather thats both ok for SO : How can you get files to open automatically when starting emacs?

I guess it sth. like executing the find file command in your .emacs but the exact notation isn't clear to me.

C-h b 

This opens the help showing the correspondence between key-bindings and elisp functions. Look for

C-x C-f 

in it (you can do it by typing Cs C - x space C - f ), you find find-file . Now, do

C-h f find-file

and it tells you, among other things, the syntax :

(find-file FILENAME &optional WILDCARDS)

So just try

(find-file "/path/to/your/file") 

in your .emacs

Are you thinking of having it re-open files you've looked at before? The desktop package remembers files and re-opens them when you restart. Depending on your emacs version, you enable by simply adding this to your .emacs (for 22.1+ versions):

 (desktop-save-mode 1)

And after that, it's pretty much automatic. Whatever files you had open before will be re-opened (provided you start from the same directory, b/c that's where the desktop configuration file is saved) - unless you add a change that forces a single desktop for all sessions .

There are bunches of variants of that functionality, which are listed in the session management page .

If you're calling it from the terminal , can't you just go

emacs FileName

You could desktop-save which basically restores the last session you were working with. When you restart emacs, it looks for a saved session in your folder and loads your files. See link text

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM