annotate lisp/packages/desktop.el @ 147:e186c2b7192d xemacs-20-2

Added tag r20-2p1 for changeset 2af401a6ecca
author cvs
date Mon, 13 Aug 2007 09:34:48 +0200
parents 34a5b81f86ba
children 41ff10fd062f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; desktop.el --- save partial status of Emacs when killed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Author: Morten Welinder <terra@diku.dk>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Version: 2.09? RMS has an obnoxious tendency to remove version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; numbers from packages, and he did in this case.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; Keywords: customization
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; Favourite-brand-of-beer: None, I hate beer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;; along with XEmacs; see the file COPYING. If not, write to the Free
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
25 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
26 ;; 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
28 ;;; Synched up with: FSF 19.34.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;; Save the Desktop, i.e.,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;; - some global variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;; - the list of buffers with associated files. For each buffer also
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;; - the major mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;; - the default directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;; - the point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;; - the mark & mark-active
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;; - buffer-read-only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;; - some local variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;; To use this, first put these three lines in the bottom of your .emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;; file (the later the better):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;; (load "desktop")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;; (desktop-load-default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;; (desktop-read)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ;; Between the second and the third line you may wish to add something that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;; updates the variables `desktop-globals-to-save' and/or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;; `desktop-locals-to-save'. If for instance you want to save the local
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 ;; variable `foobar' for every buffer in which it is local, you could add
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;; the line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;; (setq desktop-locals-to-save (cons 'foobar desktop-locals-to-save))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;; To avoid saving excessive amounts of data you may also wish to add
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ;; something like the following
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;; (add-hook 'kill-emacs-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;; '(lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ;; (desktop-truncate search-ring 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;; (desktop-truncate regexp-search-ring 3)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;; which will make sure that no more than three search items are saved. You
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ;; must place this line *after* the (load "desktop") line. See also the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 ;; variable desktop-save-hook.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ;; Start Emacs in the root directory of your "project". The desktop saver
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ;; is inactive by default. You activate it by M-x desktop-save RET. When
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 ;; you exit the next time the above data will be saved. This ensures that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 ;; all the files you were editing will be reloaded the next time you start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ;; Emacs from the same directory and that points will be set where you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ;; left them. If you save a desktop file in your home directory it will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ;; act as a default desktop when you start Emacs from a directory that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 ;; doesn't have its own. I never do this, but you may want to.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 ;; By the way: don't use desktop.el to customize Emacs -- the file .emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 ;; in your home directory is used for that. Saving global default values
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 ;; for buffers is an example of misuse.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ;; PLEASE NOTE: The kill ring can be saved as specified by the variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 ;; `desktop-globals-to-save' (by default it isn't). This may result in saving
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 ;; things you did not mean to keep. Use M-x desktop-clear RET.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 ;; Thanks to hetrick@phys.uva.nl (Jim Hetrick) for useful ideas.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ;; avk@rtsg.mot.com (Andrew V. Klein) for a dired tip.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 ;; chris@tecc.co.uk (Chris Boucher) for a mark tip.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 ;; f89-kam@nada.kth.se (Klas Mellbourn) for a mh-e tip.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 ;; kifer@sbkifer.cs.sunysb.edu (M. Kifer) for a bug hunt.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 ;; treese@lcs.mit.edu (Win Treese) for ange-ftp tips.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
92 ;; pot@cnuce.cnr.it (Francesco Potorti`) for misc. tips.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 ;; ---------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ;; TODO:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 ;; Save window configuration.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ;; Recognize more minor modes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 ;; Save mark rings.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 ;; Start-up with buffer-menu???
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 ;; Make the compilation more silent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (eval-when-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 ;; We use functions from these modules
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 ;; We can't (require 'mh-e) since that wants to load something.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (mapcar 'require '(info dired reporter)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 ;; ----------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 ;; USER OPTIONS -- settings you might want to play with.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 ;; ----------------------------------------------------------------------------
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 2
diff changeset
111
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 2
diff changeset
112 (defgroup desktop nil
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 2
diff changeset
113 "Save partial status of Emacs when killed"
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 2
diff changeset
114 :group 'frames)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 2
diff changeset
115
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (defconst desktop-basefilename
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (if (or (eq system-type 'ms-dos) (eq system-type 'windows-nt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 "emacs.dsk" ; Ms-Dos does not support multiple dots in file name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 ".emacs.desktop")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 "File for Emacs desktop, not including the directory name.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 2
diff changeset
122 (defcustom desktop-missing-file-warning t
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 "*If non-nil then desktop warns when a file no longer exists.
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 2
diff changeset
124 Otherwise it simply ignores that file."
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 2
diff changeset
125 :type 'boolean
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 2
diff changeset
126 :group 'desktop)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 2
diff changeset
128 (defcustom desktop-globals-to-save
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (list 'desktop-missing-file-warning
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 ;; Feature: saving kill-ring implies saving kill-ring-yank-pointer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 ;; 'kill-ring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 'tags-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 'tags-table-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 'search-ring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 'regexp-search-ring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 'register-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 ;; 'desktop-globals-to-save ; Itself!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 "List of global variables to save when killing Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 An element may be variable name (a symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 or a cons cell of the form (VAR . MAX-SIZE),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 which means to truncate VAR's value to at most MAX-SIZE elements
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 2
diff changeset
143 \(if the value is a list) before saving the value."
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 2
diff changeset
144 :type '(repeat (choice (symbol :tag "Variable")
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 2
diff changeset
145 (cons (symbol :tag "Variable")
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 2
diff changeset
146 (integer :tag "Size"))))
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 2
diff changeset
147 :group 'desktop)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 2
diff changeset
149 (defcustom desktop-locals-to-save
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (list 'desktop-locals-to-save ; Itself! Think it over.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 'truncate-lines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 'case-fold-search
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 'case-replace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 'fill-column
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 'overwrite-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 'change-log-default-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 'line-number-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 "List of local variables to save for each buffer.
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 2
diff changeset
160 The variables are saved only when they really are local."
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 2
diff changeset
161 :type '(repeat (choice (symbol :tag "Variable")
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 2
diff changeset
162 (cons (symbol :tag "Variable")
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 2
diff changeset
163 (integer :tag "Size"))))
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 2
diff changeset
164 :group 'desktop)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (make-variable-buffer-local 'desktop-locals-to-save)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 ;; We skip .log files because they are normally temporary.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
168 ;; (ftp) files because they require passwords and whatnot.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 ;; TAGS files to save time (tags-file-name is saved instead).
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 2
diff changeset
170 (defcustom desktop-buffers-not-to-save
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 "\\(^nn\\.a[0-9]+\\|\\.log\\|(ftp)\\|^tags\\|^TAGS\\)$"
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 2
diff changeset
172 "Regexp identifying buffers that are to be excluded from saving."
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 2
diff changeset
173 :type 'regexp
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 2
diff changeset
174 :group 'desktop)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 ;; Skip ange-ftp files
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 2
diff changeset
177 (defcustom desktop-files-not-to-save
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 "^/[^/:]*:"
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 2
diff changeset
179 "Regexp identifying files whose buffers are to be excluded from saving."
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 2
diff changeset
180 :type 'regexp
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 2
diff changeset
181 :group 'desktop)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
183 (defvar desktop-buffer-major-mode nil
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
184 "When desktop creates a buffer, this holds the desired Major mode.")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
185
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
186 (defvar desktop-buffer-file-name nil
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
187 "When desktop creates a buffer, this holds the file name to visit.")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
188
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
189 (defvar desktop-buffer-name nil
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
190 "When desktop creates a buffer, this holds the desired buffer name.")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
191
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
192 (defvar desktop-buffer-misc nil
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
193 "When desktop creates a buffer, this holds a list of misc info.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
194 It is used by the `desktop-buffer-handlers' functions.")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
195
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 2
diff changeset
196 (defcustom desktop-buffer-handlers
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 '(desktop-buffer-dired
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 desktop-buffer-rmail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 desktop-buffer-mh
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 desktop-buffer-info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 desktop-buffer-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 "*List of functions to call in order to create a buffer.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
203 The functions are called without explicit parameters but can use the
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
204 variables `desktop-buffer-major-mode', `desktop-buffer-file-name',
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
205 `desktop-buffer-name'.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
206 If one function returns non-nil, no further functions are called.
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 2
diff changeset
207 If the function returns t then the buffer is considered created."
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 2
diff changeset
208 :type '(repeat function)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 2
diff changeset
209 :group 'desktop)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (defvar desktop-create-buffer-form "(desktop-create-buffer 205"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 "Opening of form for creation of new buffers.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 2
diff changeset
214 (defcustom desktop-save-hook nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 "Hook run before saving the desktop to allow you to cut history lists and
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 2
diff changeset
216 the like shorter."
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 2
diff changeset
217 :type 'hook
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 2
diff changeset
218 :group 'desktop)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 ;; ----------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (defvar desktop-dirname nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 "The directory in which the current desktop file resides.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (defconst desktop-header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 ";; --------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 ;; Desktop File for Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 ;; --------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 " "*Header to place in Desktop file.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (defvar desktop-delay-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 "Hooks run after all buffers are loaded; intended for internal use.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 ;; ----------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (defun desktop-truncate (l n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 "Truncate LIST to at most N elements destructively."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (let ((here (nthcdr (1- n) l)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (if (consp here)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (setcdr here nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 ;; ----------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (defun desktop-clear () "Empty the Desktop."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (setq kill-ring nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 kill-ring-yank-pointer nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 search-ring nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 search-ring-yank-pointer nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 regexp-search-ring nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 regexp-search-ring-yank-pointer nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (mapcar (function (lambda (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 ;; XEmacs change
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (if (not (equal (buffer-name x) "*Warnings*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (kill-buffer x)))) (buffer-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (delete-other-windows))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 ;; ----------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (add-hook 'kill-emacs-hook 'desktop-kill)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (defun desktop-kill ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (if desktop-dirname
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (condition-case err
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (desktop-save desktop-dirname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (file-error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (if (yes-or-no-p "Error while saving the desktop. Quit anyway? ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (signal (car err) (cdr err)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 ;; ----------------------------------------------------------------------------
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
263 (defun desktop-list* (&rest args)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
264 (if (null (cdr args))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
265 (car args)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
266 (setq args (nreverse args))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
267 (let ((value (cons (nth 1 args) (car args))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
268 (setq args (cdr (cdr args)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
269 (while args
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
270 (setq value (cons (car args) value))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
271 (setq args (cdr args)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
272 value)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
273
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (defun desktop-internal-v2s (val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 "Convert VALUE to a pair (QUOTE . TXT); (eval (read TXT)) gives VALUE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 TXT is a string that when read and evaluated yields value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 QUOTE may be `may' (value may be quoted),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 `must' (values must be quoted), or nil (value may not be quoted)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 ((or (numberp val) (null val) (eq t val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (cons 'may (prin1-to-string val)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 ((stringp val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (let ((copy (copy-sequence val)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (set-text-properties 0 (length copy) nil copy)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 ;; Get rid of text properties because we cannot read them
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (cons 'may (prin1-to-string copy))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 ((symbolp val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (cons 'must (prin1-to-string val)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 ((vectorp val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (let* ((special nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (pass1 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (lambda (el)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (let ((res (desktop-internal-v2s el)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (if (null (car res))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (setq special t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 res))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 val)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (if special
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (cons nil (concat "(vector "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (mapconcat (lambda (el)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (if (eq (car el) 'must)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (concat "'" (cdr el))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (cdr el)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 pass1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 ")"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (cons 'may (concat "[" (mapconcat 'cdr pass1 " ") "]")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 ((consp val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (let ((p val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 newlist
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
311 use-list*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 anynil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (while (consp p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (let ((q.txt (desktop-internal-v2s (car p))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (or anynil (setq anynil (null (car q.txt))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (setq newlist (cons q.txt newlist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (setq p (cdr p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (if p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (let ((last (desktop-internal-v2s p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (el (car newlist)))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
321 (or anynil (setq anynil (null (car last))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
322 (or anynil
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
323 (setq newlist (cons '(must . ".") newlist)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
324 (setq use-list* t)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
325 (setq newlist (cons last newlist))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (setq newlist (nreverse newlist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (if anynil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (cons nil
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
329 (concat (if use-list* "(desktop-list* " "(list ")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (mapconcat (lambda (el)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (if (eq (car el) 'must)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (concat "'" (cdr el))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (cdr el)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 newlist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 ")"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (cons 'must
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (concat "(" (mapconcat 'cdr newlist " ") ")")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 ((subrp val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (cons nil (concat "(symbol-function '"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (substring (prin1-to-string val) 7 -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 ")")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 ((markerp val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (let ((pos (prin1-to-string (marker-position val)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (buf (prin1-to-string (buffer-name (marker-buffer val)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (cons nil (concat "(let ((mk (make-marker)))"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 " (add-hook 'desktop-delay-hook"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 " (list 'lambda '() (list 'set-marker mk "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 pos " (get-buffer " buf ")))) mk)"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (t ; save as text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (cons 'may "\"Unprintable entity\""))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (defun desktop-value-to-string (val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 "Convert VALUE to a string that when read evaluates to the same value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 Not all types of values are supported."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (let* ((print-escape-newlines t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (float-output-format nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (quote.txt (desktop-internal-v2s val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (quote (car quote.txt))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (txt (cdr quote.txt)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (if (eq quote 'must)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (concat "'" txt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 txt)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 ;; ----------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (defun desktop-outvar (varspec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 "Output a setq statement for variable VAR to the desktop file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 The argument VARSPEC may be the variable name VAR (a symbol),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 or a cons cell of the form (VAR . MAX-SIZE),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 which means to truncate VAR's value to at most MAX-SIZE elements
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 \(if the value is a list) before saving the value."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (let (var size)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (if (consp varspec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (setq var (car varspec) size (cdr varspec))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (setq var varspec))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (if (boundp var)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (if (and (integerp size)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (> size 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (listp (eval var)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (desktop-truncate (eval var) size))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (insert "(setq "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (symbol-name var)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 " "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (desktop-value-to-string (symbol-value var))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 ")\n")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 ;; ----------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (defun desktop-save-buffer-p (filename bufname mode &rest dummy)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 "Return t if the desktop should record a particular buffer for next startup.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 FILENAME is the visited file name, BUFNAME is the buffer name, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 MODE is the major mode."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (let ((case-fold-search nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (or (and filename
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (not (string-match desktop-buffers-not-to-save bufname))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (not (string-match desktop-files-not-to-save filename)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (and (eq mode 'dired-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (set-buffer (get-buffer bufname))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (not (string-match desktop-files-not-to-save
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 default-directory))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (and (null filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (memq mode '(Info-mode rmail-mode))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 ;; ----------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (defun desktop-save (dirname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 "Save the Desktop file. Parameter DIRNAME specifies where to save desktop."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (interactive "DDirectory to save desktop file in: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (run-hooks 'desktop-save-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (let ((filename (expand-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (concat dirname desktop-basefilename)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (info (nreverse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (function (lambda (b)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (set-buffer b)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (buffer-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 major-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (list ; list explaining minor modes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (not (null auto-fill-function)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (list (mark t) ;; mark-active
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (not (null (mark)))) ; XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 buffer-read-only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (cond ((eq major-mode 'Info-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (list Info-current-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 Info-current-node))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 ((eq major-mode 'dired-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (cons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (expand-file-name dired-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (cdr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (nreverse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (function car)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 dired-subdir-alist))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (let ((locals desktop-locals-to-save)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (loclist (buffer-local-variables))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (ll))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (while locals
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (let ((here (assq (car locals) loclist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (if here
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (setq ll (cons here ll))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (if (member (car locals) loclist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (setq ll (cons (car locals) ll)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (setq locals (cdr locals)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 ll)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 (buffer-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (buf (get-buffer-create "*desktop*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (set-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (insert desktop-header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 ";; Created " (current-time-string) "\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 ";; Emacs version " emacs-version "\n\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 ";; Global section:\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (mapcar (function desktop-outvar) desktop-globals-to-save)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 (if (memq 'kill-ring desktop-globals-to-save)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (insert "(setq kill-ring-yank-pointer (nthcdr "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (int-to-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (- (length kill-ring) (length kill-ring-yank-pointer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 " kill-ring))\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (insert "\n;; Buffer section:\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (function (lambda (l)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (if (apply 'desktop-save-buffer-p l)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (insert desktop-create-buffer-form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (function (lambda (e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (insert "\n "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (desktop-value-to-string e))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 l)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (insert ")\n\n")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 info)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (setq default-directory dirname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (if (file-exists-p filename) (delete-file filename))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (write-region (point-min) (point-max) filename nil 'nomessage)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (setq desktop-dirname dirname))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 ;; ----------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (defun desktop-remove ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 "Delete the Desktop file and inactivate the desktop system."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 (if desktop-dirname
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (let ((filename (concat desktop-dirname desktop-basefilename)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 (setq desktop-dirname nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (if (file-exists-p filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 (delete-file filename)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 ;; ----------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 (defun desktop-read ()
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
491 "Read the Desktop file and the files it specifies.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
492 This is a no-op when Emacs is running in batch mode."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 (interactive)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
494 (if noninteractive
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
495 nil
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
496 (let ((dirs '("./" "~/")))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
497 (while (and dirs
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
498 (not (file-exists-p (expand-file-name
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
499 desktop-basefilename
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
500 (car dirs)))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
501 (setq dirs (cdr dirs)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
502 (setq desktop-dirname (and dirs (expand-file-name (car dirs))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
503 (if desktop-dirname
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
504 (progn
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
505 (load (expand-file-name desktop-basefilename desktop-dirname)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
506 t t t)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
507 (run-hooks 'desktop-delay-hook)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
508 (setq desktop-delay-hook nil)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
509 (message "Desktop loaded."))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
510 (desktop-clear)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 ;; ----------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 (defun desktop-load-default ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 "Load the `default' start-up library manually.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 Also inhibit further loading of it. Call this from your `.emacs' file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 to provide correct modes for autoloaded files."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 (if (not inhibit-default-init) ; safety check
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 (load "default" t t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 (setq inhibit-default-init t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 ;; ----------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 ;; Note: the following functions use the dynamic variable binding in Lisp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (defun desktop-buffer-info () "Load an info file."
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
524 (if (eq 'Info-mode desktop-buffer-major-mode)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 (require 'info)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
527 (Info-find-node (nth 0 desktop-buffer-misc)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
528 (nth 1 desktop-buffer-misc))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 ;; ----------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 (defun desktop-buffer-rmail () "Load an RMAIL file."
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
532 (if (eq 'rmail-mode desktop-buffer-major-mode)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 (condition-case error
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
534 (progn (rmail-input desktop-buffer-file-name) t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 (file-locked
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 (kill-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 'ignored))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 ;; ----------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 (defun desktop-buffer-mh () "Load a folder in the mh system."
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
540 (if (eq 'mh-folder-mode desktop-buffer-major-mode)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 (require 'mh-e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 (mh-find-path)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
544 (mh-visit-folder desktop-buffer-name)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 ;; ----------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 (defun desktop-buffer-dired () "Load a directory using dired."
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
548 (if (eq 'dired-mode desktop-buffer-major-mode)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
549 (if (file-directory-p (file-name-directory (car desktop-buffer-misc)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 (progn
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
551 (dired (car desktop-buffer-misc))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
552 (mapcar 'dired-insert-subdir (cdr desktop-buffer-misc))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 t)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
554 (message "Directory %s no longer exists." (car desktop-buffer-misc))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 (sit-for 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 'ignored)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 ;; ----------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 (defun desktop-buffer-file () "Load a file."
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
559 (if desktop-buffer-file-name
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
560 (if (or (file-exists-p desktop-buffer-file-name)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (and desktop-missing-file-warning
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (y-or-n-p (format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 "File \"%s\" no longer exists. Re-create? "
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
564 desktop-buffer-file-name))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
565 (progn (find-file desktop-buffer-file-name) t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 'ignored)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 ;; ----------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 ;; Create a buffer, load its file, set is mode, ...; called from Desktop file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 ;; only.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
570 (defun desktop-create-buffer (ver desktop-buffer-file-name desktop-buffer-name
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
571 desktop-buffer-major-mode
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
572 mim pt mk ro desktop-buffer-misc
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
573 &optional locals)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 (let ((hlist desktop-buffer-handlers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 (result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 (handler))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (while (and (not result) hlist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 (setq handler (car hlist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (setq result (funcall handler))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 (setq hlist (cdr hlist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (if (eq result t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 (progn
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
583 (if (not (equal (buffer-name) desktop-buffer-name))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
584 (rename-buffer desktop-buffer-name))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 (auto-fill-mode (if (nth 0 mim) 1 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 (goto-char pt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 (if (consp mk)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 (set-mark (car mk))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 ;; (setq mark-active (car (cdr mk))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 (if (car (cdr mk)) (zmacs-activate-region))) ; XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 (set-mark mk))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 ;; Never override file system if the file really is read-only marked.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (if ro (setq buffer-read-only ro))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 (while locals
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 (let ((this (car locals)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 (if (consp this)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 ;; an entry of this form `(symbol . value)'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 (make-local-variable (car this))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 (set (car this) (cdr this)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 ;; an entry of the form `symbol'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 (make-local-variable this)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 (makunbound this)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 (setq locals (cdr locals)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 ;; Backward compatibility -- update parameters to 205 standards.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
609 (defun desktop-buffer (desktop-buffer-file-name desktop-buffer-name
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
610 desktop-buffer-major-mode
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
611 mim pt mk ro tl fc cfs cr
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
612 desktop-buffer-misc)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
613 (desktop-create-buffer 205 desktop-buffer-file-name desktop-buffer-name
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
614 desktop-buffer-major-mode (cdr mim) pt mk ro
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
615 desktop-buffer-misc
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 (list (cons 'truncate-lines tl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 (cons 'fill-column fc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 (cons 'case-fold-search cfs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 (cons 'case-replace cr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 (cons 'overwrite-mode (car mim)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 ;; ----------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 (provide 'desktop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 ;; desktop.el ends here.