From 131cd421c0b41559c0a93e89cd3e1888912b1e2f Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Tue, 6 Aug 2013 15:53:20 +0200 Subject: [PATCH] Add desktop-registry-remove-desktop - desktop-registry.el (desktop-registry--completing-read): (desktop-registry-remove-desktop): New functions. (desktop-registry-change-desktop): Use `desktop-registry--completing-read' to interactively ask the user which desktop to switch to. --- NEWS | 7 +++++++ README.org | 3 +++ desktop-registry.el | 20 +++++++++++++++++--- 3 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 NEWS diff --git a/NEWS b/NEWS new file mode 100644 index 0000000..b9ba2f2 --- /dev/null +++ b/NEWS @@ -0,0 +1,7 @@ +# -*- mode: org; -*- +#+STARTUP: showall + +* Development + + - Add =desktop-registry-remove-desktop= command to remove desktops you + no longer (want to) use. diff --git a/README.org b/README.org index 8d31e3e..aefc2b1 100644 --- a/README.org +++ b/README.org @@ -24,3 +24,6 @@ to fix that. To switch between desktops you can use =desktop-registry-change-desktop=, this will prompt (with completion) for the directory you would like to load. + + When you're done with a desktop or want to get rid of a desktop for + another reason you can use =desktop-registry-remove-desktop=. diff --git a/desktop-registry.el b/desktop-registry.el index 6aaef14..c8bc55e 100644 --- a/desktop-registry.el +++ b/desktop-registry.el @@ -63,12 +63,26 @@ (error "No desktop loaded")) (desktop-registry-add-directory desktop-dirname)) +(defun desktop-registry--completing-read () + "Ask the user to pick a desktop directory." + (completing-read "Directory: " desktop-registry-registry nil nil + nil 'desktop-registry--history)) + +;;;###autoload +(defun desktop-registry-remove-desktop (desktop) + "Remove DESKTOP from the desktop registry." + (interactive (list (desktop-registry--completing-read))) + (let ((spec (assoc desktop desktop-registry-registry))) + (if spec + (customize-save-variable + 'desktop-registry-registry + (delete spec desktop-registry-registry)) + (error "Unknown desktop: %s" desktop)))) + ;;;###autoload (defun desktop-registry-change-desktop (name) "Change to the desktop named NAME." - (interactive - (list (completing-read "Directory: " desktop-registry-registry nil nil - nil 'desktop-registry--history))) + (interactive (list (desktop-registry--completing-read))) (desktop-change-dir (cdr (assoc name desktop-registry-registry)))) ;;;###autoload