Show
Ignore:
Timestamp:
07/01/06 08:27:06 (2 years ago)
Author:
miyoshi
Message:

Sync up with Emacs CVS HEAD.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lisp/desktop.el

    r4085 r4098  
    154154  "Toggle desktop saving mode. 
    155155With numeric ARG, turn desktop saving on if ARG is positive, off 
    156 otherwise.  See variable `desktop-save' for a description of when the 
    157 desktop is saved." 
     156otherwise.  If desktop saving is turned on, the state of Emacs is 
     157saved from one session to another.  See variable `desktop-save' 
     158and function `desktop-read' for details." 
    158159  :global t 
    159160  :group 'desktop) 
     
    176177The variables `desktop-dirname' and `desktop-base-file-name' 
    177178determine where the desktop is saved." 
    178   :type '(choice 
     179  :type 
     180  '(choice 
    179181    (const :tag "Always save" t) 
    180182    (const :tag "Always ask" ask) 
     
    213215(defcustom desktop-no-desktop-file-hook nil 
    214216  "Normal hook run when `desktop-read' can't find a desktop file. 
     217Run in the directory in which the desktop file was sought. 
    215218May be used to show a dired buffer." 
    216219  :type 'hook 
     
    223226  :type 'hook 
    224227  :group 'desktop 
     228  :options '(list-buffers) 
    225229  :version "22.1") 
    226230 
    227231(defcustom desktop-save-hook nil 
    228232  "Normal hook run before the desktop is saved in a desktop file. 
    229 This is useful for truncating history lists, for example." 
     233Run with the desktop buffer current with only the header present. 
     234May be used to add to the desktop code or to truncate history lists, 
     235for example." 
    230236  :type 'hook 
    231237  :group 'desktop) 
     
    283289    buffer-file-coding-system 
    284290    indent-tabs-mode 
     291    tab-width 
    285292    indicate-buffer-boundaries 
    286293    indicate-empty-lines 
     
    476483  "The directory in which the desktop file should be saved.") 
    477484 
     485(defun desktop-full-file-name (&optional dirname) 
     486  "Return the full name of the desktop file in DIRNAME. 
     487DIRNAME omitted or nil means use `desktop-dirname'." 
     488  (expand-file-name desktop-base-file-name (or dirname desktop-dirname))) 
     489 
    478490(defconst desktop-header 
    479491";; -------------------------------------------------------------------------- 
     
    493505 
    494506;; ---------------------------------------------------------------------------- 
     507;;;###autoload 
    495508(defun desktop-clear () 
    496509  "Empty the Desktop. 
     
    529542If the desktop should be saved and `desktop-dirname' 
    530543is nil, ask the user where to save the desktop." 
    531   (when 
    532     (and 
    533       desktop-save-mode 
    534       (let ((exists (file-exists-p (expand-file-name desktop-base-file-name desktop-dirname)))) 
    535         (or 
    536           (eq desktop-save t) 
    537           (and exists (memq desktop-save '(ask-if-new if-exists))) 
    538           (and 
    539             (or 
    540               (memq desktop-save '(ask ask-if-new)) 
    541               (and exists (eq desktop-save 'ask-if-exists))) 
    542             (y-or-n-p "Save desktop? "))))) 
     544  (when (and desktop-save-mode 
     545             (let ((exists (file-exists-p (desktop-full-file-name)))) 
     546               (or (eq desktop-save t) 
     547                   (and exists (memq desktop-save '(ask-if-new if-exists))) 
     548                   (and 
     549                    (or (memq desktop-save '(ask ask-if-new)) 
     550                        (and exists (eq desktop-save 'ask-if-exists))) 
     551                    (y-or-n-p "Save desktop? "))))) 
    543552    (unless desktop-dirname 
    544553      (setq desktop-dirname 
    545         (file-name-as-directory 
    546           (expand-file-name 
    547             (call-interactively 
    548               (lambda (dir) (interactive "DDirectory for desktop file: ") dir)))))) 
     554            (file-name-as-directory 
     555             (expand-file-name 
     556              (call-interactively 
     557               (lambda (dir) 
     558                 (interactive "DDirectory for desktop file: ") dir)))))) 
    549559    (condition-case err 
    550       (desktop-save desktop-dirname) 
     560        (desktop-save desktop-dirname) 
    551561      (file-error 
    552         (unless (yes-or-no-p "Error while saving the desktop.  Ignore? ") 
    553           (signal (car err) (cdr err))))))) 
     562       (unless (yes-or-no-p "Error while saving the desktop.  Ignore? ") 
     563         (signal (car err) (cdr err))))))) 
    554564 
    555565;; ---------------------------------------------------------------------------- 
     
    716726 
    717727;; ---------------------------------------------------------------------------- 
     728;;;###autoload 
    718729(defun desktop-save (dirname) 
    719730  "Save the desktop in a desktop file. 
     
    724735  (setq dirname (file-name-as-directory (expand-file-name dirname))) 
    725736  (save-excursion 
    726     (let ((filename (expand-file-name desktop-base-file-name dirname)) 
     737    (let ((filename (desktop-full-file-name dirname)) 
    727738          (info 
    728739            (mapcar 
     
    803814 
    804815;; ---------------------------------------------------------------------------- 
     816;;;###autoload 
    805817(defun desktop-remove () 
    806818  "Delete desktop file in `desktop-dirname'. 
     
    808820  (interactive) 
    809821  (when desktop-dirname 
    810     (let ((filename (expand-file-name desktop-base-file-name desktop-dirname))) 
     822    (let ((filename (desktop-full-file-name))) 
    811823      (setq desktop-dirname nil) 
    812824      (when (file-exists-p filename) 
     
    831843  (unless noninteractive 
    832844    (setq desktop-dirname 
    833       (file-name-as-directory 
    834         (expand-file-name 
    835           (or 
    836             ;; If DIRNAME is specified, use it. 
    837             (and (< 0 (length dirname)) dirname) 
    838             ;; Otherwise search desktop file in desktop-path. 
    839             (let ((dirs desktop-path)) 
    840               (while 
    841                 (and 
    842                   dirs 
    843                   (not 
    844                     (file-exists-p (expand-file-name desktop-base-file-name (car dirs))))) 
    845                 (setq dirs (cdr dirs))) 
    846               (and dirs (car dirs))) 
    847             ;; If not found and `desktop-path' is non-nil, use its first element. 
    848             (and desktop-path (car desktop-path)) 
    849             ;; Default: Home directory. 
    850             "~")))) 
    851     (if (file-exists-p (expand-file-name desktop-base-file-name desktop-dirname)) 
     845          (file-name-as-directory 
     846           (expand-file-name 
     847            (or 
     848             ;; If DIRNAME is specified, use it. 
     849             (and (< 0 (length dirname)) dirname) 
     850             ;; Otherwise search desktop file in desktop-path. 
     851             (let ((dirs desktop-path)) 
     852               (while (and dirs 
     853                           (not (file-exists-p 
     854                                 (desktop-full-file-name (car dirs))))) 
     855                 (setq dirs (cdr dirs))) 
     856               (and dirs (car dirs))) 
     857             ;; If not found and `desktop-path' is non-nil, use its first element. 
     858             (and desktop-path (car desktop-path)) 
     859             ;; Default: Home directory. 
     860             "~")))) 
     861    (if (file-exists-p (desktop-full-file-name)) 
    852862      ;; Desktop file found, process it. 
    853863      (let ((desktop-first-buffer nil) 
     
    856866        (setq desktop-lazy-timer nil) 
    857867        ;; Evaluate desktop buffer. 
    858         (load (expand-file-name desktop-base-file-name desktop-dirname) t t t) 
     868        (load (desktop-full-file-name) t t t) 
    859869        ;; `desktop-create-buffer' puts buffers at end of the buffer list. 
    860870        ;; We want buffers existing prior to evaluating the desktop (and not reused) 
     
    926936  (unless desktop-dirname 
    927937    (error "Unknown desktop directory")) 
    928   (unless (file-exists-p (expand-file-name desktop-base-file-name desktop-dirname)) 
     938  (unless (file-exists-p (desktop-full-file-name)) 
    929939    (error "No desktop file found")) 
    930940  (desktop-clear)