(diff-end-of-hunk): Revert 2008-01-08 change.
[bpt/emacs.git] / lisp / desktop.el
index 191d1db..4837aee 100644 (file)
@@ -1,7 +1,7 @@
 ;;; desktop.el --- save partial status of Emacs when killed
 
 ;; Copyright (C) 1993, 1994, 1995, 1997, 2000, 2001, 2002, 2003,
-;;   2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+;;   2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Author: Morten Welinder <terra@diku.dk>
 ;; Keywords: convenience
@@ -11,7 +11,7 @@
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
+;; the Free Software Foundation; either version 3, or (at your option)
 ;; any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 
 ;;; Code:
 
+(defvar uniquify-managed)
+
 (defvar desktop-file-version "206"
   "Version number of desktop file format.
 Written into the desktop file and used at desktop read to provide
@@ -204,7 +206,7 @@ the normal hook `desktop-not-loaded-hook' is run."
     (const :tag "Don't load" nil)
     (const :tag "Ask the user" ask))
   :group 'desktop
-  :version "23.1")
+  :version "22.2")
 
 (defcustom desktop-base-file-name
   (convert-standard-filename ".emacs.desktop")
@@ -219,7 +221,7 @@ the normal hook `desktop-not-loaded-hook' is run."
   "Name of lock file for Emacs desktop, excluding the directory part."
   :type 'file
   :group 'desktop
-  :version "23.1")
+  :version "22.2")
 
 (defcustom desktop-path '("." "~")
   "List of directories to search for the desktop file.
@@ -253,7 +255,7 @@ May be used to deal with accidental multiple Emacs jobs."
   :type 'hook
   :group 'desktop
   :options '(desktop-save-mode-off save-buffers-kill-emacs)
-  :version "23.1")
+  :version "22.2")
 
 (defcustom desktop-after-read-hook nil
   "Normal hook run after a successful `desktop-read'.
@@ -454,7 +456,8 @@ Furthermore the major mode function must be autoloaded.")
 (defcustom desktop-minor-mode-table
   '((auto-fill-function auto-fill-mode)
     (vc-mode nil)
-    (vc-dired-mode nil))
+    (vc-dired-mode nil)
+    (erc-track-minor-mode nil))
   "Table mapping minor mode variables to minor mode functions.
 Each entry has the form (NAME RESTORE-FUNCTION).
 NAME is the name of the buffer-local variable indicating that the minor
@@ -626,9 +629,7 @@ is nil, ask the user where to save the desktop."
       (setq desktop-dirname
             (file-name-as-directory
              (expand-file-name
-              (call-interactively
-               (lambda (dir)
-                 (interactive "DDirectory for desktop file: ") dir))))))
+             (read-directory-name "Directory for desktop file: " nil nil t)))))
     (condition-case err
        (desktop-save desktop-dirname t)
       (file-error
@@ -650,12 +651,16 @@ is nil, ask the user where to save the desktop."
       value)))
 
 ;; ----------------------------------------------------------------------------
+(declare-function uniquify-item-base "uniquify" (cl-x) t) ; defstruct
+
 (defun desktop-buffer-info (buffer)
   (set-buffer buffer)
   (list
    ;; basic information
-   (desktop-file-name (buffer-file-name) dirname)
-   (buffer-name)
+   (desktop-file-name (buffer-file-name) desktop-dirname)
+   (if (bound-and-true-p uniquify-managed)
+       (uniquify-item-base (car uniquify-managed))
+     (buffer-name))
    major-mode
    ;; minor modes
    (let (ret)
@@ -675,7 +680,7 @@ is nil, ask the user where to save the desktop."
    buffer-read-only
    ;; auxiliary information
    (when (functionp desktop-save-buffer)
-     (funcall desktop-save-buffer dirname))
+     (funcall desktop-save-buffer desktop-dirname))
    ;; local variables
    (let ((locals desktop-locals-to-save)
         (loclist (buffer-local-variables))
@@ -898,7 +903,7 @@ See also `desktop-base-file-name'."
                (insert "\n  " (desktop-value-to-string e)))
              (insert ")\n\n")))
 
-         (setq default-directory dirname)
+         (setq default-directory desktop-dirname)
          (let ((coding-system-for-write 'emacs-mule))
            (write-region (point-min) (point-max) (desktop-full-file-name) nil 'nomessage))
          ;; We remember when it was modified (which is presumably just now).
@@ -964,9 +969,9 @@ It returns t if a desktop file was loaded, nil otherwise."
                       (not (y-or-n-p (format "Warning: desktop file appears to be in use by PID %s.\n\
 Using it may cause conflicts.  Use it anyway? " owner)))))
              (progn
-               (setq desktop-dirname nil)
                (let ((default-directory desktop-dirname))
                  (run-hooks 'desktop-not-loaded-hook))
+               (setq desktop-dirname nil)
                (message "Desktop file in use; not loaded."))
            (desktop-lazy-abort)
            ;; Evaluate desktop buffer and remember when it was modified.
@@ -1151,7 +1156,7 @@ directory DIRNAME."
           (setq desktop-first-buffer result))
         (set-buffer result)
         (unless (equal (buffer-name) desktop-buffer-name)
-          (rename-buffer desktop-buffer-name))
+          (rename-buffer desktop-buffer-name t))
         ;; minor modes
         (cond ((equal '(t) desktop-buffer-minor-modes) ; backwards compatible
                (auto-fill-mode 1))