Emacs: Restore Opened Files, Windows Config

By Xah Lee. Date: . Last updated: .

emacs has desktop-save-mode. When on, it save and restore all previously opened files in last emacs session, and also previous windows configuration (size, position, etc.)

Put this in your emacs init file:

;; save/restore opened files and windows config
(desktop-save-mode 1) ; 0 for off

Starting Emacs Without Opening Last Session's Files

To start emacs without opening last session's files, start it by:

emacs --no-desktop

This is useful because sometimes you have a corrupted desktop file.

Desktop File Path Location

By default, the temp file used by emacs to store your “desktop” status is at ~/.emacs.d/.emacs.desktop.

The desktop file path is controlled by the variable desktop-dirname and desktop-base-file-name.

Alt+x describe-variable, type “desktop-”, then press Tab, to see all desktop mode's variables.

Alt+x customize-group type “desktop”, to set preferences. [see Emacs: M-x customize Tutorial]

desktop-save-mode Changes in Emacs 24.4

In emacs 24.4: new variable desktop-save. Default is t. When t, desktop are automatically saved when you quit.

In emacs 24.4: new variable desktop-auto-save-timeout. Default value is 30 (seconds). It specifies the time interval to periodically save “desktop”. Before, it saves only when you quit emacs.

In emacs 24.4: New variable desktop-restore-frames. Default value is t. When t, save and restore the frame and window configuration.

More options for restoring windows, see: desktop-restore-in-current-display, desktop-restore-reuses-frames, desktop-restore-forces-onscreen

Alt+x describe-variable to see a variable's value and documentation.

Manage Windows Topic

  1. Split Windows
  2. Save Split Windows Configuration
  3. Effective Windows Management
  4. Make Buffer Flow Side-by-Side
  5. Restore Opened Files, Windows Config
  6. Set Default Window Size

Emacs Customization

  1. Emacs init file
  2. What's Major Mode
  3. What's Minor Mode
  4. M-x customize
  5. Organize Init File
  6. Byte Compile Elisp
  7. What's Hook
  8. Avoid Lambda in Hook
  9. Environment Variables in Emacs
  10. Check OS, Version, Host Name
  11. Check Defined/Loaded

packages

  1. Install Packages
  2. Install Package Manually

text editing

  1. Define Keys
  2. Set Mouse Buttons
  3. Tabs, Space, Indentation Setup
  4. auto bracket pair
  5. Copy/Cut Line If No Selection
  6. Isearch space for - _
  7. Ido Completion
  8. Icomplete Completion
  9. Move Cursor by camelCase
  10. Stop Cursor Going into Minibuffer Prompt
  11. Sync Clipboard with Linux X11

file

  1. Default Major Mode
  2. Auto Backup Off
  3. Auto Save
  4. Restore Opened Files
  5. Save Cursor Position
  6. Dired Customization
  7. Open Recently Opened
  8. Open Last Closed File

appearance

  1. Show Line Numbers
  2. Show Cursor Position
  3. Visual Line Mode, Wrap Lines
  4. High Light Current Line
  5. Make Whitespaces Visible
  6. Set Default Window Size
  7. Font Setup
  8. Line Spacing
  9. Set Color Theme
  10. Highlight Paren
  11. Show lambda as λ
  12. Color CSS Hex Code

misc

  1. Default Browser
  2. Misc Init Tips

If you have a question, put $5 at patreon and message me.
Or Buy Xah Emacs Tutorial
Or buy a nice keyboard: Best Keyboards for Emacs

Emacs

Emacs Lisp

Misc