]> code.delx.au - gnu-emacs/blobdiff - lisp/desktop.el
Update copyright year to 2015
[gnu-emacs] / lisp / desktop.el
index 26d288bf9cd7924b964a20500630de313f7ff04a..3845f940d0285a00e4d25d7b2a8d7f409cbcbf08 100644 (file)
@@ -1,6 +1,7 @@
 ;;; desktop.el --- save partial status of Emacs when killed -*- lexical-binding: t -*-
 
-;; Copyright (C) 1993-1995, 1997, 2000-2014 Free Software Foundation, Inc.
+;; Copyright (C) 1993-1995, 1997, 2000-2015 Free Software Foundation,
+;; Inc.
 
 ;; Author: Morten Welinder <terra@diku.dk>
 ;; Keywords: convenience
@@ -528,6 +529,8 @@ Furthermore the major mode function must be autoloaded.")
 
 (defcustom desktop-minor-mode-table
   '((auto-fill-function auto-fill-mode)
+    (defining-kbd-macro nil)
+    (isearch-mode nil)
     (vc-mode nil)
     (vc-dired-mode nil)
     (erc-track-minor-mode nil)
@@ -938,16 +941,17 @@ Frames with a non-nil `desktop-dont-save' parameter are not saved."
        (and desktop-restore-frames
             (frameset-save nil
                            :app desktop--app-id
-                           :name (concat user-login-name "@" system-name)
+                           :name (concat user-login-name "@" (system-name))
                            :predicate #'desktop--check-dont-save))))
 
 ;;;###autoload
-(defun desktop-save (dirname &optional release auto-save)
+(defun desktop-save (dirname &optional release only-if-changed)
   "Save the desktop in a desktop file.
 Parameter DIRNAME specifies where to save the desktop file.
 Optional parameter RELEASE says whether we're done with this desktop.
-If AUTO-SAVE is non-nil, compare the saved contents to the one last saved,
-and don't save the buffer if they are the same."
+If ONLY-IF-CHANGED is non-nil, compare the current desktop information
+to that in the desktop file, and if the desktop information has not
+changed since it was last saved then do not rewrite the file."
   (interactive (list
                 ;; Or should we just use (car desktop-path)?
                 (let ((default (if (member "." desktop-path)
@@ -1020,7 +1024,7 @@ and don't save the buffer if they are the same."
 
          (setq default-directory desktop-dirname)
          ;; When auto-saving, avoid writing if nothing has changed since the last write.
-         (let* ((beg (and auto-save
+         (let* ((beg (and only-if-changed
                           (save-excursion
                             (goto-char (point-min))
                             ;; Don't check the header with changing timestamp
@@ -1372,7 +1376,9 @@ after that many seconds of idle time."
        ;; Restore buffer list order with new buffer at end. Don't change
        ;; the order for old desktop files (old desktop module behavior).
        (unless (< desktop-file-version 206)
-         (mapc 'bury-buffer buffer-list)
+         (dolist (buf buffer-list)
+            (and (buffer-live-p buf)
+                 (bury-buffer buf)))
          (when result (bury-buffer result)))
        (when result
          (unless (or desktop-first-buffer (< desktop-file-version 206))
@@ -1408,8 +1414,8 @@ after that many seconds of idle time."
             (if (consp desktop-buffer-mark)
                 (progn
                   (move-marker (mark-marker) (car desktop-buffer-mark))
-                  ;; FIXME: Should we call (de)activate-mark instead?
-                  (setq mark-active (car (cdr desktop-buffer-mark))))
+                  (if (car (cdr desktop-buffer-mark))
+                      (activate-mark 'dont-touch-tmm)))
               (move-marker (mark-marker) desktop-buffer-mark)))
          ;; Never override file system if the file really is read-only marked.
          (when desktop-buffer-read-only (setq buffer-read-only desktop-buffer-read-only))
@@ -1513,8 +1519,15 @@ If there are no buffers left to create, kill the timer."
         (setq command-line-args (delete key command-line-args))
         (desktop-save-mode 0)))
     (when desktop-save-mode
-      (desktop-read)
-      (setq inhibit-startup-screen t))))
+      ;; People don't expect emacs -nw, or --daemon,
+      ;; to create graphical frames (bug#17693).
+      ;; TODO perhaps there should be a separate value
+      ;; for desktop-restore-frames to control this startup behavior?
+      (let ((desktop-restore-frames (and desktop-restore-frames
+                                         initial-window-system
+                                         (not (daemonp)))))
+        (desktop-read)
+        (setq inhibit-startup-screen t)))))
 
 ;; So we can restore vc-dir buffers.
 (autoload 'vc-dir-mode "vc-dir" nil t)