[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: desktop~ ?

From: Chuck Siska
Subject: Re: desktop~ ?
Date: Tue, 17 Sep 2002 10:36:01 -0700

thomas --

i've hacked desktop-save to do this and load my version in my
.emacs file.  it's below.  i've only made a few changes to it.
good luck.

-- chuck

;;------------------------------------------------- -save ----
(message "Set my redefine desktop-save...")

;; *** Why do I redefine desktop-save?
;; Because, the normal desktop-save doesn't make backup copies!

(defun desktop-save (dirname)
  "Save the Desktop file.  Parameter DIRNAME specifies where to save desktop."
  (interactive "DDirectory to save desktop file in: ")
  (run-hooks 'desktop-save-hook)
    (let* ((filename (expand-file-name
                     (concat dirname desktop-basefilename)))
          (info (nreverse
                  (function (lambda (b)
                              (set-buffer b)
                               (list    ; list explaining minor modes
                                (not (null auto-fill-function)))
                               (list (mark t) mark-active)
                               (cond ((eq major-mode 'Info-mode)
                                      (list Info-current-file
                                     ((eq major-mode 'dired-mode)
                                       (expand-file-name dired-directory)
                                          (function car)
                               (let ((locals desktop-locals-to-save)
                                     (loclist (buffer-local-variables))
                                 (while locals
                                   (let ((here (assq (car locals) loclist)))
                                     (if here
                                         (setq ll (cons here ll))
                                       (if (member (car locals) loclist)
                                           (setq ll (cons (car locals) ll)))))
                                   (setq locals (cdr locals)))
          ;(buf (get-buffer-create "*desktop*")) ;cs 020701
          (buf (find-file-noselect filename)))
      (set-buffer buf)

      (insert desktop-header
              ";; Created " (current-time-string) "\n"
              ";; Emacs version " emacs-version "\n\n"
              ";; Global section:\n")
      (mapcar (function desktop-outvar) desktop-globals-to-save)
      (if (memq 'kill-ring desktop-globals-to-save)
          (insert "(setq kill-ring-yank-pointer (nthcdr "
                   (- (length kill-ring) (length kill-ring-yank-pointer)))
                  " kill-ring))\n"))

      (insert "\n;; Buffer section:\n")
       (function (lambda (l)
                   (if (apply 'desktop-save-buffer-p l)
                         (insert desktop-create-buffer-form)
                          (function (lambda (e)
                                      (insert "\n  "
                                              (desktop-value-to-string e))))
                         (insert ")\n\n")))))
      (setq default-directory dirname)
;       (if (file-exists-p filename) (delete-file filename))
;       (write-region (point-min) (point-max) filename nil 'nomessage)
      (save-buffer) ;cs 020701
      (kill-buffer buf) ;ensure a backup is made every time, if desired. ;cs 
  (setq desktop-dirname dirname))

Thomas L Roche wrote:
> Has anyone got a way to make 'desktop' back up its most-recently-used
> file? Why I ask:
> I recently whacked my desktop file when emacs (GNU Emacs 21.1.1
> i386-msvc-nt5.0.2195) of 2001-10-22 on buffy) abended. Fortunately, at
> my main workstation, all my emacs stuff gets backed up nightly, so I
> just restored. Unfortunately I don't have such luxury everywhere I
> run. So I'd like to make desktop back up its MRU file, e.g. to
> desktop~ in the "normal emacsian manner."
> I notice that *Customize Group: Desktop* has a Desktop Save Hook:
> anyone got code for that? Or an advice?
> Apologies if this is a FAQ, but I didn't see anything in the info.
> _______________________________________________
> Help-gnu-emacs mailing list
> address@hidden

What is life without looking for           . . `; -._      )-;-,_`)
the next cute little bug to play with?     v_,-    _  ),(,.\  ``-' 
                                          _.- _.,-_/ /  ((.'    
-- address@hidden  `<}:..  ((,.-'   ((,/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]