annotate lisp/desktop.el @ 9874:2bf88bd23cbb

(facemenu-update): Use C-down-mouse-2 for the menu. Doc fixes.
author Richard M. Stallman <rms@gnu.org>
date Wed, 09 Nov 1994 20:56:17 +0000
parents b25efd6c4f30
children 06fa5b312280
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
9776
b25efd6c4f30 (desktop-basefilename): Use emacs.dsk on windows-nt.
Richard M. Stallman <rms@gnu.org>
parents: 9521
diff changeset
107 (if (or (eq system-type 'ms-dos) (eq system-type 'windows-nt))
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
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
9521
d53ed4fd05ca (desktop-internal-v2s): Remove all text properties from strings.
Richard M. Stallman <rms@gnu.org>
parents: 8152
diff changeset
219 ((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
220 (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
221 ((stringp val)
d53ed4fd05ca (desktop-internal-v2s): Remove all text properties from strings.
Richard M. Stallman <rms@gnu.org>
parents: 8152
diff changeset
222 ;; Get rid of text properties because we cannot read them
d53ed4fd05ca (desktop-internal-v2s): Remove all text properties from strings.
Richard M. Stallman <rms@gnu.org>
parents: 8152
diff changeset
223 (cons 'may (prin1-to-string (format "%s" val))))
5788
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
224 ((symbolp val)
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
225 (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
226 ((vectorp val)
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
227 (let* ((special nil)
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
228 (pass1 (mapcar
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
229 (lambda (el)
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
230 (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
231 (if (null (car res))
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
232 (setq special t))
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
233 res))
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
234 val)))
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
235 (if special
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
236 (cons nil (concat "(vector "
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
237 (mapconcat (lambda (el)
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
238 (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
239 (concat "'" (cdr el))
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
240 (cdr el)))
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
241 pass1
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
242 " ")
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
243 ")"))
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
244 (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
245 ((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
246 (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
247 newlist
eabd5e6e95de (desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents: 7091
diff changeset
248 anynil)
eabd5e6e95de (desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents: 7091
diff changeset
249 (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
250 (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
251 (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
252 (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
253 (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
254 (if p
eabd5e6e95de (desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents: 7091
diff changeset
255 (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
256 (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
257 (setcar newlist
eabd5e6e95de (desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents: 7091
diff changeset
258 (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
259 (cons nil
eabd5e6e95de (desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents: 7091
diff changeset
260 (concat "(cons "
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 el) '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 el)
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 (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
265 (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 ")"))
eabd5e6e95de (desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents: 7091
diff changeset
267 (cons 'must
eabd5e6e95de (desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents: 7091
diff changeset
268 (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
269 (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
270 (if anynil
eabd5e6e95de (desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents: 7091
diff changeset
271 (cons nil
eabd5e6e95de (desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents: 7091
diff changeset
272 (concat "(list "
eabd5e6e95de (desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents: 7091
diff changeset
273 (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
274 (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
275 (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
276 (cdr el)))
eabd5e6e95de (desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents: 7091
diff changeset
277 newlist
eabd5e6e95de (desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents: 7091
diff changeset
278 " ")
eabd5e6e95de (desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents: 7091
diff changeset
279 ")"))
eabd5e6e95de (desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents: 7091
diff changeset
280 (cons 'must
eabd5e6e95de (desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents: 7091
diff changeset
281 (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
282 ((subrp val)
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
283 (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
284 (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
285 ")")))
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
286 ((markerp val)
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
287 (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
288 (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
289 (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
290 " (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
291 " (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
292 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
293 (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
294 (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
295
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
296 (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
297 "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
298 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
299 (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
300 (float-output-format nil)
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
301 (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
302 (quote (car quote.txt))
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
303 (txt (cdr quote.txt)))
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
304 (if (eq quote 'must)
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
305 (concat "'" txt)
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
306 txt)))
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
307 ;; ----------------------------------------------------------------------------
5314
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
308 (defun desktop-outvar (var)
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
309 "Output a setq statement for VAR to the desktop file."
5314
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
310 (if (boundp var)
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
311 (insert "(setq "
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
312 (symbol-name var)
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
313 " "
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
314 (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
315 ")\n")))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
316 ;; ----------------------------------------------------------------------------
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
317 (defun desktop-save-buffer-p (filename bufname mode &rest dummy)
5314
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
318 "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
319 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
320 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
321 (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
322 (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
323 (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
324 (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
325 (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
326 (save-excursion
195e64dad1eb (desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents: 7200
diff changeset
327 (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
328 (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
329 default-directory))))
195e64dad1eb (desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents: 7200
diff changeset
330 (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
331 (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
332 ;; ----------------------------------------------------------------------------
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
333 (defun desktop-save (dirname)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
334 "Save the Desktop file. Parameter DIRNAME specifies where to save desktop."
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
335 (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
336 (run-hooks 'desktop-save-hook)
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
337 (save-excursion
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
338 (let ((filename (expand-file-name
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
339 (concat dirname desktop-basefilename)))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
340 (info (nreverse
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
341 (mapcar
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
342 (function (lambda (b)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
343 (set-buffer b)
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
344 (list
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
345 (buffer-file-name)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
346 (buffer-name)
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
347 major-mode
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
348 (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
349 (not (null auto-fill-function)))
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
350 (point)
5788
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
351 (list (mark t) mark-active)
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
352 buffer-read-only
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
353 (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
354 (list Info-current-file
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
355 Info-current-node))
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
356 ((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
357 (nreverse
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
358 (mapcar
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
359 (function car)
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
360 dired-subdir-alist)))
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
361 )
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
362 (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
363 (loclist (buffer-local-variables))
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
364 (ll))
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
365 (while locals
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
366 (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
367 (if here
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
368 (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
369 (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
370 (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
371 (setq locals (cdr locals)))
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
372 ll)
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
373 )))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
374 (buffer-list))))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
375 (buf (get-buffer-create "*desktop*")))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
376 (set-buffer buf)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
377 (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
378
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
379 (insert desktop-header
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
380 ";; 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
381 ";; 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
382 ";; Global section:\n")
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
383 (mapcar (function desktop-outvar) desktop-globals-to-save)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
384 (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
385 (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
386 (int-to-string
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
387 (- (length kill-ring) (length kill-ring-yank-pointer)))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
388 " kill-ring))\n"))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
389
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
390 (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
391 (mapcar
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
392 (function (lambda (l)
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
393 (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
394 (progn
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
395 (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
396 (mapcar
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
397 (function (lambda (e)
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
398 (insert "\n "
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
399 (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
400 l)
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
401 (insert ")\n\n")))))
913f27480fad (desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents: 5465
diff changeset
402 info)
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
403 (setq default-directory dirname)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
404 (if (file-exists-p filename) (delete-file filename))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
405 (write-region (point-min) (point-max) filename nil 'nomessage)))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
406 (setq desktop-dirname dirname))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
407 ;; ----------------------------------------------------------------------------
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
408 (defun desktop-remove ()
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
409 "Delete the Desktop file and inactivate the desktop system."
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
410 (interactive)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
411 (if desktop-dirname
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
412 (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
413 (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
414 (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
415 (delete-file filename)))))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
416 ;; ----------------------------------------------------------------------------
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
417 (defun desktop-read ()
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
418 "Read the Desktop file and the files it specifies."
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
419 (interactive)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
420 (let ((filename))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
421 (if (file-exists-p (concat "./" desktop-basefilename))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
422 (setq desktop-dirname (expand-file-name "./"))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
423 (if (file-exists-p (concat "~/" desktop-basefilename))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
424 (setq desktop-dirname (expand-file-name "~/"))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
425 (setq desktop-dirname nil)))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
426 (if desktop-dirname
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
427 (progn
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
428 (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
429 (run-hooks 'desktop-delay-hook)
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
430 (message "Desktop loaded."))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
431 (desktop-clear))))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
432 ;; ----------------------------------------------------------------------------
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
433 (defun desktop-load-default ()
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
434 "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
435 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
436 autoloaded files."
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
437 (if (not inhibit-default-init) ; safety check
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
438 (progn
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
439 (load "default" t t)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
440 (setq inhibit-default-init t))))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
441 ;; ----------------------------------------------------------------------------
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
442 ;; 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
443 ;;
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
444 (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
445 (if (eq 'Info-mode mam)
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
446 (progn
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
447 (require 'info)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
448 (Info-find-node (nth 0 misc) (nth 1 misc))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
449 t)))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
450 ;; ----------------------------------------------------------------------------
5314
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
451 (defun desktop-buffer-rmail () "Load an RMAIL file."
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
452 (if (eq 'rmail-mode mam)
8152
eecf5ae5a194 (desktop-buffer-rmail): Handle the situation
Richard M. Stallman <rms@gnu.org>
parents: 7240
diff changeset
453 (condition-case error
9521
d53ed4fd05ca (desktop-internal-v2s): Remove all text properties from strings.
Richard M. Stallman <rms@gnu.org>
parents: 8152
diff changeset
454 (progn (rmail-input fn) t)
d53ed4fd05ca (desktop-internal-v2s): Remove all text properties from strings.
Richard M. Stallman <rms@gnu.org>
parents: 8152
diff changeset
455 (file-locked
d53ed4fd05ca (desktop-internal-v2s): Remove all text properties from strings.
Richard M. Stallman <rms@gnu.org>
parents: 8152
diff changeset
456 (kill-buffer (current-buffer))
d53ed4fd05ca (desktop-internal-v2s): Remove all text properties from strings.
Richard M. Stallman <rms@gnu.org>
parents: 8152
diff changeset
457 'ignored))))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
458 ;; ----------------------------------------------------------------------------
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
459 (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
460 (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
461 (progn
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
462 (require 'mh-e)
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
463 (mh-find-path)
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
464 (mh-visit-folder bn)
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
465 t)))
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
466 ;; ----------------------------------------------------------------------------
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
467 (defun desktop-buffer-dired () "Load a directory using dired."
5314
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
468 (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
469 (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
470 (progn
195e64dad1eb (desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents: 7200
diff changeset
471 (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
472 (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
473 t)
195e64dad1eb (desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents: 7200
diff changeset
474 (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
475 (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
476 'ignored)))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
477 ;; ----------------------------------------------------------------------------
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
478 (defun desktop-buffer-file () "Load a file."
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
479 (if fn
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
480 (if (or (file-exists-p fn)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
481 (and desktop-missing-file-warning
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
482 (y-or-n-p (format
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
483 "File \"%s\" no longer exists. Re-create? "
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
484 fn))))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
485 (progn (find-file fn) t)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
486 'ignored)))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
487 ;; ----------------------------------------------------------------------------
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
488 ;; 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
489 ;; only.
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
490 (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
491 (let ((hlist desktop-buffer-handlers)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
492 (result)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
493 (handler))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
494 (while (and (not result) hlist)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
495 (setq handler (car hlist))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
496 (setq result (funcall handler))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
497 (setq hlist (cdr hlist)))
5314
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
498 (if (eq result t)
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
499 (progn
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
500 (if (not (equal (buffer-name) bn))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
501 (rename-buffer bn))
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
502 (auto-fill-mode (if (nth 0 mim) 1 0))
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
503 (goto-char pt)
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
504 (if (consp mk)
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
505 (progn
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
506 (set-mark (car mk))
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
507 (setq mark-active (car (cdr mk))))
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
508 (set-mark mk))
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
509 ;; 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
510 (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
511 (while locals
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
512 (let ((this (car locals)))
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
513 (if (consp this)
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
514 ;; 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
515 (progn
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
516 (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
517 (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
518 ;; 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
519 (make-local-variable this)
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
520 (makunbound this)))
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
521 (setq locals (cdr locals)))
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
522 ))))
5465
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
523
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
524 ;; 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
525 (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
526 (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
527 (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
528 (cons 'fill-column fc)
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
529 (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
530 (cons 'case-replace cr)
9fcfca1caec7 (desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents: 5314
diff changeset
531 (cons 'overwrite-mode (car mim)))))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
532 ;; ----------------------------------------------------------------------------
3405
b48f023e8e29 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 3404
diff changeset
533 (provide 'desktop)
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
534
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
535 ;; desktop.el ends here.