annotate lisp/desktop.el @ 48749:94d8efd47824

Now correctly creates a self-contained application
author Steven Tamm <steventamm@mac.com>
date Sun, 08 Dec 2002 18:29:36 +0000
parents 8c7919f99581
children 110c0e29159c d7ddb3e565de
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
38592
27468a9cf559 (desktop-save): Add `-*- coding: emacs-mule -*-' to
Gerd Moellmann <gerd@gnu.org>
parents: 32447
diff changeset
3 ;; Copyright (C) 1993, 1994, 1995, 1997, 2000, 2001
27468a9cf559 (desktop-save): Add `-*- coding: emacs-mule -*-' to
Gerd Moellmann <gerd@gnu.org>
parents: 32447
diff changeset
4 ;; Free Software Foundation, Inc.
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 ;; Author: Morten Welinder <terra@diku.dk>
27577
beed019fbf10 Fix keywords comment.
Dave Love <fx@gnu.org>
parents: 23699
diff changeset
7 ;; Keywords: convenience
5314
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
8 ;; Favourite-brand-of-beer: None, I hate beer.
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10 ;; This file is part of GNU Emacs.
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; 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
14 ;; the Free Software Foundation; either version 2, or (at your option)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; any later version.
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; GNU General Public License for more details.
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;; 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
23 ;; 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
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
25 ;; Boston, MA 02111-1307, USA.
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 ;;; Commentary:
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
29 ;; Save the Desktop, i.e.,
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
30 ;; - some global variables
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
31 ;; - 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
32 ;; - the major mode
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
33 ;; - the default directory
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
34 ;; - the point
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
35 ;; - the mark & mark-active
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
36 ;; - buffer-read-only
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
37 ;; - some local variables
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38
21303
346595905ae4 (desktop-load-default): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 20772
diff changeset
39 ;; To use this, first put these two lines in the bottom of your .emacs
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
40 ;; file (the later the better):
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
41 ;;
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 ;;
28719
f56c181fb849 (desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents: 27577
diff changeset
45 ;; Between these two lines you may wish to add something that updates the
f56c181fb849 (desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents: 27577
diff changeset
46 ;; variables `desktop-globals-to-save' and/or `desktop-locals-to-save'. If
f56c181fb849 (desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents: 27577
diff changeset
47 ;; for instance you want to save the local variable `foobar' for every buffer
f56c181fb849 (desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents: 27577
diff changeset
48 ;; in which it is local, you could add the line
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
49 ;;
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
50 ;; (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
51 ;;
11224
f7f101a90cd4 (desktop-save): Use dired-directory as name
Richard M. Stallman <rms@gnu.org>
parents: 10777
diff changeset
52 ;; 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
53 ;; something like the following
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
54 ;;
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
55 ;; (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
56 ;; '(lambda ()
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
57 ;; (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
58 ;; (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
59 ;;
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
60 ;; which will make sure that no more than three search items are saved. You
28719
f56c181fb849 (desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents: 27577
diff changeset
61 ;; must place this line *after* the `(desktop-load-default)' line. See also
f56c181fb849 (desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents: 27577
diff changeset
62 ;; the variable `desktop-save-hook'.
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
64 ;; 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
65 ;; 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
66 ;; 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
67 ;; 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
68 ;; 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
69 ;; 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
70 ;; 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
71 ;; 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
72
28719
f56c181fb849 (desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents: 27577
diff changeset
73 ;; Some words on minor modes: Most minor modes are controlled by
f56c181fb849 (desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents: 27577
diff changeset
74 ;; buffer-local variables, which have a standard save / restore
f56c181fb849 (desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents: 27577
diff changeset
75 ;; mechanism. To handle all minor modes, we take the following
f56c181fb849 (desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents: 27577
diff changeset
76 ;; approach: (1) check whether the variable name from
f56c181fb849 (desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents: 27577
diff changeset
77 ;; `minor-mode-alist' is also a function; and (2) use translation
f56c181fb849 (desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents: 27577
diff changeset
78 ;; table `desktop-minor-mode-table' in the case where the two names
f56c181fb849 (desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents: 27577
diff changeset
79 ;; are not the same.
f56c181fb849 (desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents: 27577
diff changeset
80
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
81 ;; 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
82 ;; 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
83 ;; 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
84
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
85 ;; 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
86 ;; `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
87 ;; 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
88
7240
195e64dad1eb (desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents: 7200
diff changeset
89 ;; 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
90 ;; 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
91 ;; 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
92 ;; 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
93 ;; 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
94 ;; 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
95 ;; 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
96 ;; ---------------------------------------------------------------------------
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
97 ;; TODO:
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
98 ;;
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
99 ;; Save window configuration.
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
100 ;; Recognize more minor modes.
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
101 ;; Save mark rings.
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
102 ;; Start-up with buffer-menu???
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 ;;; Code:
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
106 ;; 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
107 (eval-when-compile
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
108 ;; 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
109 ;; 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
110 (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
111 ;; ----------------------------------------------------------------------------
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
112 ;; 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
113 ;; ----------------------------------------------------------------------------
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17204
diff changeset
114
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17204
diff changeset
115 (defgroup desktop nil
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17204
diff changeset
116 "Save status of Emacs when you exit."
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17204
diff changeset
117 :group 'frames)
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17204
diff changeset
118
20526
ec0a8ccddd6c (desktop-enable): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 18581
diff changeset
119 (defcustom desktop-enable nil
ec0a8ccddd6c (desktop-enable): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 18581
diff changeset
120 "*Non-nil enable Desktop to save the state of Emacs when you exit."
ec0a8ccddd6c (desktop-enable): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 18581
diff changeset
121 :group 'desktop
ec0a8ccddd6c (desktop-enable): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 18581
diff changeset
122 :type 'boolean
ec0a8ccddd6c (desktop-enable): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 18581
diff changeset
123 :require 'desktop
21669
9861518505cb *** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents: 21316
diff changeset
124 :initialize 'custom-initialize-default
9861518505cb *** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents: 21316
diff changeset
125 :version "20.3")
20526
ec0a8ccddd6c (desktop-enable): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 18581
diff changeset
126
ec0a8ccddd6c (desktop-enable): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 18581
diff changeset
127 (defcustom desktop-basefilename
16037
a1e88c05b53c (desktop-basefilename): Use convert-standard-filename.
Richard M. Stallman <rms@gnu.org>
parents: 14756
diff changeset
128 (convert-standard-filename ".emacs.desktop")
20526
ec0a8ccddd6c (desktop-enable): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 18581
diff changeset
129 "File for Emacs desktop, not including the directory name."
ec0a8ccddd6c (desktop-enable): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 18581
diff changeset
130 :type 'file
ec0a8ccddd6c (desktop-enable): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 18581
diff changeset
131 :group 'desktop)
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17204
diff changeset
133 (defcustom desktop-missing-file-warning nil
10595
06fa5b312280 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 9776
diff changeset
134 "*If non-nil then desktop warns when a file no longer exists.
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17204
diff changeset
135 Otherwise it simply ignores that file."
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17204
diff changeset
136 :type 'boolean
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17204
diff changeset
137 :group 'desktop)
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
139 (defvar desktop-globals-to-save
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 (list 'desktop-missing-file-warning
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
141 ;; 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
142 ;; 'kill-ring
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
143 'tags-file-name
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
144 'tags-table-list
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
145 'search-ring
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
146 'regexp-search-ring
5788
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
147 'register-alist
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
148 ;; 'desktop-globals-to-save ; Itself!
5314
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
149 )
13154
f86e18ff3736 (desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents: 11224
diff changeset
150 "List of global variables to save when killing Emacs.
f86e18ff3736 (desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents: 11224
diff changeset
151 An element may be variable name (a symbol)
f86e18ff3736 (desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents: 11224
diff changeset
152 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
153 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
154 \(if the value is a list) before saving the value.")
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
156 (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
157 (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
158 'truncate-lines
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
159 'case-fold-search
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
160 'case-replace
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
161 'fill-column
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
162 'overwrite-mode
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
163 '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
164 'line-number-mode
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
165 )
10595
06fa5b312280 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 9776
diff changeset
166 "List of local variables to save for each buffer.
06fa5b312280 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 9776
diff changeset
167 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
168 (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
169
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
170 ;; We skip .log files because they are normally temporary.
14040
187735b53d52 Comment fixes.
Karl Heuer <kwzh@gnu.org>
parents: 13154
diff changeset
171 ;; (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
172 ;; TAGS files to save time (tags-file-name is saved instead).
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17204
diff changeset
173 (defcustom 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
174 "\\(^nn\\.a[0-9]+\\|\\.log\\|(ftp)\\|^tags\\|^TAGS\\)$"
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17204
diff changeset
175 "Regexp identifying buffers that are to be excluded from saving."
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17204
diff changeset
176 :type 'regexp
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17204
diff changeset
177 :group 'desktop)
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178
7240
195e64dad1eb (desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents: 7200
diff changeset
179 ;; Skip ange-ftp files
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17204
diff changeset
180 (defcustom desktop-files-not-to-save
7240
195e64dad1eb (desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents: 7200
diff changeset
181 "^/[^/:]*:"
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17204
diff changeset
182 "Regexp identifying files whose buffers are to be excluded from saving."
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17204
diff changeset
183 :type 'regexp
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17204
diff changeset
184 :group 'desktop)
7240
195e64dad1eb (desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents: 7200
diff changeset
185
32447
cfae1c82d702 Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents: 32366
diff changeset
186 (defcustom desktop-buffer-modes-to-save
cfae1c82d702 Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents: 32366
diff changeset
187 '(Info-mode rmail-mode)
cfae1c82d702 Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents: 32366
diff changeset
188 "If a buffer is of one of these major modes, save the buffer name.
cfae1c82d702 Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents: 32366
diff changeset
189 It is up to the functions in `desktop-buffer-handlers' to decide
cfae1c82d702 Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents: 32366
diff changeset
190 whether the buffer should be recreated or not, and how."
cfae1c82d702 Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents: 32366
diff changeset
191 :type '(repeat symbol)
cfae1c82d702 Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents: 32366
diff changeset
192 :group 'desktop)
cfae1c82d702 Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents: 32366
diff changeset
193
32366
40d8b29df57e (desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30853
diff changeset
194 (defcustom desktop-modes-not-to-save nil
40d8b29df57e (desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30853
diff changeset
195 "List of major modes whose buffers should not be saved."
40d8b29df57e (desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30853
diff changeset
196 :type '(repeat symbol)
40d8b29df57e (desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30853
diff changeset
197 :group 'desktop)
40d8b29df57e (desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30853
diff changeset
198
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17204
diff changeset
199 (defcustom desktop-buffer-major-mode nil
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17204
diff changeset
200 "When desktop creates a buffer, this holds the desired Major mode."
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17204
diff changeset
201 :type 'symbol
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17204
diff changeset
202 :group 'desktop)
14755
3d473ed8c718 Global vars mam, fn, bn renamed.
Richard M. Stallman <rms@gnu.org>
parents: 14754
diff changeset
203
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17204
diff changeset
204 (defcustom desktop-buffer-file-name nil
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17204
diff changeset
205 "When desktop creates a buffer, this holds the file name to visit."
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17204
diff changeset
206 :type '(choice file (const nil))
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17204
diff changeset
207 :group 'desktop)
14755
3d473ed8c718 Global vars mam, fn, bn renamed.
Richard M. Stallman <rms@gnu.org>
parents: 14754
diff changeset
208
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17204
diff changeset
209 (defcustom desktop-buffer-name nil
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17204
diff changeset
210 "When desktop creates a buffer, this holds the desired buffer name."
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17204
diff changeset
211 :type '(choice string (const nil))
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17204
diff changeset
212 :group 'desktop)
14755
3d473ed8c718 Global vars mam, fn, bn renamed.
Richard M. Stallman <rms@gnu.org>
parents: 14754
diff changeset
213
14756
aabf776c3b6a Global var `misc' renamed.
Richard M. Stallman <rms@gnu.org>
parents: 14755
diff changeset
214 (defvar desktop-buffer-misc nil
aabf776c3b6a Global var `misc' renamed.
Richard M. Stallman <rms@gnu.org>
parents: 14755
diff changeset
215 "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
216 It is used by the `desktop-buffer-handlers' functions.")
aabf776c3b6a Global var `misc' renamed.
Richard M. Stallman <rms@gnu.org>
parents: 14755
diff changeset
217
32447
cfae1c82d702 Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents: 32366
diff changeset
218 (defcustom desktop-buffer-misc-functions
cfae1c82d702 Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents: 32366
diff changeset
219 '(desktop-buffer-info-misc-data
cfae1c82d702 Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents: 32366
diff changeset
220 desktop-buffer-dired-misc-data)
cfae1c82d702 Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents: 32366
diff changeset
221 "*Functions used to determine auxiliary information for a buffer.
cfae1c82d702 Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents: 32366
diff changeset
222 These functions are called in order, with no arguments. If a function
cfae1c82d702 Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents: 32366
diff changeset
223 returns non-nil, its value is saved along with the desktop buffer for
cfae1c82d702 Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents: 32366
diff changeset
224 which it was called; no further functions will be called.
cfae1c82d702 Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents: 32366
diff changeset
225
cfae1c82d702 Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents: 32366
diff changeset
226 Later, when desktop.el restores the buffers it has saved, each of the
cfae1c82d702 Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents: 32366
diff changeset
227 `desktop-buffer-handlers' functions will have access to a buffer local
cfae1c82d702 Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents: 32366
diff changeset
228 variable, named `desktop-buffer-misc', whose value is what the
cfae1c82d702 Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents: 32366
diff changeset
229 \"misc\" function returned previously."
cfae1c82d702 Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents: 32366
diff changeset
230 :type '(repeat function)
cfae1c82d702 Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents: 32366
diff changeset
231 :group 'desktop)
cfae1c82d702 Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents: 32366
diff changeset
232
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17204
diff changeset
233 (defcustom desktop-buffer-handlers
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
234 '(desktop-buffer-dired
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
235 desktop-buffer-rmail
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
236 desktop-buffer-mh
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
237 desktop-buffer-info
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
238 desktop-buffer-file)
10595
06fa5b312280 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 9776
diff changeset
239 "*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
240 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
241 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
242 `desktop-buffer-name'.
3d473ed8c718 Global vars mam, fn, bn renamed.
Richard M. Stallman <rms@gnu.org>
parents: 14754
diff changeset
243 If one function returns non-nil, no further functions are called.
43831
7837693f5bac (desktop-buffer-handlers): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 41150
diff changeset
244 If the function returns a buffer, then the saved mode settings
7837693f5bac (desktop-buffer-handlers): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 41150
diff changeset
245 and variable values for that buffer are copied into it."
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17204
diff changeset
246 :type '(repeat function)
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17204
diff changeset
247 :group 'desktop)
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
248
32447
cfae1c82d702 Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents: 32366
diff changeset
249 (put 'desktop-buffer-handlers 'risky-local-variable t)
cfae1c82d702 Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents: 32366
diff changeset
250
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
251 (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
252 "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
253
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17204
diff changeset
254 (defcustom desktop-save-hook nil
20526
ec0a8ccddd6c (desktop-enable): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 18581
diff changeset
255 "Hook run before desktop saves the state of Emacs.
ec0a8ccddd6c (desktop-enable): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 18581
diff changeset
256 This is useful for truncating history lists, for example."
17411
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17204
diff changeset
257 :type 'hook
f0ff96a35eb8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17204
diff changeset
258 :group 'desktop)
20526
ec0a8ccddd6c (desktop-enable): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 18581
diff changeset
259
28719
f56c181fb849 (desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents: 27577
diff changeset
260 (defcustom desktop-minor-mode-table
f56c181fb849 (desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents: 27577
diff changeset
261 '((auto-fill-function auto-fill-mode)
f56c181fb849 (desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents: 27577
diff changeset
262 (vc-mode nil))
f56c181fb849 (desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents: 27577
diff changeset
263 "Table mapping minor mode variables to minor mode functions.
f56c181fb849 (desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents: 27577
diff changeset
264 Each entry has the form (NAME RESTORE-FUNCTION).
f56c181fb849 (desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents: 27577
diff changeset
265 NAME is the name of the buffer-local variable indicating that the minor
f56c181fb849 (desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents: 27577
diff changeset
266 mode is active. RESTORE-FUNCTION is the function to activate the minor mode.
f56c181fb849 (desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents: 27577
diff changeset
267 called. RESTORE-FUNCTION nil means don't try to restore the minor mode.
f56c181fb849 (desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents: 27577
diff changeset
268 Only minor modes for which the name of the buffer-local variable
f56c181fb849 (desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents: 27577
diff changeset
269 and the name of the minor mode function are different have to added to
f56c181fb849 (desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents: 27577
diff changeset
270 this table."
f56c181fb849 (desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents: 27577
diff changeset
271 :type 'sexp
f56c181fb849 (desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents: 27577
diff changeset
272 :group 'desktop)
f56c181fb849 (desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents: 27577
diff changeset
273
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
274 ;; ----------------------------------------------------------------------------
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
275 (defvar desktop-dirname nil
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
276 "The directory in which the current desktop file resides.")
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
277
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
278 (defconst desktop-header
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
279 ";; --------------------------------------------------------------------------
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
280 ;; Desktop File for Emacs
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
281 ;; --------------------------------------------------------------------------
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
282 " "*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
283
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
284 (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
285 "Hooks run after all buffers are loaded; intended for internal use.")
20526
ec0a8ccddd6c (desktop-enable): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 18581
diff changeset
286
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
287 ;; ----------------------------------------------------------------------------
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
288 (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
289 "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
290 (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
291 (if (consp here)
5788
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
292 (setcdr here nil))))
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
293 ;; ----------------------------------------------------------------------------
18581
45f27efe77c7 (desktop-clear-preserve-buffers): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 18527
diff changeset
294 (defcustom desktop-clear-preserve-buffers
45f27efe77c7 (desktop-clear-preserve-buffers): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 18527
diff changeset
295 '("*scratch*" "*Messages*")
45f27efe77c7 (desktop-clear-preserve-buffers): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 18527
diff changeset
296 "*Buffer names that `desktop-clear' should not delete."
45f27efe77c7 (desktop-clear-preserve-buffers): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 18527
diff changeset
297 :type '(repeat string)
45f27efe77c7 (desktop-clear-preserve-buffers): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 18527
diff changeset
298 :group 'desktop)
45f27efe77c7 (desktop-clear-preserve-buffers): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 18527
diff changeset
299
45f27efe77c7 (desktop-clear-preserve-buffers): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 18527
diff changeset
300 (defun desktop-clear ()
45f27efe77c7 (desktop-clear-preserve-buffers): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 18527
diff changeset
301 "Empty the Desktop.
45f27efe77c7 (desktop-clear-preserve-buffers): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 18527
diff changeset
302 This kills all buffers except for internal ones
45f27efe77c7 (desktop-clear-preserve-buffers): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 18527
diff changeset
303 and those listed in `desktop-clear-preserve-buffers'."
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
304 (interactive)
7240
195e64dad1eb (desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents: 7200
diff changeset
305 (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
306 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
307 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
308 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
309 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
310 regexp-search-ring-yank-pointer nil)
18581
45f27efe77c7 (desktop-clear-preserve-buffers): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 18527
diff changeset
311 (let ((buffers (buffer-list)))
45f27efe77c7 (desktop-clear-preserve-buffers): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 18527
diff changeset
312 (while buffers
45f27efe77c7 (desktop-clear-preserve-buffers): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 18527
diff changeset
313 (or (member (buffer-name (car buffers)) desktop-clear-preserve-buffers)
20772
a75bd4b8183d (desktop-clear): Don't kill dead buffers.
Richard M. Stallman <rms@gnu.org>
parents: 20526
diff changeset
314 (null (buffer-name (car buffers)))
18581
45f27efe77c7 (desktop-clear-preserve-buffers): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 18527
diff changeset
315 ;; Don't kill buffers made for internal purposes.
45f27efe77c7 (desktop-clear-preserve-buffers): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 18527
diff changeset
316 (and (not (equal (buffer-name (car buffers)) ""))
45f27efe77c7 (desktop-clear-preserve-buffers): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 18527
diff changeset
317 (eq (aref (buffer-name (car buffers)) 0) ?\ ))
45f27efe77c7 (desktop-clear-preserve-buffers): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 18527
diff changeset
318 (kill-buffer (car buffers)))
45f27efe77c7 (desktop-clear-preserve-buffers): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 18527
diff changeset
319 (setq buffers (cdr buffers))))
5314
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
320 (delete-other-windows))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
321 ;; ----------------------------------------------------------------------------
5788
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
322 (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
323
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
324 (defun desktop-kill ()
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
325 (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
326 (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
327 (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
328 (file-error
195e64dad1eb (desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents: 7200
diff changeset
329 (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
330 nil
195e64dad1eb (desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents: 7200
diff changeset
331 (signal (car err) (cdr err)))))))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
332 ;; ----------------------------------------------------------------------------
14754
9955249f9b0f (desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14172
diff changeset
333 (defun desktop-list* (&rest args)
9955249f9b0f (desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14172
diff changeset
334 (if (null (cdr args))
9955249f9b0f (desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14172
diff changeset
335 (car args)
9955249f9b0f (desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14172
diff changeset
336 (setq args (nreverse args))
9955249f9b0f (desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14172
diff changeset
337 (let ((value (cons (nth 1 args) (car args))))
9955249f9b0f (desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14172
diff changeset
338 (setq args (cdr (cdr args)))
9955249f9b0f (desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14172
diff changeset
339 (while args
9955249f9b0f (desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14172
diff changeset
340 (setq value (cons (car args) value))
9955249f9b0f (desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14172
diff changeset
341 (setq args (cdr args)))
9955249f9b0f (desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14172
diff changeset
342 value)))
9955249f9b0f (desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14172
diff changeset
343
5788
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
344 (defun desktop-internal-v2s (val)
10595
06fa5b312280 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 9776
diff changeset
345 "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
346 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
347 QUOTE may be `may' (value may be quoted),
06fa5b312280 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 9776
diff changeset
348 `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
349 (cond
9521
d53ed4fd05ca (desktop-internal-v2s): Remove all text properties from strings.
Richard M. Stallman <rms@gnu.org>
parents: 8152
diff changeset
350 ((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
351 (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
352 ((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
353 (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
354 (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
355 ;; 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
356 (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
357 ((symbolp val)
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
358 (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
359 ((vectorp val)
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
360 (let* ((special nil)
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
361 (pass1 (mapcar
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
362 (lambda (el)
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
363 (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
364 (if (null (car res))
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
365 (setq special t))
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
366 res))
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
367 val)))
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
368 (if special
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
369 (cons nil (concat "(vector "
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
370 (mapconcat (lambda (el)
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
371 (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
372 (concat "'" (cdr el))
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
373 (cdr el)))
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
374 pass1
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
375 " ")
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
376 ")"))
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
377 (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
378 ((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
379 (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
380 newlist
14754
9955249f9b0f (desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14172
diff changeset
381 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
382 anynil)
eabd5e6e95de (desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents: 7091
diff changeset
383 (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
384 (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
385 (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
386 (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
387 (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
388 (if p
eabd5e6e95de (desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents: 7091
diff changeset
389 (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
390 (el (car newlist)))
14754
9955249f9b0f (desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14172
diff changeset
391 (or anynil (setq anynil (null (car last))))
9955249f9b0f (desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14172
diff changeset
392 (or anynil
9955249f9b0f (desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14172
diff changeset
393 (setq newlist (cons '(must . ".") newlist)))
9955249f9b0f (desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14172
diff changeset
394 (setq use-list* t)
9955249f9b0f (desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14172
diff changeset
395 (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
396 (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
397 (if anynil
eabd5e6e95de (desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents: 7091
diff changeset
398 (cons nil
14754
9955249f9b0f (desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14172
diff changeset
399 (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
400 (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
401 (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
402 (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
403 (cdr el)))
eabd5e6e95de (desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents: 7091
diff changeset
404 newlist
eabd5e6e95de (desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents: 7091
diff changeset
405 " ")
eabd5e6e95de (desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents: 7091
diff changeset
406 ")"))
eabd5e6e95de (desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents: 7091
diff changeset
407 (cons 'must
eabd5e6e95de (desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents: 7091
diff changeset
408 (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
409 ((subrp val)
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
410 (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
411 (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
412 ")")))
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
413 ((markerp val)
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
414 (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
415 (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
416 (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
417 " (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
418 " (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
419 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
420 (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
421 (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
422
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
423 (defun desktop-value-to-string (val)
10595
06fa5b312280 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 9776
diff changeset
424 "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
425 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
426 (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
427 (float-output-format nil)
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
428 (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
429 (quote (car quote.txt))
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
430 (txt (cdr quote.txt)))
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
431 (if (eq quote 'must)
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
432 (concat "'" txt)
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
433 txt)))
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
434 ;; ----------------------------------------------------------------------------
13154
f86e18ff3736 (desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents: 11224
diff changeset
435 (defun desktop-outvar (varspec)
f86e18ff3736 (desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents: 11224
diff changeset
436 "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
437 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
438 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
439 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
440 \(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
441 (let (var size)
f86e18ff3736 (desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents: 11224
diff changeset
442 (if (consp varspec)
f86e18ff3736 (desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents: 11224
diff changeset
443 (setq var (car varspec) size (cdr varspec))
f86e18ff3736 (desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents: 11224
diff changeset
444 (setq var varspec))
f86e18ff3736 (desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents: 11224
diff changeset
445 (if (boundp var)
f86e18ff3736 (desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents: 11224
diff changeset
446 (progn
f86e18ff3736 (desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents: 11224
diff changeset
447 (if (and (integerp size)
f86e18ff3736 (desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents: 11224
diff changeset
448 (> size 0)
f86e18ff3736 (desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents: 11224
diff changeset
449 (listp (eval var)))
28719
f56c181fb849 (desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents: 27577
diff changeset
450 (desktop-truncate (eval var) size))
13154
f86e18ff3736 (desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents: 11224
diff changeset
451 (insert "(setq "
f86e18ff3736 (desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents: 11224
diff changeset
452 (symbol-name var)
f86e18ff3736 (desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents: 11224
diff changeset
453 " "
f86e18ff3736 (desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents: 11224
diff changeset
454 (desktop-value-to-string (symbol-value var))
f86e18ff3736 (desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents: 11224
diff changeset
455 ")\n")))))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
456 ;; ----------------------------------------------------------------------------
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
457 (defun desktop-save-buffer-p (filename bufname mode &rest dummy)
5314
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
458 "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
459 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
460 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
461 (let ((case-fold-search nil))
32366
40d8b29df57e (desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30853
diff changeset
462 (and (not (string-match desktop-buffers-not-to-save bufname))
40d8b29df57e (desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30853
diff changeset
463 (not (memq mode desktop-modes-not-to-save))
40d8b29df57e (desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30853
diff changeset
464 (or (and filename
40d8b29df57e (desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30853
diff changeset
465 (not (string-match desktop-files-not-to-save filename)))
40d8b29df57e (desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30853
diff changeset
466 (and (eq mode 'dired-mode)
40d8b29df57e (desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30853
diff changeset
467 (save-excursion
40d8b29df57e (desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30853
diff changeset
468 (set-buffer (get-buffer bufname))
40d8b29df57e (desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30853
diff changeset
469 (not (string-match desktop-files-not-to-save
40d8b29df57e (desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30853
diff changeset
470 default-directory))))
40d8b29df57e (desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30853
diff changeset
471 (and (null filename)
32447
cfae1c82d702 Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents: 32366
diff changeset
472 (memq mode desktop-buffer-modes-to-save))))))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
473 ;; ----------------------------------------------------------------------------
48143
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
474 (defcustom desktop-relative-file-names nil
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
475 "*Store relative file names in the desktop file."
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
476 :type 'boolean
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
477 :group 'desktop)
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
478
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
479 (defun desktop-save (dirname)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
480 "Save the Desktop file. Parameter DIRNAME specifies where to save desktop."
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
481 (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
482 (run-hooks 'desktop-save-hook)
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
483 (save-excursion
38765
7f07f5bca733 (desktop-save): Don't use concat to form a file
Gerd Moellmann <gerd@gnu.org>
parents: 38618
diff changeset
484 (let ((filename (expand-file-name desktop-basefilename dirname))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
485 (info (nreverse
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
486 (mapcar
28719
f56c181fb849 (desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents: 27577
diff changeset
487 (function
f56c181fb849 (desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents: 27577
diff changeset
488 (lambda (b)
48143
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
489 (set-buffer b)
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
490 (list
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
491 (let ((bn (buffer-file-name)))
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
492 (if bn
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
493 (if desktop-relative-file-names
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
494 (file-relative-name bn dirname)
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
495 bn)))
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
496 (buffer-name)
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
497 major-mode
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
498 ;; minor modes
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
499 (let (ret)
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
500 (mapcar
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
501 #'(lambda (mim)
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
502 (and (boundp mim)
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
503 (symbol-value mim)
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
504 (setq ret
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
505 (cons (let ((special (assq mim desktop-minor-mode-table)))
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
506 (if special
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
507 (cadr special)
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
508 mim))
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
509 ret))))
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
510 (mapcar #'car minor-mode-alist))
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
511 ret)
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
512 (point)
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
513 (list (mark t) mark-active)
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
514 buffer-read-only
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
515 (run-hook-with-args-until-success
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
516 'desktop-buffer-misc-functions)
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
517 (let ((locals desktop-locals-to-save)
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
518 (loclist (buffer-local-variables))
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
519 (ll))
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
520 (while locals
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
521 (let ((here (assq (car locals) loclist)))
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
522 (if here
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
523 (setq ll (cons here ll))
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
524 (if (member (car locals) loclist)
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
525 (setq ll (cons (car locals) ll)))))
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
526 (setq locals (cdr locals)))
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
527 ll)
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
528 )))
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
529 (buffer-list))))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
530 (buf (get-buffer-create "*desktop*")))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
531 (set-buffer buf)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
532 (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
533
38798
15f5a37cdf42 (desktop-save): Insert the coding: tag before desktop-header.
Eli Zaretskii <eliz@gnu.org>
parents: 38765
diff changeset
534 (insert ";; -*- coding: emacs-mule; -*-\n"
15f5a37cdf42 (desktop-save): Insert the coding: tag before desktop-header.
Eli Zaretskii <eliz@gnu.org>
parents: 38765
diff changeset
535 desktop-header
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
536 ";; 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
537 ";; 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
538 ";; Global section:\n")
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
539 (mapcar (function desktop-outvar) desktop-globals-to-save)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
540 (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
541 (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
542 (int-to-string
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
543 (- (length kill-ring) (length kill-ring-yank-pointer)))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
544 " kill-ring))\n"))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
545
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
546 (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
547 (mapcar
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
548 (function (lambda (l)
48143
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
549 (if (apply 'desktop-save-buffer-p l)
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
550 (progn
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
551 (insert desktop-create-buffer-form)
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
552 (mapcar
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
553 (function (lambda (e)
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
554 (insert "\n "
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
555 (desktop-value-to-string e))))
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
556 l)
8c7919f99581 (desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents: 43831
diff changeset
557 (insert ")\n\n")))))
5788
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
558 info)
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
559 (setq default-directory dirname)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
560 (if (file-exists-p filename) (delete-file filename))
38618
c41fb9fae096 (desktop-save): Bind coding-system-for-write to
Gerd Moellmann <gerd@gnu.org>
parents: 38592
diff changeset
561 (let ((coding-system-for-write 'emacs-mule))
c41fb9fae096 (desktop-save): Bind coding-system-for-write to
Gerd Moellmann <gerd@gnu.org>
parents: 38592
diff changeset
562 (write-region (point-min) (point-max) filename nil 'nomessage))))
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
563 (setq desktop-dirname dirname))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
564 ;; ----------------------------------------------------------------------------
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
565 (defun desktop-remove ()
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
566 "Delete the Desktop file and inactivate the desktop system."
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
567 (interactive)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
568 (if desktop-dirname
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
569 (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
570 (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
571 (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
572 (delete-file filename)))))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
573 ;; ----------------------------------------------------------------------------
21303
346595905ae4 (desktop-load-default): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 20772
diff changeset
574 ;;;###autoload
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
575 (defun desktop-read ()
14172
da563949c7d7 (desktop-read): Do nothing in batch mode.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
576 "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
577 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
578 (interactive)
14172
da563949c7d7 (desktop-read): Do nothing in batch mode.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
579 (if noninteractive
da563949c7d7 (desktop-read): Do nothing in batch mode.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
580 nil
da563949c7d7 (desktop-read): Do nothing in batch mode.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
581 (let ((dirs '("./" "~/")))
da563949c7d7 (desktop-read): Do nothing in batch mode.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
582 (while (and dirs
da563949c7d7 (desktop-read): Do nothing in batch mode.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
583 (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
584 desktop-basefilename
da563949c7d7 (desktop-read): Do nothing in batch mode.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
585 (car dirs)))))
da563949c7d7 (desktop-read): Do nothing in batch mode.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
586 (setq dirs (cdr dirs)))
da563949c7d7 (desktop-read): Do nothing in batch mode.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
587 (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
588 (if desktop-dirname
40210
01666fd1b210 (desktop-last-buffer): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 38798
diff changeset
589 (let ((desktop-last-buffer nil))
01666fd1b210 (desktop-last-buffer): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 38798
diff changeset
590 ;; `load-with-code-conversion' calls `eval-buffer' which
01666fd1b210 (desktop-last-buffer): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 38798
diff changeset
591 ;; contains a `save-excursion', so we end up with the same
01666fd1b210 (desktop-last-buffer): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 38798
diff changeset
592 ;; buffer before and after the load. This is a problem
01666fd1b210 (desktop-last-buffer): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 38798
diff changeset
593 ;; when the desktop is read initially when Emacs starts up
01666fd1b210 (desktop-last-buffer): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 38798
diff changeset
594 ;; because, if we still are in *scratch* after running
01666fd1b210 (desktop-last-buffer): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 38798
diff changeset
595 ;; `after-init-hook', the splash screen will be displayed.
14172
da563949c7d7 (desktop-read): Do nothing in batch mode.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
596 (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
597 t t t)
40210
01666fd1b210 (desktop-last-buffer): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 38798
diff changeset
598 (when desktop-last-buffer
01666fd1b210 (desktop-last-buffer): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 38798
diff changeset
599 (switch-to-buffer desktop-last-buffer))
14172
da563949c7d7 (desktop-read): Do nothing in batch mode.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
600 (run-hooks 'desktop-delay-hook)
da563949c7d7 (desktop-read): Do nothing in batch mode.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
601 (setq desktop-delay-hook nil)
da563949c7d7 (desktop-read): Do nothing in batch mode.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
602 (message "Desktop loaded."))
da563949c7d7 (desktop-read): Do nothing in batch mode.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
603 (desktop-clear)))))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
604 ;; ----------------------------------------------------------------------------
21303
346595905ae4 (desktop-load-default): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 20772
diff changeset
605 ;;;###autoload
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
606 (defun desktop-load-default ()
10595
06fa5b312280 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 9776
diff changeset
607 "Load the `default' start-up library manually.
06fa5b312280 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 9776
diff changeset
608 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
609 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
610 (if (not inhibit-default-init) ; safety check
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
611 (progn
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
612 (load "default" t t)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
613 (setq inhibit-default-init t))))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
614 ;; ----------------------------------------------------------------------------
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
615 ;; 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
616 ;;
32447
cfae1c82d702 Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents: 32366
diff changeset
617 (defun desktop-buffer-info-misc-data ()
cfae1c82d702 Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents: 32366
diff changeset
618 (if (eq major-mode 'Info-mode)
cfae1c82d702 Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents: 32366
diff changeset
619 (list Info-current-file
cfae1c82d702 Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents: 32366
diff changeset
620 Info-current-node)))
cfae1c82d702 Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents: 32366
diff changeset
621
cfae1c82d702 Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents: 32366
diff changeset
622 (defun desktop-buffer-dired-misc-data ()
cfae1c82d702 Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents: 32366
diff changeset
623 (if (eq major-mode 'dired-mode)
cfae1c82d702 Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents: 32366
diff changeset
624 (cons
cfae1c82d702 Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents: 32366
diff changeset
625 (expand-file-name dired-directory)
cfae1c82d702 Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents: 32366
diff changeset
626 (cdr
cfae1c82d702 Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents: 32366
diff changeset
627 (nreverse
cfae1c82d702 Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents: 32366
diff changeset
628 (mapcar
cfae1c82d702 Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents: 32366
diff changeset
629 (function car)
cfae1c82d702 Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents: 32366
diff changeset
630 dired-subdir-alist))))))
cfae1c82d702 Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents: 32366
diff changeset
631
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
632 (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
633 (if (eq 'Info-mode desktop-buffer-major-mode)
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
634 (progn
32447
cfae1c82d702 Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents: 32366
diff changeset
635 (let ((first (nth 0 desktop-buffer-misc))
cfae1c82d702 Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents: 32366
diff changeset
636 (second (nth 1 desktop-buffer-misc)))
cfae1c82d702 Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents: 32366
diff changeset
637 (when (and first second)
cfae1c82d702 Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents: 32366
diff changeset
638 (require 'info)
cfae1c82d702 Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents: 32366
diff changeset
639 (Info-find-node first second)
cfae1c82d702 Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents: 32366
diff changeset
640 (current-buffer))))))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
641 ;; ----------------------------------------------------------------------------
5314
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
642 (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
643 (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
644 (condition-case error
21316
8bfa13d10dd1 (desktop-buffer-info, desktop-buffer-rmail)
Richard M. Stallman <rms@gnu.org>
parents: 21303
diff changeset
645 (progn (rmail-input desktop-buffer-file-name)
8bfa13d10dd1 (desktop-buffer-info, desktop-buffer-rmail)
Richard M. Stallman <rms@gnu.org>
parents: 21303
diff changeset
646 (if (eq major-mode 'rmail-mode)
8bfa13d10dd1 (desktop-buffer-info, desktop-buffer-rmail)
Richard M. Stallman <rms@gnu.org>
parents: 21303
diff changeset
647 (current-buffer)
8bfa13d10dd1 (desktop-buffer-info, desktop-buffer-rmail)
Richard M. Stallman <rms@gnu.org>
parents: 21303
diff changeset
648 rmail-buffer))
9521
d53ed4fd05ca (desktop-internal-v2s): Remove all text properties from strings.
Richard M. Stallman <rms@gnu.org>
parents: 8152
diff changeset
649 (file-locked
d53ed4fd05ca (desktop-internal-v2s): Remove all text properties from strings.
Richard M. Stallman <rms@gnu.org>
parents: 8152
diff changeset
650 (kill-buffer (current-buffer))
d53ed4fd05ca (desktop-internal-v2s): Remove all text properties from strings.
Richard M. Stallman <rms@gnu.org>
parents: 8152
diff changeset
651 'ignored))))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
652 ;; ----------------------------------------------------------------------------
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
653 (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
654 (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
655 (progn
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
656 (require 'mh-e)
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
657 (mh-find-path)
21316
8bfa13d10dd1 (desktop-buffer-info, desktop-buffer-rmail)
Richard M. Stallman <rms@gnu.org>
parents: 21303
diff changeset
658 (mh-visit-folder desktop-buffer-name)
8bfa13d10dd1 (desktop-buffer-info, desktop-buffer-rmail)
Richard M. Stallman <rms@gnu.org>
parents: 21303
diff changeset
659 (current-buffer))))
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
660 ;; ----------------------------------------------------------------------------
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
661 (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
662 (if (eq 'dired-mode desktop-buffer-major-mode)
14756
aabf776c3b6a Global var `misc' renamed.
Richard M. Stallman <rms@gnu.org>
parents: 14755
diff changeset
663 (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
664 (progn
21316
8bfa13d10dd1 (desktop-buffer-info, desktop-buffer-rmail)
Richard M. Stallman <rms@gnu.org>
parents: 21303
diff changeset
665 (dired (car desktop-buffer-misc))
23541
417a469a4354 (desktop-buffer-dired): Use dired-maybe-insert-subdir.
Richard M. Stallman <rms@gnu.org>
parents: 23535
diff changeset
666 (mapcar 'dired-maybe-insert-subdir (cdr desktop-buffer-misc))
21316
8bfa13d10dd1 (desktop-buffer-info, desktop-buffer-rmail)
Richard M. Stallman <rms@gnu.org>
parents: 21303
diff changeset
667 (current-buffer))
14756
aabf776c3b6a Global var `misc' renamed.
Richard M. Stallman <rms@gnu.org>
parents: 14755
diff changeset
668 (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
669 (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
670 'ignored)))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
671 ;; ----------------------------------------------------------------------------
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
672 (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
673 (if desktop-buffer-file-name
3d473ed8c718 Global vars mam, fn, bn renamed.
Richard M. Stallman <rms@gnu.org>
parents: 14754
diff changeset
674 (if (or (file-exists-p desktop-buffer-file-name)
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
675 (and desktop-missing-file-warning
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
676 (y-or-n-p (format
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
677 "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
678 desktop-buffer-file-name))))
32366
40d8b29df57e (desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30853
diff changeset
679 (let ((buf (find-file-noselect desktop-buffer-file-name)))
40d8b29df57e (desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30853
diff changeset
680 (condition-case nil
40d8b29df57e (desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30853
diff changeset
681 (switch-to-buffer buf)
43831
7837693f5bac (desktop-buffer-handlers): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 41150
diff changeset
682 (error (pop-to-buffer buf)))
7837693f5bac (desktop-buffer-handlers): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 41150
diff changeset
683 buf)
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
684 'ignored)))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
685 ;; ----------------------------------------------------------------------------
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
686 ;; 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
687 ;; only.
40210
01666fd1b210 (desktop-last-buffer): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 38798
diff changeset
688
01666fd1b210 (desktop-last-buffer): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 38798
diff changeset
689 (defvar desktop-last-buffer nil
01666fd1b210 (desktop-last-buffer): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 38798
diff changeset
690 "Last buffer read. Dynamically bound in `desktop-read'.")
01666fd1b210 (desktop-last-buffer): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 38798
diff changeset
691
14755
3d473ed8c718 Global vars mam, fn, bn renamed.
Richard M. Stallman <rms@gnu.org>
parents: 14754
diff changeset
692 (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
693 desktop-buffer-major-mode
28719
f56c181fb849 (desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents: 27577
diff changeset
694 mim pt mk ro desktop-buffer-misc
f56c181fb849 (desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents: 27577
diff changeset
695 &optional locals)
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
696 (let ((hlist desktop-buffer-handlers)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
697 (result)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
698 (handler))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
699 (while (and (not result) hlist)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
700 (setq handler (car hlist))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
701 (setq result (funcall handler))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
702 (setq hlist (cdr hlist)))
21316
8bfa13d10dd1 (desktop-buffer-info, desktop-buffer-rmail)
Richard M. Stallman <rms@gnu.org>
parents: 21303
diff changeset
703 (when (bufferp result)
40210
01666fd1b210 (desktop-last-buffer): New variable.
Gerd Moellmann <gerd@gnu.org>
parents: 38798
diff changeset
704 (setq desktop-last-buffer result)
21316
8bfa13d10dd1 (desktop-buffer-info, desktop-buffer-rmail)
Richard M. Stallman <rms@gnu.org>
parents: 21303
diff changeset
705 (set-buffer result)
8bfa13d10dd1 (desktop-buffer-info, desktop-buffer-rmail)
Richard M. Stallman <rms@gnu.org>
parents: 21303
diff changeset
706 (if (not (equal (buffer-name) desktop-buffer-name))
8bfa13d10dd1 (desktop-buffer-info, desktop-buffer-rmail)
Richard M. Stallman <rms@gnu.org>
parents: 21303
diff changeset
707 (rename-buffer desktop-buffer-name))
28719
f56c181fb849 (desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents: 27577
diff changeset
708 ;; minor modes
f56c181fb849 (desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents: 27577
diff changeset
709 (cond ((equal '(t) mim) (auto-fill-mode 1)) ; backwards compatible
f56c181fb849 (desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents: 27577
diff changeset
710 ((equal '(nil) mim) (auto-fill-mode 0))
f56c181fb849 (desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents: 27577
diff changeset
711 (t (mapcar #'(lambda (minor-mode)
41150
6ce8f906931a (desktop-create-buffer): Use functionp.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40210
diff changeset
712 (when (functionp minor-mode)
6ce8f906931a (desktop-create-buffer): Use functionp.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40210
diff changeset
713 (funcall minor-mode 1)))
6ce8f906931a (desktop-create-buffer): Use functionp.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40210
diff changeset
714 mim)))
23535
28c62eea9ae7 (desktop-create-buffer): Handle old (broken) minor mode support.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23502
diff changeset
715 (goto-char pt)
21316
8bfa13d10dd1 (desktop-buffer-info, desktop-buffer-rmail)
Richard M. Stallman <rms@gnu.org>
parents: 21303
diff changeset
716 (if (consp mk)
8bfa13d10dd1 (desktop-buffer-info, desktop-buffer-rmail)
Richard M. Stallman <rms@gnu.org>
parents: 21303
diff changeset
717 (progn
8bfa13d10dd1 (desktop-buffer-info, desktop-buffer-rmail)
Richard M. Stallman <rms@gnu.org>
parents: 21303
diff changeset
718 (set-mark (car mk))
8bfa13d10dd1 (desktop-buffer-info, desktop-buffer-rmail)
Richard M. Stallman <rms@gnu.org>
parents: 21303
diff changeset
719 (setq mark-active (car (cdr mk))))
8bfa13d10dd1 (desktop-buffer-info, desktop-buffer-rmail)
Richard M. Stallman <rms@gnu.org>
parents: 21303
diff changeset
720 (set-mark mk))
8bfa13d10dd1 (desktop-buffer-info, desktop-buffer-rmail)
Richard M. Stallman <rms@gnu.org>
parents: 21303
diff changeset
721 ;; Never override file system if the file really is read-only marked.
8bfa13d10dd1 (desktop-buffer-info, desktop-buffer-rmail)
Richard M. Stallman <rms@gnu.org>
parents: 21303
diff changeset
722 (if ro (setq buffer-read-only ro))
8bfa13d10dd1 (desktop-buffer-info, desktop-buffer-rmail)
Richard M. Stallman <rms@gnu.org>
parents: 21303
diff changeset
723 (while locals
8bfa13d10dd1 (desktop-buffer-info, desktop-buffer-rmail)
Richard M. Stallman <rms@gnu.org>
parents: 21303
diff changeset
724 (let ((this (car locals)))
8bfa13d10dd1 (desktop-buffer-info, desktop-buffer-rmail)
Richard M. Stallman <rms@gnu.org>
parents: 21303
diff changeset
725 (if (consp this)
8bfa13d10dd1 (desktop-buffer-info, desktop-buffer-rmail)
Richard M. Stallman <rms@gnu.org>
parents: 21303
diff changeset
726 ;; an entry of this form `(symbol . value)'
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
727 (progn
21316
8bfa13d10dd1 (desktop-buffer-info, desktop-buffer-rmail)
Richard M. Stallman <rms@gnu.org>
parents: 21303
diff changeset
728 (make-local-variable (car this))
8bfa13d10dd1 (desktop-buffer-info, desktop-buffer-rmail)
Richard M. Stallman <rms@gnu.org>
parents: 21303
diff changeset
729 (set (car this) (cdr this)))
8bfa13d10dd1 (desktop-buffer-info, desktop-buffer-rmail)
Richard M. Stallman <rms@gnu.org>
parents: 21303
diff changeset
730 ;; an entry of the form `symbol'
8bfa13d10dd1 (desktop-buffer-info, desktop-buffer-rmail)
Richard M. Stallman <rms@gnu.org>
parents: 21303
diff changeset
731 (make-local-variable this)
8bfa13d10dd1 (desktop-buffer-info, desktop-buffer-rmail)
Richard M. Stallman <rms@gnu.org>
parents: 21303
diff changeset
732 (makunbound this)))
8bfa13d10dd1 (desktop-buffer-info, desktop-buffer-rmail)
Richard M. Stallman <rms@gnu.org>
parents: 21303
diff changeset
733 (setq locals (cdr locals))))))
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
734
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
735 ;; 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
736 (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
737 desktop-buffer-major-mode
14756
aabf776c3b6a Global var `misc' renamed.
Richard M. Stallman <rms@gnu.org>
parents: 14755
diff changeset
738 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
739 (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
740 desktop-buffer-major-mode (cdr mim) pt mk ro
aabf776c3b6a Global var `misc' renamed.
Richard M. Stallman <rms@gnu.org>
parents: 14755
diff changeset
741 desktop-buffer-misc
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
742 (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
743 (cons 'fill-column fc)
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
744 (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
745 (cons 'case-replace cr)
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
746 (cons 'overwrite-mode (car mim)))))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
747 ;; ----------------------------------------------------------------------------
20526
ec0a8ccddd6c (desktop-enable): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 18581
diff changeset
748
ec0a8ccddd6c (desktop-enable): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 18581
diff changeset
749 ;; If the user set desktop-enable to t with Custom,
ec0a8ccddd6c (desktop-enable): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 18581
diff changeset
750 ;; do the rest of what it takes to use desktop,
ec0a8ccddd6c (desktop-enable): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 18581
diff changeset
751 ;; but do it after finishing loading the init file.
ec0a8ccddd6c (desktop-enable): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 18581
diff changeset
752 (add-hook 'after-init-hook
ec0a8ccddd6c (desktop-enable): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 18581
diff changeset
753 '(lambda ()
ec0a8ccddd6c (desktop-enable): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 18581
diff changeset
754 (when desktop-enable
ec0a8ccddd6c (desktop-enable): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 18581
diff changeset
755 (desktop-load-default)
ec0a8ccddd6c (desktop-enable): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 18581
diff changeset
756 (desktop-read))))
ec0a8ccddd6c (desktop-enable): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 18581
diff changeset
757
3405
b48f023e8e29 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 3404
diff changeset
758 (provide 'desktop)
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
759
32366
40d8b29df57e (desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 30853
diff changeset
760 ;;; desktop.el ends here