Skip to content

Commit

Permalink
Fixes #25: Refactor frameset filtering into a dedicated function
Browse files Browse the repository at this point in the history
  • Loading branch information
jamescherti committed Feb 7, 2025
1 parent 477cf8f commit bf95579
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 88 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
![Build Status](https://github.com/jamescherti/easysession.el/actions/workflows/ci.yml/badge.svg)
![License](https://img.shields.io/github/license/jamescherti/easysession.el)

The `easysession.el` Emacs package is a lightweight session manager for Emacs that can persist and restore file editing buffers, indirect buffers/clones, Dired buffers, windows/splits, the built-in tab-bar (including tabs, their buffers, and windows), and Emacs frames. It offers a convenient and effortless way to manage Emacs editing sessions and utilizes built-in Emacs functions to persist and restore frames.
The `easysession.el` Emacs package is a session manager for Emacs that can persist and restore file editing buffers, indirect buffers/clones, Dired buffers, windows/splits, the built-in tab-bar (including tabs, their buffers, and windows), and Emacs frames. It offers a convenient and effortless way to manage Emacs editing sessions and utilizes built-in Emacs functions to persist and restore frames.

<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-refresh-toc -->
## Table of Contents
Expand Down Expand Up @@ -36,11 +36,12 @@ The `easysession.el` Emacs package is a lightweight session manager for Emacs th
## Features

Key features include:
- Minimalist design focused on performance and simplicity, avoiding unnecessary complexity.
- Quickly switch between sessions while editing without disrupting the frame geometry, enabling you to resume work immediately.
- Save and load file editing buffers, indirect buffers/clones, dired buffers, windows/splits, the built-in tab-bar (including tabs, their buffers, and windows), the Emacs frames (with or without their position and size).
- Automatically save sessions by activating the mode with `easysession-save-mode` to ensure that the current session is automatically saved every `easysession-save-interval` seconds and when emacs quits.
- Design focused on performance, simplicity, and efficiency.
- Helper functions: Switch to a session (i.e., load and change the current session) with `easysession-switch-to`, load the Emacs editing session with `easysession-load`, save the Emacs editing session with `easysession-save` and `easysession-save-as`, delete the current Emacs session with `easysession-delete`, and rename the current Emacs session with `easysession-rename`.
- Customizable: Users can implement their own handlers to manage non-file-editing buffers, enabling the creation of custom functions for restoring buffers.

## Installation

Expand Down Expand Up @@ -206,7 +207,7 @@ Here is a code snippet shared by u/capuche on Reddit that closes all buffers bef

### How to create custom load and save handlers for non-file-visiting buffers

EasySession is customizable. Users can implement their own handlers to manage non-file-editing buffers, enabling the creation of custom functions for restoring such buffers.
EasySession is customizable. Users can implement their own handlers to manage non-file-editing buffers, enabling the creation of custom functions for restoring buffers.

Here is an example:
```elisp
Expand Down Expand Up @@ -299,7 +300,7 @@ There are some existing packages, such as minimal-session-saver, save-visited-fi
- Sesman is designed to implement some IDE features in Emacs.
- Psession cannot switch between sessions quickly, with or without modifying the the Emacs frame geometry. This last feature is important in easysession.el because it allows switching between sessions without the annoyance of changing the window position or size.

Easysession is lightweight and can persist and restore file editing buffers, indirect buffers/clones, Dired buffers, the tab-bar, and the Emacs frames (with or without the Emacs frames geometry). It is similar to Vim or Neovim sessions because it loads and restores your editing environment, including buffers, windows, tabs, and other settings, allowing you to resume work exactly where you left off.
Easysession can persist and restore file editing buffers, indirect buffers/clones, Dired buffers, the tab-bar, and the Emacs frames (with or without the Emacs frames geometry). It is similar to Vim or Neovim sessions because it loads and restores your editing environment, including buffers, windows, tabs, and other settings, allowing you to resume work exactly where you left off.

### Are there any testimonials from users?

Expand Down
111 changes: 27 additions & 84 deletions easysession.el
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,8 @@ geometry.")

(defvar easysession--timer nil)

;; Overrides `frameset-filter-alist' while preserving its keys,
;; but replaces their values with the ones specified in the following alist:
(defvar easysession--overwrite-frameset-filter-alist
'((GUI:bottom . :never)
(GUI:font . :never)
Expand Down Expand Up @@ -419,91 +421,32 @@ geometry.")
(z-group . :never))
"Alist of frame parameters and filtering functions.")

(defun easysession--filter-out-frameset-filters (list-keys)
"Remove geometry.
LIST-KEYS is the list of keys (e.g., GUI:left, bottom, height...)
from `easysession--overwrite-frameset-filter-alist`."
(seq-remove (lambda (entry)
(memq (car entry) list-keys))
easysession--overwrite-frameset-filter-alist))

(defvar easysession--overwrite-frameset-filter-include-geometry-alist
'(;; (GUI:bottom . :never)
(GUI:font . :never)
;; (GUI:fullscreen . :never)
;; (GUI:height . :never)
;; (GUI:left . :never)
;; (GUI:right . :never)
;; (GUI:top . :never)
;; (GUI:width . :never)
(alpha . :never)
(alpha-background . :never)
(auto-lower . :never)
(auto-raise . :never)
(background-color . :never)
(background-mode . :never)
(border-color . :never)
(border-width . :never)
;; (bottom . :never)
(bottom-divider-width . :never)
(buffer-list . :never)
(buffer-predicate . :never)
(buried-buffer-list . :never)
(child-frame-border-width . :never)
(client . :never)
(cursor-color . :never)
(cursor-type . :never)
(delete-before . :never)
(display-type . :never)
(environment . :never)
(font . :never)
(font-backend . :never)
(font-parameter . :never)
(foreground-color . :never)
;; (frameset--text-pixel-height . :never)
;; (frameset--text-pixel-width . :never)
;; (fullscreen . :never)
;; (height . :never)
(horizontal-scroll-bars . :never)
(icon-type . :never)
(inhibit-double-buffering . :never)
(internal-border-width . :never)
;; (left . :never)
(left-fringe . :never)
(line-spacing . :never)
(menu-bar-lines . :never)
(minibuffer . :never)
(mouse-color . :never)
(mouse-wheel-frame . :never)
(name . :never)
(no-accept-focus . :never)
(no-focus-on-map . :never)
(no-special-glyphs . :never)
(ns-appearance . :never)
(outer-window-id . :never)
(override-redirect . :never)
(parent-frame . :never)
(parent-id . :never)
;; (right . :never)
(right-divider-width . :never)
(right-fringe . :never)
(screen-gamma . :never)
(scroll-bar-background . :never)
(scroll-bar-foreground . :never)
(scroll-bar-height . :never)
(scroll-bar-width . :never)
(shaded . :never)
(skip-taskbar . :never)
(sticky . :never)
(tab-bar-lines . :never)
(title . :never)
(tool-bar-lines . :never)
(tool-bar-position . :never)
;; (top . :never)
(tty . :never)
(tty-type . :never)
(undecorated . :never)
(use-frame-synchronization . :never)
(vertical-scroll-bars . :never)
;; (visibility . :never) ; Commenting this fixes: #24
(wait-for-wm . :never)
;; (width . :never)
(window-id . :never)
(window-system . :never)
(lsp-ui-doc-buffer . :never) ; Third party package (Fixes #22)
(z-group . :never))
(easysession--filter-out-frameset-filters '(GUI:bottom
GUI:fullscreen
GUI:height
GUI:left
GUI:right
GUI:top
GUI:width
bottom
frameset--text-pixel-height
frameset--text-pixel-width
fullscreen
height
left
right
top
visibility
width))
"Alist of frame parameters and filtering functions.")

(defvar easysession-file-version 3
Expand Down

0 comments on commit bf95579

Please sign in to comment.