Skip to content

Commit

Permalink
Remove prefix and rename easysession-mode-line -> easysession-mode-li…
Browse files Browse the repository at this point in the history
…ne-misc-info

Remove: easysession-mode-line-prefix
  • Loading branch information
jamescherti committed Sep 14, 2024
1 parent bc4bd7a commit 6cc9fde
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 32 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,18 @@ The `easysession` package can be installed from MELPA by adding the following to
(use-package easysession
:ensure t
:custom
;; Interval between automatic session saves
(easysession-save-interval (* 10 60))
(easysession-mode-line t)
;; Make the current session name appear in the mode-line
(easysession-mode-line-misc-info t)
:init
(add-hook 'after-init-hook #'easysession-load-including-geometry 98)
(add-hook 'after-init-hook #'easysession-save-mode 99))
```

Note that:
- `easysession-load-including-geometry` is not needed after Emacs is loaded if you do not want EasySession to move or resize the Emacs frame when switching sessions. Instead, use `easysession-switch-to` or `easysession-load` to switch to another session or reload the current session without resizing or moving the Emacs frames.
- `easysession-mode-line` determines whether the current session name appears in the mode line by adding `easysession` to `mode-line-misc-info`. Alternatively, `easysession-save-mode-lighter-show-session-name` can be used to display the session name in the lighter.
- `easysession-mode-line` determines whether the current session name appears in the mode line by adding EasySession to `mode-line-misc-info`. Alternatively, the `easysession-save-mode-lighter-show-session-name` can be set to `t` to make EasySession display the session name in the lighter.
- The `easysession-save-mode` ensures that the current session is automatically saved every `easysession-save-interval` seconds and when emacs quits.
- The `easysession-save-interval` variable determines the interval between automatic session saves. Setting it to nil disables timer-based autosaving, causing `easysession-save-mode` to save only when Emacs exits.

Expand Down
41 changes: 11 additions & 30 deletions easysession.el
Original file line number Diff line number Diff line change
Expand Up @@ -113,43 +113,37 @@ activated when `easysession-save-mode' is enabled."
:group 'easysession)

;; Mode line
(defcustom easysession-mode-line-prefix "EasySession"
"Prefix string used to customize the session name display in the mode-line."
:type 'string
:group 'easysession)

(defface easysession-mode-line-session-name-face
'((t :inherit font-lock-constant-face :weight bold))
"Face used in the mode-line to indicate the current session.")

(defcustom easysession-mode-line-format '(" ["
easysession-mode-line-prefix
":"
easysession-mode-line-session-name
"] ")
(defcustom easysession-mode-line-misc-info-format
'(" [EasySession:"
easysession-mode-line-session-name "] ")
"Mode-line format used to display the session name."
:type 'sexp
:group 'easysession
:set (lambda (symbol value)
(set symbol value)
(setq mode-line-misc-info
(assq-delete-all 'easysession-mode-line mode-line-misc-info))
(add-to-list 'mode-line-misc-info `(easysession-mode-line
(assq-delete-all 'easysession-mode-line-misc-info
mode-line-misc-info))
(add-to-list 'mode-line-misc-info `(easysession-mode-line-misc-info
,value))))
(put 'easysession-mode-line-format 'risky-local-variable t)
(put 'easysession-mode-line-misc-info-format 'risky-local-variable t)

(defcustom easysession-mode-line nil
(defcustom easysession-mode-line-misc-info nil
"If non-nil, add `easysession` to `mode-line-misc-info'. If nil, remove it."
:type 'boolean
:group 'easysession
:set (lambda (symbol value)
(set symbol value)
(setq mode-line-misc-info
(assq-delete-all
'easysession-mode-line mode-line-misc-info))
'easysession-mode-line-misc-info mode-line-misc-info))
(add-to-list 'mode-line-misc-info
`(easysession-mode-line
,easysession-mode-line-format))))
`(easysession-mode-line-misc-info
easysession-mode-line-misc-info-format))))

;; Lighter
(defvar easysession-save-mode-lighter " EasySeSave"
Expand Down Expand Up @@ -981,26 +975,13 @@ non-nil, the current session is saved."
'mouse-face 'mode-line-highlight)))
""))

(defun easysession--mode-line-prefix-format ()
"Compose EasySession's mode-line."
(if (bound-and-true-p easysession-mode-line-prefix)
(eval easysession-mode-line-prefix)
""))

(defvar easysession-mode-line-session-name
'(:eval (easysession--mode-line-session-name-format))
"Mode line specification for displaying the current session name.
The value is evaluated to generate a formatted string that shows the current
session name in the mode line.")
(put 'easysession-mode-line-session-name 'risky-local-variable t)

(defvar easysession-mode-line-prefix
'(:eval (easysession--mode-line-prefix-format))
"Prefix string for the mode line format.
The value is evaluated to produce a prefix string that precedes the current
session name in the mode line.")
(put 'easysession-mode-line-prefix 'risky-local-variable t)

;;;###autoload
(define-minor-mode easysession-save-mode
"Toggle `easysession-save-mode'."
Expand Down

0 comments on commit 6cc9fde

Please sign in to comment.