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