unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* desktop~ ?
@ 2002-09-17 17:06 Thomas L Roche
  2002-09-17 17:36 ` Chuck Siska
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas L Roche @ 2002-09-17 17:06 UTC (permalink / raw)


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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: desktop~ ?
  2002-09-17 17:06 desktop~ ? Thomas L Roche
@ 2002-09-17 17:36 ` Chuck Siska
  0 siblings, 0 replies; 2+ messages in thread
From: Chuck Siska @ 2002-09-17 17:36 UTC (permalink / raw)


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)
  (save-excursion
    (let* ((filename (expand-file-name
		     (concat dirname desktop-basefilename)))
	  (info (nreverse
		 (mapcar
		  (function (lambda (b)
			      (set-buffer b)
			      (list
			       (buffer-file-name)
			       (buffer-name)
			       major-mode
			       (list	; list explaining minor modes
				(not (null auto-fill-function)))
			       (point)
			       (list (mark t) mark-active)
			       buffer-read-only
			       (cond ((eq major-mode 'Info-mode)
				      (list Info-current-file
					    Info-current-node))
				     ((eq major-mode 'dired-mode)
				      (cons
				       (expand-file-name dired-directory)
				       (cdr
					(nreverse
					 (mapcar
					  (function car)
					  dired-subdir-alist))))))
			       (let ((locals desktop-locals-to-save)
				     (loclist (buffer-local-variables))
				     (ll))
				 (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)))
				 ll)
			       )))
		  (buffer-list))))
	  ;(buf (get-buffer-create "*desktop*")) ;cs 020701
          (buf (find-file-noselect filename)))
      (set-buffer buf)
      (erase-buffer)

      (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 "
		  (int-to-string
		   (- (length kill-ring) (length kill-ring-yank-pointer)))
		  " kill-ring))\n"))

      (insert "\n;; Buffer section:\n")
      (mapcar
       (function (lambda (l)
		   (if (apply 'desktop-save-buffer-p l)
		       (progn
			 (insert desktop-create-buffer-form)
			 (mapcar
			  (function (lambda (e)
				      (insert "\n  "
					      (desktop-value-to-string e))))
			  l)
			 (insert ")\n\n")))))
       info)
      (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 020701
      ))
  (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
> Help-gnu-emacs@gnu.org
> http://mail.gnu.org/mailman/listinfo/help-gnu-emacs

-- 
                                           |\_/\_.-'""``:-._       
What is life without looking for           . . `; -._      )-;-,_`)
the next cute little bug to play with?     v_,-    _  ),(,.\  ``-' 
                                          _.- _.,-_/ /  ((.'    
-- chuck.siska@skyworksinc.com  `<}:..  ((,.-'   ((,/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-09-17 17:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-09-17 17:06 desktop~ ? Thomas L Roche
2002-09-17 17:36 ` Chuck Siska

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).