annotate lisp/desktop.el @ 7885:bc6406a90796

(init_eval_once): Call xmalloc, not malloc.
author Richard M. Stallman <rms@gnu.org>
date Tue, 14 Jun 1994 19:48:19 +0000
parents 195e64dad1eb
children eecf5ae5a194
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
5788
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
3 ;; Copyright (C) 1993, 1994 Free Software Foundation, Inc.
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5 ;; Author: Morten Welinder <terra@diku.dk>
7240
195e64dad1eb (desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents: 7200
diff changeset
6 ;; Version: 2.09
5314
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
7 ;; Keywords: customization
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
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 ;; along with GNU Emacs; see the file COPYING. If not, write to
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26 ;;; Commentary:
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
28 ;; Save the Desktop, i.e.,
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
29 ;; - some global variables
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
30 ;; - the list of buffers with associated files. For each buffer also
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
31 ;; - the major mode
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
32 ;; - the default directory
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
33 ;; - the point
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
34 ;; - the mark & mark-active
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
35 ;; - buffer-read-only
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
36 ;; - some local variables
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
38 ;; To use this, first put these three lines in the bottom of your .emacs
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
39 ;; file (the later the better):
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
40 ;;
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
41 ;; (load "desktop")
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
42 ;; (desktop-load-default)
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
43 ;; (desktop-read)
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
44 ;;
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
45 ;; Between the second and the third line you may wish to add something that
5788
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
46 ;; updates the variables `desktop-globals-to-save' and/or
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
47 ;; `desktop-locals-to-save'. If for instance you want to save the local
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
48 ;; variable `foobar' for every buffer in which it is local, you could add
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
49 ;; the line
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
50 ;;
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
51 ;; (setq desktop-locals-to-save (cons 'foobar desktop-locals-to-save))
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
52 ;;
5788
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
53 ;; To avoid saving excessive amounts of data you may also with to add
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
54 ;; something like the following
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
55 ;;
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
56 ;; (add-hook 'kill-emacs-hook
5788
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
57 ;; '(lambda ()
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
58 ;; (desktop-truncate search-ring 3)
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
59 ;; (desktop-truncate regexp-search-ring 3)))
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
60 ;;
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
61 ;; which will make sure that no more than three search items are saved. You
7240
195e64dad1eb (desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents: 7200
diff changeset
62 ;; must place this line *after* the (load "desktop") line. See also the
195e64dad1eb (desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents: 7200
diff changeset
63 ;; variable desktop-save-hook.
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
65 ;; Start Emacs in the root directory of your "project". The desktop saver
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
66 ;; is inactive by default. You activate it by M-x desktop-save RET. When
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
67 ;; you exit the next time the above data will be saved. This ensures that
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
68 ;; all the files you were editing will be reloaded the next time you start
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
69 ;; Emacs from the same directory and that points will be set where you
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
70 ;; left them. If you save a desktop file in your home directory it will
5788
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
71 ;; act as a default desktop when you start Emacs from a directory that
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
72 ;; doesn't have its own. I never do this, but you may want to.
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
73
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
74 ;; By the way: don't use desktop.el to customize Emacs -- the file .emacs
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
75 ;; in your home directory is used for that. Saving global default values
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
76 ;; for buffers is an example of misuse.
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
77
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
78 ;; PLEASE NOTE: The kill ring can be saved as specified by the variable
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
79 ;; `desktop-globals-to-save' (by default it isn't). This may result in saving
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
80 ;; things you did not mean to keep. Use M-x desktop-clear RET.
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
81
7240
195e64dad1eb (desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents: 7200
diff changeset
82 ;; Thanks to hetrick@phys.uva.nl (Jim Hetrick) for useful ideas.
195e64dad1eb (desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents: 7200
diff changeset
83 ;; avk@rtsg.mot.com (Andrew V. Klein) for a dired tip.
195e64dad1eb (desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents: 7200
diff changeset
84 ;; chris@tecc.co.uk (Chris Boucher) for a mark tip.
195e64dad1eb (desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents: 7200
diff changeset
85 ;; f89-kam@nada.kth.se (Klas Mellbourn) for a mh-e tip.
195e64dad1eb (desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents: 7200
diff changeset
86 ;; kifer@sbkifer.cs.sunysb.edu (M. Kifer) for a bug hunt.
195e64dad1eb (desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents: 7200
diff changeset
87 ;; treese@lcs.mit.edu (Win Treese) for ange-ftp ftps.
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
88 ;; ---------------------------------------------------------------------------
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
89 ;; TODO:
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
90 ;;
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
91 ;; Save window configuration.
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
92 ;; Recognize more minor modes.
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
93 ;; Save mark rings.
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
94 ;; Start-up with buffer-menu???
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 ;;; Code:
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
98 ;; 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
99 (eval-when-compile
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
100 ;; 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
101 ;; 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
102 (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
103 ;; ----------------------------------------------------------------------------
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
104 ;; 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
105 ;; ----------------------------------------------------------------------------
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
106 (defconst desktop-basefilename
5788
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
107 (if (eq system-type 'ms-dos)
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 "emacs.dsk" ; Ms-Dos does not support multiple dots in file name
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 ".emacs.desktop")
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 "File for Emacs desktop. A directory name will be prepended to this name.")
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
112 (defvar desktop-missing-file-warning t
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 "*If non-nil then issue warning if a file no longer exists.
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 Otherwise simply ignore the file.")
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
116 (defvar desktop-globals-to-save
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 (list 'desktop-missing-file-warning
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
118 ;; 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
119 ;; 'kill-ring
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
120 'tags-file-name
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
121 'tags-table-list
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
122 'search-ring
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
123 'regexp-search-ring
5788
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
124 'register-alist
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
125 ;; 'desktop-globals-to-save ; Itself!
5314
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
126 )
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 "List of global variables to save when killing Emacs.")
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
129 (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
130 (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
131 'truncate-lines
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
132 'case-fold-search
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
133 'case-replace
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
134 'fill-column
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
135 'overwrite-mode
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
136 '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
137 'line-number-mode
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
138 )
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
139 "List of local variables to save for each buffer. The variables are saved
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
140 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
141 (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
142
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
143 ;; We skip .log files because they are normally temporary.
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
144 ;; (ftp) files because they require passwords and whatsnot.
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
145 ;; TAGS files to save time (tags-file-name is saved instead).
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 (defvar desktop-buffers-not-to-save
5788
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
147 "\\(^nn\\.a[0-9]+\\|\\.log\\|(ftp)\\|^tags\\|^TAGS\\)$"
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148 "Regexp identifying buffers that are to be excluded from saving.")
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149
7240
195e64dad1eb (desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents: 7200
diff changeset
150 ;; Skip ange-ftp files
195e64dad1eb (desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents: 7200
diff changeset
151 (defvar desktop-files-not-to-save
195e64dad1eb (desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents: 7200
diff changeset
152 "^/[^/:]*:"
195e64dad1eb (desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents: 7200
diff changeset
153 "Regexp identifying files whose buffers are to be excluded from saving.")
195e64dad1eb (desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents: 7200
diff changeset
154
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155 (defvar desktop-buffer-handlers
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
156 '(desktop-buffer-dired
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 desktop-buffer-rmail
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
158 desktop-buffer-mh
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159 desktop-buffer-info
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160 desktop-buffer-file)
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
161 "*List of functions to call in order to create a buffer. The functions are
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
162 called without explicit parameters but may access the the major mode as `mam',
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
163 the file name as `fn', the buffer name as `bn', the default directory as
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
164 `dd'. If some function returns non-nil no further functions are called.
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 If the function returns t then the buffer is considered created.")
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
166
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
167 (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
168 "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
169
195e64dad1eb (desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents: 7200
diff changeset
170 (defvar desktop-save-hook nil
195e64dad1eb (desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents: 7200
diff changeset
171 "Hook run before saving the desktop to allow you to cut history lists and
195e64dad1eb (desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents: 7200
diff changeset
172 the like shorter.")
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
173 ;; ----------------------------------------------------------------------------
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
174 (defvar desktop-dirname nil
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175 "The directory in which the current desktop file resides.")
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177 (defconst desktop-header
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
178 ";; --------------------------------------------------------------------------
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
179 ;; Desktop File for Emacs
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
180 ;; --------------------------------------------------------------------------
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181 " "*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
182
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
183 (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
184 "Hooks run after all buffers are loaded; intended for internal use.")
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
185 ;; ----------------------------------------------------------------------------
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
186 (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
187 "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
188 (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
189 (if (consp here)
5788
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
190 (setcdr here nil))))
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
191 ;; ----------------------------------------------------------------------------
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192 (defun desktop-clear () "Empty the Desktop."
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193 (interactive)
7240
195e64dad1eb (desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents: 7200
diff changeset
194 (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
195 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
196 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
197 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
198 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
199 regexp-search-ring-yank-pointer nil)
5314
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
200 (mapcar (function kill-buffer) (buffer-list))
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
201 (delete-other-windows))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
202 ;; ----------------------------------------------------------------------------
5788
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
203 (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
204
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205 (defun desktop-kill ()
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
206 (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
207 (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
208 (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
209 (file-error
195e64dad1eb (desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents: 7200
diff changeset
210 (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
211 nil
195e64dad1eb (desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents: 7200
diff changeset
212 (signal (car err) (cdr err)))))))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
213 ;; ----------------------------------------------------------------------------
5788
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
214 (defun desktop-internal-v2s (val)
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
215 "Convert VALUE to a pair (quote . txt) where txt is a string that when read
7091
cb7cc8672ea9 (desktop-internal-v2s): Make structure match docstring.
Karl Heuer <kwzh@gnu.org>
parents: 5836
diff changeset
216 and evaluated yields value. quote may be 'may (value may be quoted),
5788
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
217 'must (values must be quoted), or nil (value may not be quoted)."
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
218 (cond
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
219 ((or (numberp val) (stringp val) (null val) (eq t val))
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
220 (cons 'may (prin1-to-string val)))
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
221 ((symbolp val)
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
222 (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
223 ((vectorp val)
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
224 (let* ((special nil)
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
225 (pass1 (mapcar
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
226 (lambda (el)
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
227 (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
228 (if (null (car res))
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
229 (setq special t))
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
230 res))
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
231 val)))
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
232 (if special
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
233 (cons nil (concat "(vector "
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
234 (mapconcat (lambda (el)
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
235 (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
236 (concat "'" (cdr el))
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
237 (cdr el)))
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
238 pass1
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
239 " ")
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
240 ")"))
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
241 (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
242 ((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
243 (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
244 newlist
eabd5e6e95de (desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents: 7091
diff changeset
245 anynil)
eabd5e6e95de (desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents: 7091
diff changeset
246 (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
247 (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
248 (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
249 (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
250 (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
251 (if p
eabd5e6e95de (desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents: 7091
diff changeset
252 (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
253 (el (car newlist)))
eabd5e6e95de (desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents: 7091
diff changeset
254 (setcar newlist
eabd5e6e95de (desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents: 7091
diff changeset
255 (if (or anynil (setq anynil (null (car last))))
eabd5e6e95de (desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents: 7091
diff changeset
256 (cons nil
eabd5e6e95de (desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents: 7091
diff changeset
257 (concat "(cons "
eabd5e6e95de (desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents: 7091
diff changeset
258 (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
259 (cdr el)
eabd5e6e95de (desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents: 7091
diff changeset
260 " "
eabd5e6e95de (desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents: 7091
diff changeset
261 (if (eq (car last) 'must) "'" "")
eabd5e6e95de (desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents: 7091
diff changeset
262 (cdr last)
eabd5e6e95de (desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents: 7091
diff changeset
263 ")"))
eabd5e6e95de (desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents: 7091
diff changeset
264 (cons 'must
eabd5e6e95de (desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents: 7091
diff changeset
265 (concat (cdr el) " . " (cdr last)))))))
eabd5e6e95de (desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents: 7091
diff changeset
266 (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
267 (if anynil
eabd5e6e95de (desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents: 7091
diff changeset
268 (cons nil
eabd5e6e95de (desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents: 7091
diff changeset
269 (concat "(list "
eabd5e6e95de (desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents: 7091
diff changeset
270 (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
271 (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
272 (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
273 (cdr el)))
eabd5e6e95de (desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents: 7091
diff changeset
274 newlist
eabd5e6e95de (desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents: 7091
diff changeset
275 " ")
eabd5e6e95de (desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents: 7091
diff changeset
276 ")"))
eabd5e6e95de (desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents: 7091
diff changeset
277 (cons 'must
eabd5e6e95de (desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents: 7091
diff changeset
278 (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
279 ((subrp val)
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
280 (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
281 (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
282 ")")))
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
283 ((markerp val)
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
284 (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
285 (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
286 (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
287 " (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
288 " (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
289 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
290 (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
291 (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
292
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
293 (defun desktop-value-to-string (val)
5788
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
294 "Convert VALUE to a string that when read evaluates to the same value. Not
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
295 all types of values are supported."
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
296 (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
297 (float-output-format nil)
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
298 (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
299 (quote (car quote.txt))
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
300 (txt (cdr quote.txt)))
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
301 (if (eq quote 'must)
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
302 (concat "'" txt)
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
303 txt)))
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
304 ;; ----------------------------------------------------------------------------
5314
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
305 (defun desktop-outvar (var)
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
306 "Output a setq statement for VAR to the desktop file."
5314
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
307 (if (boundp var)
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
308 (insert "(setq "
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
309 (symbol-name var)
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
310 " "
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
311 (desktop-value-to-string (symbol-value var))
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
312 ")\n")))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
313 ;; ----------------------------------------------------------------------------
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
314 (defun desktop-save-buffer-p (filename bufname mode &rest dummy)
5314
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
315 "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
316 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
317 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
318 (let ((case-fold-search nil))
195e64dad1eb (desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents: 7200
diff changeset
319 (or (and filename
195e64dad1eb (desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents: 7200
diff changeset
320 (not (string-match desktop-buffers-not-to-save bufname))
195e64dad1eb (desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents: 7200
diff changeset
321 (not (string-match desktop-files-not-to-save filename)))
195e64dad1eb (desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents: 7200
diff changeset
322 (and (eq mode 'dired-mode)
195e64dad1eb (desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents: 7200
diff changeset
323 (save-excursion
195e64dad1eb (desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents: 7200
diff changeset
324 (set-buffer (get-buffer bufname))
195e64dad1eb (desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents: 7200
diff changeset
325 (not (string-match desktop-files-not-to-save
195e64dad1eb (desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents: 7200
diff changeset
326 default-directory))))
195e64dad1eb (desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents: 7200
diff changeset
327 (and (null filename)
195e64dad1eb (desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents: 7200
diff changeset
328 (memq mode '(Info-mode rmail-mode))))))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
329 ;; ----------------------------------------------------------------------------
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
330 (defun desktop-save (dirname)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
331 "Save the Desktop file. Parameter DIRNAME specifies where to save desktop."
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
332 (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
333 (run-hooks 'desktop-save-hook)
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
334 (save-excursion
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
335 (let ((filename (expand-file-name
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
336 (concat dirname desktop-basefilename)))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
337 (info (nreverse
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
338 (mapcar
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
339 (function (lambda (b)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
340 (set-buffer b)
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
341 (list
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
342 (buffer-file-name)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
343 (buffer-name)
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
344 major-mode
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
345 (list ; list explaining minor modes
7240
195e64dad1eb (desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents: 7200
diff changeset
346 (not (null auto-fill-function)))
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
347 (point)
5788
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
348 (list (mark t) mark-active)
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
349 buffer-read-only
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
350 (cond ((eq major-mode 'Info-mode)
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
351 (list Info-current-file
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
352 Info-current-node))
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
353 ((eq major-mode 'dired-mode)
5788
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
354 (nreverse
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
355 (mapcar
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
356 (function car)
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
357 dired-subdir-alist)))
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
358 )
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
359 (let ((locals desktop-locals-to-save)
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
360 (loclist (buffer-local-variables))
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
361 (ll))
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
362 (while locals
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
363 (let ((here (assq (car locals) loclist)))
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
364 (if here
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
365 (setq ll (cons here ll))
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
366 (if (member (car locals) loclist)
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
367 (setq ll (cons (car locals) ll)))))
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
368 (setq locals (cdr locals)))
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
369 ll)
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
370 )))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
371 (buffer-list))))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
372 (buf (get-buffer-create "*desktop*")))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
373 (set-buffer buf)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
374 (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
375
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
376 (insert desktop-header
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
377 ";; 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
378 ";; 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
379 ";; Global section:\n")
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
380 (mapcar (function desktop-outvar) desktop-globals-to-save)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
381 (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
382 (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
383 (int-to-string
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
384 (- (length kill-ring) (length kill-ring-yank-pointer)))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
385 " kill-ring))\n"))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
386
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
387 (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
388 (mapcar
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
389 (function (lambda (l)
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
390 (if (apply 'desktop-save-buffer-p l)
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
391 (progn
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
392 (insert desktop-create-buffer-form)
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
393 (mapcar
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
394 (function (lambda (e)
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
395 (insert "\n "
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
396 (desktop-value-to-string e))))
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
397 l)
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
398 (insert ")\n\n")))))
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
399 info)
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
400 (setq default-directory dirname)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
401 (if (file-exists-p filename) (delete-file filename))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
402 (write-region (point-min) (point-max) filename nil 'nomessage)))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
403 (setq desktop-dirname dirname))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
404 ;; ----------------------------------------------------------------------------
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
405 (defun desktop-remove ()
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
406 "Delete the Desktop file and inactivate the desktop system."
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
407 (interactive)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
408 (if desktop-dirname
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
409 (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
410 (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
411 (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
412 (delete-file filename)))))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
413 ;; ----------------------------------------------------------------------------
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
414 (defun desktop-read ()
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
415 "Read the Desktop file and the files it specifies."
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
416 (interactive)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
417 (let ((filename))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
418 (if (file-exists-p (concat "./" desktop-basefilename))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
419 (setq desktop-dirname (expand-file-name "./"))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
420 (if (file-exists-p (concat "~/" desktop-basefilename))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
421 (setq desktop-dirname (expand-file-name "~/"))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
422 (setq desktop-dirname nil)))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
423 (if desktop-dirname
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
424 (progn
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
425 (load (concat desktop-dirname desktop-basefilename) t t t)
5788
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
426 (run-hooks 'desktop-delay-hook)
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
427 (message "Desktop loaded."))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
428 (desktop-clear))))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
429 ;; ----------------------------------------------------------------------------
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
430 (defun desktop-load-default ()
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
431 "Load the `default' start-up library manually. Also inhibit further loading
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
432 of it. Call this from your `.emacs' file to provide correct modes for
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
433 autoloaded files."
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
434 (if (not inhibit-default-init) ; safety check
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
435 (progn
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
436 (load "default" t t)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
437 (setq inhibit-default-init t))))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
438 ;; ----------------------------------------------------------------------------
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
439 ;; 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
440 ;;
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
441 (defun desktop-buffer-info () "Load an info file."
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
442 (if (eq 'Info-mode mam)
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
443 (progn
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
444 (require 'info)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
445 (Info-find-node (nth 0 misc) (nth 1 misc))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
446 t)))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
447 ;; ----------------------------------------------------------------------------
5314
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
448 (defun desktop-buffer-rmail () "Load an RMAIL file."
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
449 (if (eq 'rmail-mode mam)
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
450 (progn (rmail-input fn) t)))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
451 ;; ----------------------------------------------------------------------------
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
452 (defun desktop-buffer-mh () "Load a folder in the mh system."
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
453 (if (eq 'mh-folder-mode mam)
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
454 (progn
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
455 (require 'mh-e)
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
456 (mh-find-path)
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
457 (mh-visit-folder bn)
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
458 t)))
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
459 ;; ----------------------------------------------------------------------------
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
460 (defun desktop-buffer-dired () "Load a directory using dired."
5314
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
461 (if (eq 'dired-mode mam)
7240
195e64dad1eb (desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents: 7200
diff changeset
462 (if (file-directory-p (directory-file-name (car misc)))
195e64dad1eb (desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents: 7200
diff changeset
463 (progn
195e64dad1eb (desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents: 7200
diff changeset
464 (dired (car misc))
195e64dad1eb (desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents: 7200
diff changeset
465 (mapcar (function dired-maybe-insert-subdir) (cdr misc))
195e64dad1eb (desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents: 7200
diff changeset
466 t)
195e64dad1eb (desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents: 7200
diff changeset
467 (message "Directory %s no longer exists." (car misc))
195e64dad1eb (desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents: 7200
diff changeset
468 (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
469 'ignored)))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
470 ;; ----------------------------------------------------------------------------
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
471 (defun desktop-buffer-file () "Load a file."
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
472 (if fn
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
473 (if (or (file-exists-p fn)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
474 (and desktop-missing-file-warning
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
475 (y-or-n-p (format
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
476 "File \"%s\" no longer exists. Re-create? "
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
477 fn))))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
478 (progn (find-file fn) t)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
479 'ignored)))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
480 ;; ----------------------------------------------------------------------------
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
481 ;; 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
482 ;; only.
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
483 (defun desktop-create-buffer (ver fn bn mam mim pt mk ro misc &optional locals)
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
484 (let ((hlist desktop-buffer-handlers)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
485 (result)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
486 (handler))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
487 (while (and (not result) hlist)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
488 (setq handler (car hlist))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
489 (setq result (funcall handler))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
490 (setq hlist (cdr hlist)))
5314
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
491 (if (eq result t)
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
492 (progn
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
493 (if (not (equal (buffer-name) bn))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
494 (rename-buffer bn))
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
495 (auto-fill-mode (if (nth 0 mim) 1 0))
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
496 (goto-char pt)
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
497 (if (consp mk)
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
498 (progn
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
499 (set-mark (car mk))
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
500 (setq mark-active (car (cdr mk))))
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
501 (set-mark mk))
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
502 ;; Never override file system if the file really is read-only marked.
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
503 (if ro (setq buffer-read-only ro))
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
504 (while locals
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
505 (let ((this (car locals)))
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
506 (if (consp this)
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
507 ;; an entry of this form `(symbol . value)'
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
508 (progn
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
509 (make-local-variable (car this))
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
510 (set (car this) (cdr this)))
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
511 ;; an entry of the form `symbol'
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
512 (make-local-variable this)
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
513 (makunbound this)))
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
514 (setq locals (cdr locals)))
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
515 ))))
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
516
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
517 ;; Backward compatibility -- update parameters to 205 standards.
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
518 (defun desktop-buffer (fn bn mam mim pt mk ro tl fc cfs cr misc)
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
519 (desktop-create-buffer 205 fn bn mam (cdr mim) pt mk ro misc
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
520 (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
521 (cons 'fill-column fc)
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
522 (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
523 (cons 'case-replace cr)
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
524 (cons 'overwrite-mode (car mim)))))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
525 ;; ----------------------------------------------------------------------------
3405
b48f023e8e29 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 3404
diff changeset
526 (provide 'desktop)
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
527
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
528 ;; desktop.el ends here.