From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Chuck Siska Newsgroups: gmane.emacs.help Subject: Re: desktop~ ? Date: Tue, 17 Sep 2002 10:36:01 -0700 Organization: Skyworks Solutions, Inc. Sender: help-gnu-emacs-admin@gnu.org Message-ID: <3D876801.D79374F8@skyworksinc.com> References: NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: main.gmane.org 1032284259 12904 127.0.0.1 (17 Sep 2002 17:37:39 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Tue, 17 Sep 2002 17:37:39 +0000 (UTC) Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 17rMI4-0003Lo-00 for ; Tue, 17 Sep 2002 19:37:36 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 17rMIC-0005lq-00; Tue, 17 Sep 2002 13:37:44 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10) id 17rMHM-0005MB-00 for help-gnu-emacs@gnu.org; Tue, 17 Sep 2002 13:36:52 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10) id 17rMHJ-0005Lx-00 for help-gnu-emacs@gnu.org; Tue, 17 Sep 2002 13:36:51 -0400 Original-Received: from cnxtsmtp2.conexant.com ([198.62.9.253]) by monty-python.gnu.org with esmtp (Exim 4.10) id 17rMHJ-0005Lh-00 for help-gnu-emacs@gnu.org; Tue, 17 Sep 2002 13:36:49 -0400 Original-Received: from npbsmtp1.conexant.com (npbsmtp1.nb.conexant.com [157.152.161.153]) by cnxtsmtp2.conexant.com (8.9.3/8.9.3) with ESMTP id KAA28230; Tue, 17 Sep 2002 10:36:00 -0700 (PDT) Original-Received: from krone.nb-engr.skyworksinc.com ([10.16.7.10]) by npbsmtp1.conexant.com (Lotus Domino Release 5.0.10) with ESMTP id 2002091710354936:77710 ; Tue, 17 Sep 2002 10:35:49 -0700 Original-Received: from skyworksinc.com (SISKA-5642B.nb.conexant.com [172.19.41.56]) by krone.nb-engr.skyworksinc.com (8.12.5/8.12.5) with ESMTP id g8HHZxxX020740; Tue, 17 Sep 2002 10:35:59 -0700 (PDT) X-Mailer: Mozilla 4.73 [en] (Windows NT 5.0; U) X-Accept-Language: en Original-To: Help Gnu Emacs X-MIMETrack: Itemize by SMTP Server on NPBSMTP1/Server/Conexant(Release 5.0.10 |March 22, 2002) at 09/17/2002 10:35:49 AM, Serialize by Router on NPBSMTP1/Server/Conexant(Release 5.0.10 |March 22, 2002) at 09/17/2002 10:35:49 AM, Serialize complete at 09/17/2002 10:35:49 AM Errors-To: help-gnu-emacs-admin@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.help:1548 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:1548 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 `<}:.. ((,.-' ((,/