changeset 32366:40d8b29df57e

(desktop-modes-not-to-save): New var. (desktop-save-buffer-p): Use it. Also, obey desktop-buffers-not-to-save even for non-file buffers. (desktop-buffer-file): Use pop-to-buffer if switch-to-buffer fails.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Tue, 10 Oct 2000 16:42:37 +0000
parents ccb29a0414b2
children 7c181d033dae
files lisp/desktop.el
diffstat 1 files changed, 21 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/desktop.el	Tue Oct 10 13:04:09 2000 +0000
+++ b/lisp/desktop.el	Tue Oct 10 16:42:37 2000 +0000
@@ -182,6 +182,11 @@
   :type 'regexp
   :group 'desktop)
 
+(defcustom desktop-modes-not-to-save nil
+  "List of major modes whose buffers should not be saved."
+  :type '(repeat symbol)
+  :group 'desktop)
+
 (defcustom desktop-buffer-major-mode nil
   "When desktop creates a buffer, this holds the desired Major mode."
   :type 'symbol
@@ -427,16 +432,17 @@
 FILENAME is the visited file name, BUFNAME is the buffer name, and
 MODE is the major mode."
   (let ((case-fold-search nil))
-    (or (and filename
-	     (not (string-match desktop-buffers-not-to-save bufname))
-	     (not (string-match desktop-files-not-to-save filename)))
-	(and (eq mode 'dired-mode)
-	     (save-excursion
-	       (set-buffer (get-buffer bufname))
-	       (not (string-match desktop-files-not-to-save
-				  default-directory))))
-	(and (null filename)
-	     (memq mode '(Info-mode rmail-mode))))))
+    (and (not (string-match desktop-buffers-not-to-save bufname))
+	 (not (memq mode desktop-modes-not-to-save))
+	 (or (and filename
+		  (not (string-match desktop-files-not-to-save filename)))
+	     (and (eq mode 'dired-mode)
+		  (save-excursion
+		    (set-buffer (get-buffer bufname))
+		    (not (string-match desktop-files-not-to-save
+				       default-directory))))
+	     (and (null filename)
+		  (memq mode '(Info-mode rmail-mode)))))))
 ;; ----------------------------------------------------------------------------
 (defun desktop-save (dirname)
   "Save the Desktop file.  Parameter DIRNAME specifies where to save desktop."
@@ -616,7 +622,10 @@
 		   (y-or-n-p (format
 			      "File \"%s\" no longer exists. Re-create? "
 			      desktop-buffer-file-name))))
-	  (progn (find-file desktop-buffer-file-name) (current-buffer))
+	  (let ((buf (find-file-noselect desktop-buffer-file-name)))
+	    (condition-case nil
+		(switch-to-buffer buf)
+	      (error (pop-to-buffer buf))))
 	'ignored)))
 ;; ----------------------------------------------------------------------------
 ;; Create a buffer, load its file, set is mode, ...;  called from Desktop file
@@ -687,4 +696,4 @@
 
 (provide 'desktop)
 
-;; desktop.el ends here.
+;;; desktop.el ends here