From 7c34b25254d99d89ad9769f078f107538f79fba9 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Wed, 6 Jul 2016 17:16:14 +0200 Subject: emacs: added a way to cleanup the workspace MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is specially useful if you want to start from scratch in a client-daemon setup. Signed-off-by: Miquel Sabaté Solà --- emacs/init.el | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'emacs/init.el') diff --git a/emacs/init.el b/emacs/init.el index f293d66..0b01f75 100644 --- a/emacs/init.el +++ b/emacs/init.el @@ -153,6 +153,8 @@ ;; Let flyspell be performant. (defvar flyspell-issue-message-flag nil) +;; Custom functions + ;; Allow users to fetch the latest Emacs' NEWS file. (defun view-emacs-latest-news () "Allow users to fetch the latest Emacs' NEWS file." @@ -164,6 +166,24 @@ (find-file-read-only "/tmp/emacs-news" t)) +(defun mssola-cleanup-workspace () + "Cleanup the current workspace by killing all buffers and windows. +The user will end up in the *scratch* buffer." + + (interactive) + (when (y-or-n-p "Are you sure that you want to cleanup your workspace? ") + (delete-other-windows) + (switch-to-buffer "*scratch*") + + ; Code taken from 'crux-kill-other-buffers in the crux package by + ; @bbatsov. It's the same but the confirmation has been removed since we are + ; already asking for permission before. + (seq-each + #'kill-buffer + (delete (current-buffer) (seq-filter #'buffer-file-name (buffer-list)))))) + +(global-set-key (kbd "C-c a") 'mssola-cleanup-workspace) + ;;; Packages ;; I'm using use-package to handle my installed packages. I don't know if it's -- cgit v1.2.3