Function: projectile-session-mode
projectile-session-mode is an autoloaded, interactive and
byte-compiled function defined in projectile.el.
Signature
(projectile-session-mode &optional ARG)
Documentation
Global minor mode giving each project its own tab-bar tab.
When enabled, tab-bar-mode(var)/tab-bar-mode(fun) 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(var)/tab-bar-mode(fun) and any
existing tabs untouched.
This is a global minor mode. If called interactively, toggle the
Projectile-Session mode mode. If the prefix argument is
positive, enable the mode, and if it is zero or negative, disable
the mode.
If called from Lisp, toggle the mode if ARG is toggle. Enable
the mode if ARG is nil, omitted, or is a positive number.
Disable the mode if ARG is a negative number.
To check whether the minor mode is enabled in the current buffer,
evaluate (default-value \=projectile-session-mode)'.
The mode's hook is called both when the mode is enabled and when it is disabled.
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))))