Skip to content

Instantly share code, notes, and snippets.

@ffevotte
Created December 19, 2013 20:19
Show Gist options
  • Save ffevotte/8045566 to your computer and use it in GitHub Desktop.
Save ffevotte/8045566 to your computer and use it in GitHub Desktop.
Additions to `desktop.el` to facilitate switching between saved sessions
;;; Desktop
(setq desktop-save 'ask)
(defvar desktop-base-dir "~/.emacs.d/desktops/"
"Base directory for desktop files")
(defun desktop--set-frame-title ()
(setq frame-title-format
(list (concat "%b - Emacs ["
(file-name-nondirectory (directory-file-name desktop-dirname))
"]"))))
(defun desktop-load (name)
(interactive
(list
(completing-read "Desktop name: "
(remove "." (remove ".." (directory-files desktop-base-dir))))))
(desktop-change-dir (concat desktop-base-dir name))
(desktop--set-frame-title)
(desktop-save-mode 1))
(defun desktop-create ()
(interactive)
(when (or (not (boundp 'desktop-dirname))
(null desktop-dirname))
(let ((name (read-from-minibuffer "Desktop name: ")))
(setq desktop-dirname (concat desktop-base-dir name))
(make-directory desktop-dirname 'parents)))
(desktop-save desktop-dirname)
(desktop--set-frame-title)
(desktop-save-mode 1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment