annotate lisp/desktop.el @ 15013:aad88afa6a0c libc-960413 libc-960414 libc-960415 libc-960416 libc-960417 libc-960418 libc-960419 libc-960420 libc-960421 libc-960422 libc-960423 libc-960424 libc-960425 libc-960426 libc-960427 libc-960428 libc-960429 libc-960430 libc-960501 libc-960502 libc-960503 libc-960504 libc-960505 libc-960506 libc-960507 libc-960508 libc-960509 libc-960510 libc-960511 libc-960512 libc-960513 libc-960514 libc-960515 libc-960516 libc-960517 libc-960518 libc-960519 libc-960520

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