changeset 18581:45f27efe77c7

(desktop-clear-preserve-buffers): New variable. (desktop-clear): Kill all buffers except internal ones and those listed in desktop-clear-preserve-buffers.
author Richard M. Stallman <rms@gnu.org>
date Fri, 04 Jul 1997 00:13:36 +0000
parents 717e09103d06
children fd88d8f82bbc
files lisp/desktop.el
diffstat 1 files changed, 18 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/desktop.el	Fri Jul 04 00:11:24 1997 +0000
+++ b/lisp/desktop.el	Fri Jul 04 00:13:36 1997 +0000
@@ -227,7 +227,16 @@
     (if (consp here)
 	(setcdr here nil))))
 ;; ----------------------------------------------------------------------------
-(defun desktop-clear () "Empty the Desktop."
+(defcustom desktop-clear-preserve-buffers
+  '("*scratch*" "*Messages*")
+  "*Buffer names that `desktop-clear' should not delete."
+  :type '(repeat string)
+  :group 'desktop)
+
+(defun desktop-clear ()
+  "Empty the Desktop.
+This kills all buffers except for internal ones
+and those listed in `desktop-clear-preserve-buffers'."
   (interactive)
   (setq kill-ring nil
 	kill-ring-yank-pointer nil
@@ -235,8 +244,14 @@
 	search-ring-yank-pointer nil
 	regexp-search-ring nil
 	regexp-search-ring-yank-pointer nil)
-;;;  What a screw!
-;;;  (mapcar (function kill-buffer) (buffer-list))
+  (let ((buffers (buffer-list)))
+    (while buffers
+      (or (member (buffer-name (car buffers)) desktop-clear-preserve-buffers)
+	  ;; Don't kill buffers made for internal purposes.
+	  (and (not (equal (buffer-name (car buffers)) ""))
+	       (eq (aref (buffer-name (car buffers)) 0) ?\ ))
+	  (kill-buffer (car buffers)))
+      (setq buffers (cdr buffers))))
   (delete-other-windows))
 ;; ----------------------------------------------------------------------------
 (add-hook 'kill-emacs-hook 'desktop-kill)