tags:

views:

964

answers:

7

Every day I start up emacs and open the exact same files I had open the day before. Is there something I can add to init.el file so it will reopen all the buffers I was using when I last quit emacs?

+1  A: 

http://www.phys.ufl.edu/docs/emacs/emacs_423.html may have what you need

cobbal
+20  A: 

You can use the Emacs Desktop library:

You can save the desktop manually with the command M-x desktop-save. You can also enable automatic saving of the desktop when you exit Emacs, and automatic restoration of the last saved desktop when Emacs starts: use the Customization buffer (see Easy Customization) to set desktop-save-mode to t for future sessions, or add this line in your ~/.emacs file:

 (desktop-save-mode 1)
Jared Oberhaus
A: 

You can open files in your .emacs file by using the following function:

(find-file "/home/me/path-to-file")

lewap
According to your solution, the questioner should type in her dotemacs the recently opened file names every time. Not really promising.
Török Gábor
He in fact writes the following "... open the exact same files I had open the day before ...". If he opens the same files, then such entries would not change a lot. Don't you agree?
lewap
@Lewap: the OP is a woman. She not he. Beware of assumptions.
Telemachus
@Telemachus: where do you see a "he"?
lewap
A: 

Although I suspect the question was looking for the emacs "desktop" functionality (see above answer), Lewap's approach can be useful if the set of files one uses really is the exact same file set. In fact, one can go a step further and define 'profiles' if one has different sets of regularly used files... Quickie example:

(let ((profile 
       (read-from-minibuffer "Choose a profile (acad,dist,lisp,comp,rpg,sqlg,ssqlfs,tl,tc,fpu): ")
       ))
  (cond
   ((string-match "acad" profile) 
    (dired "/home/thomp/academic")
    (dired "/home/thomp/academic/papers")
    )
   ((string-match "lisp" profile)
    (setup-slime)
    (lisp-miscellany)
    (open-lisp-dirs)
    )
   ((string-match "rpg" profile)
    (find-file "/home/thomp/computing/lisp/rp-geneval/rp-geneval/rp-geneval.lisp")
    (dired "/home/thomp/computing/lisp/rp-geneval/rp-geneval")
    (dired "/home/thomp/academic/data")
... etc.
dat
+1  A: 

Seems that desktop handling is different in Emacs 21 and 22+. The topic is described on this page: http://www.emacswiki.org/emacs/DeskTop .

hji
A: 

I'm using emacs23 and I'm just go to File->See You!(revivable) when I close my session and then to reopen just open emacs and go to File->Revive and he recover all the files and the buffered frames too.

A: 

There are useful enhancements you can make to the basic desktop feature. Particular handy (IMO) are methods of auto-saving the desktop during the session, as otherwise if your system crashes you will be stuck with the desktop file you had started that session with -- pretty annoying if you tend to keep Emacs running for many days at a time.

http://www.emacswiki.org/emacs/DeskTop

The wiki also has useful information about persisting data between sessions in general:

http://www.emacswiki.org/emacs/SessionManagement

For desktops specifically, I thought that Desktop Recover looked particularly promising, however I've not yet tried it out.

phils