SkillAgentSearch skills...

Easysession.el

easysession.el: Easily persist and restore Emacs file buffers, Magit buffers, scratch, Dired, narrowing, indirect buffers (clones), windows, and tab-bar configurations; a robust desktop.el replacement that allows switching sessions and fully supports GUI and daemon modes

Install / Use

/learn @jamescherti/Easysession.el

README

easysession.el: Easily persist and restore Emacs file buffers, Magit buffers, scratch, Dired, narrowing, indirect buffers (clones), windows, and tab-bar configurations; a robust desktop.el replacement

Build Status MELPA MELPA Stable License

The easysession Emacs package provides a comprehensive session management for Emacs. It is capable of persisting and restoring file-visiting buffers, indirect buffers (clones), buffer narrowing, Dired buffers, window configurations, the built-in tab-bar (including tabs, their buffers, and associated windows), as well as entire Emacs frames (frame name, size, position, etc.).

With easysession, your Emacs setup is restored automatically when you restart. All files, Dired buffers, and window layouts come back as they were, so you can continue working right where you left off. While editing, you can also switch to another session, switch back, rename sessions, or delete them, giving you full control over multiple work environments.

Easysession also supports extensions, enabling the restoration of Magit buffers and the scratch buffer. Custom extensions can also be created to extend its functionality.

<p align="center"> <img src="https://jamescherti.com/misc/easysession-m.png" width="40%" /> </p>

If this package enhances your workflow, please show your support by ⭐ starring EasySession on GitHub to help more users discover its benefits.

Key features include:

  • Quickly switch between sessions while editing with or without disrupting the frame geometry.
  • Capture the full Emacs workspace state: file buffers, indirect buffers and clones, buffer narrowing, Dired buffers, window layouts and splits, the built-in tab-bar with its tabs and buffers, and Emacs frames with optional position and size restoration.
  • Built from the ground up with an emphasis on speed, minimalism, and predictable behavior, even in large or long-running Emacs setups.
  • Supports both standard Emacs sessions and Emacs running in daemon mode.
  • Never lose context with automatic session persistence. (Enable easysession-save-mode to save the active session at regular intervals defined by easysession-save-interval and again on Emacs exit.)
  • Comprehensive command set for session management: switch sessions instantly with easysession-switch-to, save with easysession-save, delete with easysession-delete, and rename with easysession-rename.
  • Highly extensible architecture that allows custom handlers for non-file buffers, making it possible to restore complex or project-specific buffers exactly as needed.
  • Fine-grained control over file restoration by selectively excluding individual functions from find-file-hook during session loading via easysession-exclude-from-find-file-hook.
  • Clear visibility of the active session through modeline integration or a lighter.
  • Built-in predicate to determine whether the current session qualifies for automatic saving.
  • Save and unload the currently loaded session using easysession-unload.
  • Exact restoration of narrowed regions in both base and indirect buffers, ensuring each buffer reopens with the same visible scope as when it was saved.
  • Optional scratch buffer persistence via the extensions/easysession-scratch.el extension, preserving notes and experiments across restarts.
  • Optional Magit state restoration via the extensions/easysession-magit.el extension, keeping version control workflows intact.
<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-refresh-toc -->

Table of Contents

<!-- markdown-toc end -->

Installation

To install easysession from MELPA:

  1. If you haven't already done so, add MELPA repository to your Emacs configuration.

  2. Add the following code to your Emacs init file to install easysession from MELPA:

(use-package easysession
  :demand t
  :custom
  (easysession-save-interval (* 10 60))  ; Save every 10 minutes

  ;; Save the current session when using `easysession-switch-to'
  (easysession-switch-to-save-session t)

  ;; Do not exclude the current session when switching sessions
  (easysession-switch-to-exclude-current nil)

  ;; Display the active session name in the mode-line lighter.
  (easysession-save-mode-lighter-show-session-name t)

  ;; Optionally, the session name can be shown in the modeline info area:
  ;; (easysession-mode-line-misc-info t)

  :config
  ;; Key mappings
  (global-set-key (kbd "C-c sl") #'easysession-switch-to) ; Load session
  (global-set-key (kbd "C-c ss") #'easysession-save) ; Save session
  (global-set-key (kbd "C-c sL") #'easysession-switch-to-and-restore-geometry)
  (global-set-key (kbd "C-c sr") #'easysession-rename)
  (global-set-key (kbd "C-c sR") #'easysession-reset)
  (global-set-key (kbd "C-c su") #'easysession-unload)
  (global-set-key (kbd "C-c sd") #'easysession-delete)

  ;; non-nil: Make `easysession-setup' load the session automatically.
  ;; (nil: session is not loaded automatically; the user can load it manually.)
  (setq easysession-setup-load-session t)

  ;; The `easysession-setup' function adds hooks:
  ;; - To enable automatic session loading during `emacs-startup-hook', or
  ;;   `server-after-make-frame-hook' when running in daemon mode.
  ;; - To save the session at regular intervals, and when Emacs exits.
  (easysession-setup))

Extensions

Extension: easysession-scratch (Persist and restore the scratch buffer)

This extension makes EasySession persist and restore the scratch buffer.

To enable easysession-scratch-mode, add the following to your configuration:

(with-eval-after-load 'easysession
  (require 'easysession-scratch)
  (easysession-scratch-mode 1))

Extension: easysession-magit (Persist and restore Magit buffers)

This extension enables EasySession to persist and restore Magit buffers.

To activate easysession-magit-mode, add the following to your Emacs configuration:

(with-eval-after-load 'easysession
  (require 'easysession-magit)
  (easysession-magit-mode 1))

Usage

It is recommended to use the following functions:

  • easysession-switch-to to switch to another session,
  • easysession-save to save
View on GitHub
GitHub Stars211
CategoryCustomer
Updated1d ago
Forks12

Languages

Emacs Lisp

Security Score

100/100

Audited on Apr 3, 2026

No findings