Variable: projectile-session-mode
projectile-session-mode is a customizable variable defined in
projectile.el.
Value
nil
Documentation
Non-nil if Projectile-Session mode is enabled.
See the projectile-session-mode(var)/projectile-session-mode(fun) command
for a description of this minor mode.
Setting this variable directly does not take effect;
either customize it (see the info node (emacs)Easy Customization)
or call the function projectile-session-mode(var)/projectile-session-mode(fun).
Key Bindings
Source Code
;; Defined in ~/.emacs.d/elpa/projectile-20260820.1509/projectile.el
;;;###autoload
(define-minor-mode projectile-session-mode
"Global minor mode giving each project its own `tab-bar' tab.
When enabled, `tab-bar-mode' is turned on and project switching becomes
tab-aware: switching to a project selects its existing tab, restoring
that project's live window layout, when one is open; otherwise it opens
a fresh tab dedicated to the project and populates it via
`projectile-session-default-action'. Each project tab is stamped with
its root and named after the project (see
`projectile-session-tab-name-function').
If the mode is enabled from inside a project, the tab you're already on
is adopted so it isn't left unowned.
Disabling the mode restores `projectile-switch-project-action' to the
value it had when the mode was enabled; it leaves `tab-bar-mode' and any
existing tabs untouched."
:group 'projectile
:global t
:require 'projectile
(cond
(projectile-session-mode
(unless (bound-and-true-p tab-bar-mode)
(tab-bar-mode 1))
;; Guard the save so re-enabling an already-on mode (config re-eval, a
;; startup hook, `custom-set' plus code) can't capture our own action as
;; the "saved" value and lose the user's real one on the next disable.
(unless (eq projectile-switch-project-action
#'projectile-session-switch-project-action)
(setq projectile-session--saved-switch-action projectile-switch-project-action))
(setq projectile-switch-project-action #'projectile-session-switch-project-action)
;; Autosave wiring. `add-hook' is idempotent for an `eq' function, so a
;; double enable can't stack duplicates; the actual saving is gated on
;; `projectile-session-autosave' inside the hook functions.
(add-hook 'projectile-before-switch-project-hook
#'projectile-session--maybe-autosave)
(add-hook 'kill-emacs-hook #'projectile-session--autosave-on-kill)
;; Restore-on-startup wiring. The handler is gated on
;; `projectile-session-restore-on-startup' and `emacs-startup-hook' fires
;; once, right after init, so setting the mode plus the defcustom in init
;; restores after startup; enabling the mode later simply never fires it.
;; `add-hook' is idempotent for an `eq' function, so a double enable can't
;; stack duplicates.
(add-hook 'emacs-startup-hook #'projectile-session--maybe-restore-on-startup)
;; Re-simplify a survivor's name when its same-named sibling tab is
;; closed. `add-hook' is idempotent for an `eq' function, so a double
;; enable can't stack duplicates.
(add-hook 'tab-bar-tab-pre-close-functions
#'projectile-session--on-tab-close)
(projectile-session--adopt-current-tab))
(t
(when (eq projectile-switch-project-action
#'projectile-session-switch-project-action)
(setq projectile-switch-project-action
projectile-session--saved-switch-action))
(setq projectile-session--saved-switch-action nil)
(remove-hook 'projectile-before-switch-project-hook
#'projectile-session--maybe-autosave)
(remove-hook 'kill-emacs-hook #'projectile-session--autosave-on-kill)
(remove-hook 'emacs-startup-hook
#'projectile-session--maybe-restore-on-startup)
(remove-hook 'tab-bar-tab-pre-close-functions
#'projectile-session--on-tab-close))))