Make session persistence module agnostic
They've been removed from feature/workspaces and moved into core/autoload/sessions, which falls back to desktop.el if persp-mode isn't present. This also offers a substantial speed up to restart+restoring and restoring sessions in general. Also fixes #1210, where the newly spawned frame after doom/restart wasn't focused. Introduces the following commands: - doom/restart - doom/restart-and-restore - doom/quickload-session - doom/quicksave-session - doom/load-session - doom/save-session - +workspace/restore-last-session (alias for doom/quickload-session) And removes - +workspace/load-session - +workspace/save-session - +workspace/load-last-session (renamed to +workspace/restore-last-session) - +workspace/restart-emacs-then-restore (replaced by doom/restart-and-restore) - :ss (ex command) - :sl (ex command)
This commit is contained in:
parent
735ec58b36
commit
8a90f29c91
10 changed files with 181 additions and 143 deletions
|
@ -112,14 +112,6 @@ Returns t if successful, nil otherwise."
|
|||
*persp-hash* (list name))
|
||||
(+workspace-exists-p name))
|
||||
|
||||
;;;###autoload
|
||||
(defun +workspace-load-session (&optional name)
|
||||
"Replace current session with the entire session named NAME. If NAME is nil,
|
||||
use `persp-auto-save-fname'."
|
||||
(mapc #'+workspace-delete (+workspace-list-names))
|
||||
(persp-load-state-from-file
|
||||
(expand-file-name (or name persp-auto-save-fname) persp-save-dir)))
|
||||
|
||||
;;;###autoload
|
||||
(defun +workspace-save (name)
|
||||
"Saves a single workspace (NAME) from the current session. Can be loaded again
|
||||
|
@ -134,18 +126,6 @@ Returns t on success, nil otherwise."
|
|||
(and (member name (persp-list-persp-names-in-file fname))
|
||||
t)))
|
||||
|
||||
;;;###autoload
|
||||
(defun +workspace-save-session (&optional name)
|
||||
"Save a whole session as NAME. If NAME is nil, use `persp-auto-save-fname'.
|
||||
Return t on success, nil otherwise."
|
||||
(let ((fname (expand-file-name (or name persp-auto-save-fname)
|
||||
persp-save-dir)))
|
||||
;; disable auto-saving on kill-emacs if autosaving (i.e. name is nil)
|
||||
(when (or (not name)
|
||||
(string= name persp-auto-save-fname))
|
||||
(setq persp-auto-save-opt 0))
|
||||
(and (persp-save-state-to-file fname) t)))
|
||||
|
||||
;;;###autoload
|
||||
(defun +workspace-new (name)
|
||||
"Create a new workspace named NAME. If one already exists, return nil.
|
||||
|
@ -206,6 +186,9 @@ throws an error."
|
|||
;;
|
||||
;; Commands
|
||||
|
||||
;;;###autoload
|
||||
(defalias '+workspace/restore-last-session #'doom/quickload-session)
|
||||
|
||||
;;;###autoload
|
||||
(defun +workspace/load (name)
|
||||
"Load a workspace and switch to it. If called with C-u, try to reload the
|
||||
|
@ -236,46 +219,6 @@ workspace."
|
|||
(+workspace-message (format "'%s' workspace saved" name) 'success)
|
||||
(+workspace-error (format "Couldn't save workspace %s" name))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +workspace/load-session (&optional name)
|
||||
"Load a session and switch to it. If called with C-u, try to load the last
|
||||
session."
|
||||
(interactive
|
||||
(list
|
||||
(unless current-prefix-arg
|
||||
(completing-read
|
||||
"Session to load: "
|
||||
(directory-files persp-save-dir nil "^[^_.]")
|
||||
nil t))))
|
||||
(condition-case ex
|
||||
(let ((name (or name persp-auto-save-fname)))
|
||||
(+workspace-load-session name)
|
||||
(+workspace-message (format "'%s' workspace loaded" name) 'success))
|
||||
'(error (+workspace-error (cadr ex) t))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +workspace/load-last-session ()
|
||||
"Restore last session and switch to it."
|
||||
(interactive)
|
||||
(+workspace/load-session))
|
||||
|
||||
;;;###autoload
|
||||
(defun +workspace/save-session (&optional name)
|
||||
"Save the current session. If called with C-u, prompt you for the name to save
|
||||
the session as."
|
||||
(interactive
|
||||
(list
|
||||
(when current-prefix-arg
|
||||
(completing-read
|
||||
"Save session as: "
|
||||
(directory-files persp-save-dir nil "^[^_.]")))))
|
||||
(condition-case-unless-debug ex
|
||||
(let ((name (or name persp-auto-save-fname)))
|
||||
(if (+workspace-save-session name)
|
||||
(+workspace-message (format "Saved session as '%s'" name) 'success)
|
||||
(error "Couldn't save session as '%s'" name)))
|
||||
('error (+workspace-error ex t))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +workspace/rename (new-name)
|
||||
"Rename the current workspace."
|
||||
|
@ -437,12 +380,6 @@ the next."
|
|||
|
||||
(t (+workspace-error "Can't delete last workspace" t)))))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +workspace/restart-emacs-then-restore ()
|
||||
"Restarts Emacs, then restores the session."
|
||||
(interactive)
|
||||
(restart-emacs (list "--restore")))
|
||||
|
||||
|
||||
;;
|
||||
;; Tabs display in minibuffer
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue