changeset 14172:da563949c7d7

(desktop-read): Do nothing in batch mode. Clear desktop-delay-hook after use. Simplify.
author Richard M. Stallman <rms@gnu.org>
date Sun, 14 Jan 1996 23:24:40 +0000
parents e8e99446ef2c
children 940083ef25b9
files lisp/desktop.el
diffstat 1 files changed, 20 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/desktop.el	Sun Jan 14 14:30:11 1996 +0000
+++ b/lisp/desktop.el	Sun Jan 14 23:24:40 1996 +0000
@@ -85,6 +85,7 @@
 ;;            f89-kam@nada.kth.se (Klas Mellbourn)   for a mh-e tip.
 ;;            kifer@sbkifer.cs.sunysb.edu (M. Kifer) for a bug hunt.
 ;;            treese@lcs.mit.edu (Win Treese)        for ange-ftp tips.
+;;            pot@cnuce.cnr.it (Francesco Potorti`)  for misc. tips.
 ;; ---------------------------------------------------------------------------
 ;; TODO:
 ;;
@@ -438,20 +439,26 @@
 	    (delete-file filename)))))
 ;; ----------------------------------------------------------------------------
 (defun desktop-read ()
-  "Read the Desktop file and the files it specifies."
+  "Read the Desktop file and the files it specifies.
+This is a no-op when Emacs is running in batch mode."
   (interactive)
-  (let ((filename))
-    (if (file-exists-p (concat "./" desktop-basefilename))
-	(setq desktop-dirname (expand-file-name "./"))
-      (if (file-exists-p (concat "~/" desktop-basefilename))
-	  (setq desktop-dirname (expand-file-name "~/"))
-	(setq desktop-dirname nil)))
-    (if desktop-dirname
-	(progn
-	  (load (concat desktop-dirname desktop-basefilename) t t t)
-	  (run-hooks 'desktop-delay-hook)
-	  (message "Desktop loaded."))
-      (desktop-clear))))
+  (if noninteractive
+      nil
+    (let ((dirs '("./" "~/")))
+      (while (and dirs
+		  (not (file-exists-p (expand-file-name
+				       desktop-basefilename
+				       (car dirs)))))
+	(setq dirs (cdr dirs)))
+      (setq desktop-dirname (and dirs (expand-file-name (car dirs))))
+      (if desktop-dirname
+	  (progn
+	    (load (expand-file-name desktop-basefilename desktop-dirname)
+		  t t t)
+	    (run-hooks 'desktop-delay-hook)
+	    (setq desktop-delay-hook nil)
+	    (message "Desktop loaded."))
+	(desktop-clear)))))
 ;; ----------------------------------------------------------------------------
 (defun desktop-load-default ()
   "Load the `default' start-up library manually.