save-visited-files installed however whenever I start emacs first a directory list shows (result of another setting in .emacs), I close it and then a few message buffers show up and it's after closing all of them that I get to the file I was working on last time.
How can I configure emacs to show the file from last session when started?
Add the following snippet to your init file to open the last file you were working on:
(require 'recentf) (recentf-mode 1) (add-hook 'after-init-hook (lambda () (recentf-open-most-recent-file 1)) t)
recentf, which tracks the list of recent files you have opened. Then, you instruct Emacs to open the most recent file after initialization.
Note: If you use the
sync-recentf package, then on starting Emacs, your first item will probably be
/tmp/sync-recentf-marker. In that case, you might want to open the second-most recent file, or use a conditional checking for the file name.
If you always want to open a fixed file, then you can also set
Update: Added an optional third argument to the argument list of
add-hook in order to append the hook to the end of the initialization based on suggestions from Tobias.