Mercurial > emacs
annotate lisp/desktop.el @ 89719:d91b7816539c
(print_check_string_charset_prop): Fix previous change.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Sun, 18 Jan 2004 23:45:31 +0000 |
parents | 2f877ed80fa6 |
children | 68c22ea6027c |
rev | line source |
---|---|
3404 | 1 ;;; desktop.el --- save partial status of Emacs when killed |
2 | |
38592
27468a9cf559
(desktop-save): Add `-*- coding: emacs-mule -*-' to
Gerd Moellmann <gerd@gnu.org>
parents:
32447
diff
changeset
|
3 ;; Copyright (C) 1993, 1994, 1995, 1997, 2000, 2001 |
27468a9cf559
(desktop-save): Add `-*- coding: emacs-mule -*-' to
Gerd Moellmann <gerd@gnu.org>
parents:
32447
diff
changeset
|
4 ;; Free Software Foundation, Inc. |
3404 | 5 |
6 ;; Author: Morten Welinder <terra@diku.dk> | |
51468
2c411b58af59
Add new maintainer.
Juanma Barranquero <lekktu@gmail.com>
parents:
51441
diff
changeset
|
7 ;; Maintainter: Lars Hansen <larsh@math.ku.dk> |
27577 | 8 ;; Keywords: convenience |
5314 | 9 ;; Favourite-brand-of-beer: None, I hate beer. |
3404 | 10 |
11 ;; This file is part of GNU Emacs. | |
12 | |
13 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
14 ;; it under the terms of the GNU General Public License as published by | |
15 ;; the Free Software Foundation; either version 2, or (at your option) | |
16 ;; any later version. | |
17 | |
18 ;; GNU Emacs is distributed in the hope that it will be useful, | |
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 ;; GNU General Public License for more details. | |
22 | |
23 ;; You should have received a copy of the GNU General Public License | |
14169 | 24 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
26 ;; Boston, MA 02111-1307, USA. | |
3404 | 27 |
28 ;;; Commentary: | |
29 | |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
30 ;; Save the Desktop, i.e., |
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
31 ;; - some global variables |
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
32 ;; - 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
|
33 ;; - the major mode |
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
34 ;; - the default directory |
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
35 ;; - the point |
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
36 ;; - the mark & mark-active |
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
37 ;; - buffer-read-only |
5465
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
38 ;; - some local variables |
3404 | 39 |
21303
346595905ae4
(desktop-load-default): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents:
20772
diff
changeset
|
40 ;; To use this, first put these two lines in the bottom of your .emacs |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
41 ;; file (the later the better): |
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
42 ;; |
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
43 ;; (desktop-load-default) |
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
44 ;; (desktop-read) |
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
45 ;; |
28719
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
46 ;; Between these two lines you may wish to add something that updates the |
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
47 ;; variables `desktop-globals-to-save' and/or `desktop-locals-to-save'. If |
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
48 ;; for instance you want to save the local variable `foobar' for every buffer |
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
49 ;; in which it is local, you could add the line |
5465
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
50 ;; |
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
51 ;; (setq desktop-locals-to-save (cons 'foobar desktop-locals-to-save)) |
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
52 ;; |
11224
f7f101a90cd4
(desktop-save): Use dired-directory as name
Richard M. Stallman <rms@gnu.org>
parents:
10777
diff
changeset
|
53 ;; To avoid saving excessive amounts of data you may also wish to add |
5465
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
54 ;; something like the following |
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
55 ;; |
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
56 ;; (add-hook 'kill-emacs-hook |
5788
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
57 ;; '(lambda () |
5465
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
58 ;; (desktop-truncate search-ring 3) |
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
59 ;; (desktop-truncate regexp-search-ring 3))) |
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
60 ;; |
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
61 ;; which will make sure that no more than three search items are saved. You |
28719
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
62 ;; must place this line *after* the `(desktop-load-default)' line. See also |
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
63 ;; the variable `desktop-save-hook'. |
3404 | 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 |
28719
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
74 ;; Some words on minor modes: Most minor modes are controlled by |
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
75 ;; buffer-local variables, which have a standard save / restore |
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
76 ;; mechanism. To handle all minor modes, we take the following |
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
77 ;; approach: (1) check whether the variable name from |
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
78 ;; `minor-mode-alist' is also a function; and (2) use translation |
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
79 ;; table `desktop-minor-mode-table' in the case where the two names |
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
80 ;; are not the same. |
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
81 |
5465
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
82 ;; 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
|
83 ;; 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
|
84 ;; 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
|
85 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
86 ;; 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
|
87 ;; `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
|
88 ;; 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
|
89 |
7240
195e64dad1eb
(desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents:
7200
diff
changeset
|
90 ;; 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
|
91 ;; 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
|
92 ;; 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
|
93 ;; 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
|
94 ;; kifer@sbkifer.cs.sunysb.edu (M. Kifer) for a bug hunt. |
11224
f7f101a90cd4
(desktop-save): Use dired-directory as name
Richard M. Stallman <rms@gnu.org>
parents:
10777
diff
changeset
|
95 ;; treese@lcs.mit.edu (Win Treese) for ange-ftp tips. |
14172
da563949c7d7
(desktop-read): Do nothing in batch mode.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
96 ;; pot@cnuce.cnr.it (Francesco Potorti`) for misc. tips. |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
97 ;; --------------------------------------------------------------------------- |
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
98 ;; TODO: |
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
99 ;; |
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
100 ;; Save window configuration. |
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
101 ;; Recognize more minor modes. |
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
102 ;; Save mark rings. |
3404 | 103 |
104 ;;; Code: | |
105 | |
5465
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
106 ;; Make the compilation more silent |
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
107 (eval-when-compile |
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
108 ;; We use functions from these modules |
7240
195e64dad1eb
(desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents:
7200
diff
changeset
|
109 ;; We can't (require 'mh-e) since that wants to load something. |
195e64dad1eb
(desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents:
7200
diff
changeset
|
110 (mapcar 'require '(info dired reporter))) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
111 |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
112 (defvar desktop-file-version "206" |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
113 "Verion number of desktop file format. |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
114 Written into the desktop file and used at desktop read to provide |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
115 backward compatibility.") |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
116 |
5465
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
117 ;; ---------------------------------------------------------------------------- |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
118 ;; 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
|
119 ;; ---------------------------------------------------------------------------- |
17411
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17204
diff
changeset
|
120 |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17204
diff
changeset
|
121 (defgroup desktop nil |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17204
diff
changeset
|
122 "Save status of Emacs when you exit." |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17204
diff
changeset
|
123 :group 'frames) |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17204
diff
changeset
|
124 |
20526
ec0a8ccddd6c
(desktop-enable): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18581
diff
changeset
|
125 (defcustom desktop-enable nil |
ec0a8ccddd6c
(desktop-enable): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18581
diff
changeset
|
126 "*Non-nil enable Desktop to save the state of Emacs when you exit." |
ec0a8ccddd6c
(desktop-enable): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18581
diff
changeset
|
127 :group 'desktop |
ec0a8ccddd6c
(desktop-enable): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18581
diff
changeset
|
128 :type 'boolean |
ec0a8ccddd6c
(desktop-enable): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18581
diff
changeset
|
129 :require 'desktop |
21669
9861518505cb
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21316
diff
changeset
|
130 :initialize 'custom-initialize-default |
9861518505cb
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21316
diff
changeset
|
131 :version "20.3") |
20526
ec0a8ccddd6c
(desktop-enable): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18581
diff
changeset
|
132 |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
133 (defcustom desktop-save 'ask-if-new |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
134 "*When the user changes desktop or quits emacs, should the desktop be saved? |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
135 \(in the current desktop directory) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
136 t -- always save. |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
137 ask -- always ask. |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
138 ask-if-new -- ask if no desktop file exists, otherwise just save. |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
139 ask-if-exists -- ask if desktop file exists, otherwise don't save. |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
140 if-exists -- save if desktop file exists, otherwise don't save. |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
141 nil -- never save. |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
142 The desktop is never saved when `desktop-enable' is nil." |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
143 :type '(choice |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
144 (const :tag "Always save" t) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
145 (const :tag "Always ask" ask) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
146 (const :tag "Ask if desktop file is new, else do save" ask-if-new) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
147 (const :tag "Ask if desktop file exists, else don't save" ask-if-exists) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
148 (const :tag "Save if desktop file exists, else don't" if-exists) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
149 (const :tag "Never save" nil)) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
150 :group 'desktop) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
151 |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
152 (defcustom desktop-base-file-name |
16037
a1e88c05b53c
(desktop-basefilename): Use convert-standard-filename.
Richard M. Stallman <rms@gnu.org>
parents:
14756
diff
changeset
|
153 (convert-standard-filename ".emacs.desktop") |
20526
ec0a8ccddd6c
(desktop-enable): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18581
diff
changeset
|
154 "File for Emacs desktop, not including the directory name." |
ec0a8ccddd6c
(desktop-enable): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18581
diff
changeset
|
155 :type 'file |
ec0a8ccddd6c
(desktop-enable): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18581
diff
changeset
|
156 :group 'desktop) |
50583
aea857f85930
(desktop-base-file-name): Renamed from desktop-basefilename. Add defvaralias.
Richard M. Stallman <rms@gnu.org>
parents:
50532
diff
changeset
|
157 (defvaralias 'desktop-basefilename 'desktop-base-file-name) |
3404 | 158 |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
159 (defcustom desktop-path '("." "~") |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
160 "List of directories to search for the desktop file. |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
161 The base name of the file is specified in `desktop-base-file-name'." |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
162 :type '(repeat directory) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
163 :group 'desktop) |
3404 | 164 |
17411
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17204
diff
changeset
|
165 (defcustom desktop-missing-file-warning nil |
10595 | 166 "*If non-nil then desktop warns when a file no longer exists. |
17411
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17204
diff
changeset
|
167 Otherwise it simply ignores that file." |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17204
diff
changeset
|
168 :type 'boolean |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17204
diff
changeset
|
169 :group 'desktop) |
3404 | 170 |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
171 (defcustom desktop-no-desktop-file-hook nil |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
172 "Normal hook run after fail of `desktop-read' due to missing desktop file. |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
173 May e.g. be used to show a dired buffer." |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
174 :type 'hook |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
175 :group 'desktop) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
176 |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
177 (defcustom desktop-after-read-hook nil |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
178 "Normal hook run after a sucessful `desktop-read'. |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
179 May e.g. be used to show a buffer list." |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
180 :type 'hook |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
181 :group 'desktop) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
182 |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
183 (defcustom desktop-save-hook nil |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
184 "Hook run before desktop saves the state of Emacs. |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
185 This is useful for truncating history lists, for example." |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
186 :type 'hook |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
187 :group 'desktop) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
188 |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
189 (defcustom desktop-globals-to-save '( |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
190 desktop-missing-file-warning |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
191 tags-file-name |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
192 tags-table-list |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
193 search-ring |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
194 regexp-search-ring |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
195 register-alist) |
13154
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
196 "List of global variables to save when killing Emacs. |
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
197 An element may be variable name (a symbol) |
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
198 or a cons cell of the form (VAR . MAX-SIZE), |
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
199 which means to truncate VAR's value to at most MAX-SIZE elements |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
200 \(if the value is a list) before saving the value. |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
201 Feature: Saving `kill-ring' implies saving `kill-ring-yank-pointer'." |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
202 :type '(repeat (restricted-sexp :match-alternatives (symbolp consp))) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
203 :group 'desktop) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
204 |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
205 (defcustom desktop-globals-to-clear '( |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
206 kill-ring |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
207 kill-ring-yank-pointer |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
208 search-ring |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
209 search-ring-yank-pointer |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
210 regexp-search-ring |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
211 regexp-search-ring-yank-pointer) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
212 "List of global variables set to clear by `desktop-clear'. |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
213 An element may be variable name (a symbol) or a cons cell of the form |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
214 \(VAR . FORM). Symbols are set to nil and for cons cells VAR is set |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
215 to the value obtained by evaluateing FORM." |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
216 :type '(repeat (restricted-sexp :match-alternatives (symbolp consp))) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
217 :group 'desktop) |
3404 | 218 |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
219 (defcustom desktop-clear-preserve-buffers-regexp |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
220 "^\\*tramp/.+\\*$" |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
221 "Regexp identifying buffers that `desktop-clear' should not delete." |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
222 :type 'regexp |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
223 :group 'desktop) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
224 |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
225 ;; Maintained for backward compatibility |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
226 (defcustom desktop-clear-preserve-buffers |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
227 '("*scratch*" "*Messages*") |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
228 "*List of buffer names that `desktop-clear' should not delete." |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
229 :type '(repeat string) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
230 :group 'desktop) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
231 |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
232 (defvar desktop-locals-to-save '( |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
233 desktop-locals-to-save ; Itself! Think it over. |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
234 truncate-lines |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
235 case-fold-search |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
236 case-replace |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
237 fill-column |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
238 overwrite-mode |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
239 change-log-default-name |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
240 line-number-mode) |
10595 | 241 "List of local variables to save for each buffer. |
242 The variables are saved only when they really are local.") | |
5788
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
243 (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
|
244 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
245 ;; We skip .log files because they are normally temporary. |
14040 | 246 ;; (ftp) files because they require passwords and whatnot. |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
247 ;; TAGS files to save time (tags-file-name is saved instead). |
17411
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17204
diff
changeset
|
248 (defcustom desktop-buffers-not-to-save |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
249 "\\(^nn\\.a[0-9]+\\|\\.log\\|(ftp)\\|^tags\\|^TAGS\\)$" |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
250 "Regexp identifying buffers that are to be excluded from saving." |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
251 :type 'regexp |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
252 :group 'desktop) |
3404 | 253 |
7240
195e64dad1eb
(desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents:
7200
diff
changeset
|
254 ;; Skip ange-ftp files |
17411
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17204
diff
changeset
|
255 (defcustom desktop-files-not-to-save |
7240
195e64dad1eb
(desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents:
7200
diff
changeset
|
256 "^/[^/:]*:" |
17411
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17204
diff
changeset
|
257 "Regexp identifying files whose buffers are to be excluded from saving." |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17204
diff
changeset
|
258 :type 'regexp |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17204
diff
changeset
|
259 :group 'desktop) |
7240
195e64dad1eb
(desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents:
7200
diff
changeset
|
260 |
32447
cfae1c82d702
Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents:
32366
diff
changeset
|
261 (defcustom desktop-buffer-modes-to-save |
cfae1c82d702
Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents:
32366
diff
changeset
|
262 '(Info-mode rmail-mode) |
cfae1c82d702
Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents:
32366
diff
changeset
|
263 "If a buffer is of one of these major modes, save the buffer name. |
cfae1c82d702
Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents:
32366
diff
changeset
|
264 It is up to the functions in `desktop-buffer-handlers' to decide |
cfae1c82d702
Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents:
32366
diff
changeset
|
265 whether the buffer should be recreated or not, and how." |
cfae1c82d702
Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents:
32366
diff
changeset
|
266 :type '(repeat symbol) |
cfae1c82d702
Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents:
32366
diff
changeset
|
267 :group 'desktop) |
cfae1c82d702
Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents:
32366
diff
changeset
|
268 |
32366
40d8b29df57e
(desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30853
diff
changeset
|
269 (defcustom desktop-modes-not-to-save nil |
40d8b29df57e
(desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30853
diff
changeset
|
270 "List of major modes whose buffers should not be saved." |
40d8b29df57e
(desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30853
diff
changeset
|
271 :type '(repeat symbol) |
40d8b29df57e
(desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30853
diff
changeset
|
272 :group 'desktop) |
40d8b29df57e
(desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30853
diff
changeset
|
273 |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
274 (defcustom desktop-file-name-format 'absolute |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
275 "*Format in which desktop file names should be saved. |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
276 Possible values are: |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
277 absolute -- Absolute file name. |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
278 tilde -- Relative to ~. |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
279 local -- Relative to directory of desktop file." |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
280 :type '(choice (const absolute) (const tilde) (const local)) |
17411
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17204
diff
changeset
|
281 :group 'desktop) |
14755
3d473ed8c718
Global vars mam, fn, bn renamed.
Richard M. Stallman <rms@gnu.org>
parents:
14754
diff
changeset
|
282 |
32447
cfae1c82d702
Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents:
32366
diff
changeset
|
283 (defcustom desktop-buffer-misc-functions |
cfae1c82d702
Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents:
32366
diff
changeset
|
284 '(desktop-buffer-info-misc-data |
cfae1c82d702
Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents:
32366
diff
changeset
|
285 desktop-buffer-dired-misc-data) |
cfae1c82d702
Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents:
32366
diff
changeset
|
286 "*Functions used to determine auxiliary information for a buffer. |
cfae1c82d702
Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents:
32366
diff
changeset
|
287 These functions are called in order, with no arguments. If a function |
cfae1c82d702
Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents:
32366
diff
changeset
|
288 returns non-nil, its value is saved along with the desktop buffer for |
cfae1c82d702
Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents:
32366
diff
changeset
|
289 which it was called; no further functions will be called. |
cfae1c82d702
Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents:
32366
diff
changeset
|
290 |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
291 File names should formatted using the call |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
292 \"(desktop-file-name FILE-NAME dirname)\". |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
293 |
32447
cfae1c82d702
Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents:
32366
diff
changeset
|
294 Later, when desktop.el restores the buffers it has saved, each of the |
cfae1c82d702
Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents:
32366
diff
changeset
|
295 `desktop-buffer-handlers' functions will have access to a buffer local |
cfae1c82d702
Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents:
32366
diff
changeset
|
296 variable, named `desktop-buffer-misc', whose value is what the |
cfae1c82d702
Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents:
32366
diff
changeset
|
297 \"misc\" function returned previously." |
cfae1c82d702
Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents:
32366
diff
changeset
|
298 :type '(repeat function) |
cfae1c82d702
Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents:
32366
diff
changeset
|
299 :group 'desktop) |
cfae1c82d702
Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents:
32366
diff
changeset
|
300 |
17411
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17204
diff
changeset
|
301 (defcustom desktop-buffer-handlers |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
302 '(desktop-buffer-dired |
3404 | 303 desktop-buffer-rmail |
5465
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
304 desktop-buffer-mh |
3404 | 305 desktop-buffer-info |
306 desktop-buffer-file) | |
10595 | 307 "*List of functions to call in order to create a buffer. |
14755
3d473ed8c718
Global vars mam, fn, bn renamed.
Richard M. Stallman <rms@gnu.org>
parents:
14754
diff
changeset
|
308 The functions are called without explicit parameters but can use the |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
309 following variables: |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
310 |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
311 desktop-file-version |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
312 desktop-buffer-file-name |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
313 desktop-buffer-name |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
314 desktop-buffer-major-mode |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
315 desktop-buffer-minor-modes |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
316 desktop-buffer-point |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
317 desktop-buffer-mark |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
318 desktop-buffer-read-only |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
319 desktop-buffer-misc |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
320 desktop-buffer-locals |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
321 |
14755
3d473ed8c718
Global vars mam, fn, bn renamed.
Richard M. Stallman <rms@gnu.org>
parents:
14754
diff
changeset
|
322 If one function returns non-nil, no further functions are called. |
43831
7837693f5bac
(desktop-buffer-handlers): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
41150
diff
changeset
|
323 If the function returns a buffer, then the saved mode settings |
7837693f5bac
(desktop-buffer-handlers): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
41150
diff
changeset
|
324 and variable values for that buffer are copied into it." |
17411
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17204
diff
changeset
|
325 :type '(repeat function) |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17204
diff
changeset
|
326 :group 'desktop) |
5465
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
327 |
32447
cfae1c82d702
Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents:
32366
diff
changeset
|
328 (put 'desktop-buffer-handlers 'risky-local-variable t) |
cfae1c82d702
Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents:
32366
diff
changeset
|
329 |
28719
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
330 (defcustom desktop-minor-mode-table |
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
331 '((auto-fill-function auto-fill-mode) |
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
332 (vc-mode nil)) |
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
333 "Table mapping minor mode variables to minor mode functions. |
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
334 Each entry has the form (NAME RESTORE-FUNCTION). |
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
335 NAME is the name of the buffer-local variable indicating that the minor |
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
336 mode is active. RESTORE-FUNCTION is the function to activate the minor mode. |
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
337 called. RESTORE-FUNCTION nil means don't try to restore the minor mode. |
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
338 Only minor modes for which the name of the buffer-local variable |
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
339 and the name of the minor mode function are different have to added to |
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
340 this table." |
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
341 :type 'sexp |
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
342 :group 'desktop) |
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
343 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
344 ;; ---------------------------------------------------------------------------- |
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
345 (defvar desktop-dirname nil |
3404 | 346 "The directory in which the current desktop file resides.") |
347 | |
348 (defconst desktop-header | |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
349 ";; -------------------------------------------------------------------------- |
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
350 ;; Desktop File for Emacs |
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
351 ;; -------------------------------------------------------------------------- |
3404 | 352 " "*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
|
353 |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
354 (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
|
355 "Hooks run after all buffers are loaded; intended for internal use.") |
20526
ec0a8ccddd6c
(desktop-enable): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18581
diff
changeset
|
356 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
357 ;; ---------------------------------------------------------------------------- |
5465
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
358 (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
|
359 "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
|
360 (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
|
361 (if (consp here) |
5788
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
362 (setcdr here nil)))) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
363 |
5465
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
364 ;; ---------------------------------------------------------------------------- |
18581
45f27efe77c7
(desktop-clear-preserve-buffers): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18527
diff
changeset
|
365 (defun desktop-clear () |
45f27efe77c7
(desktop-clear-preserve-buffers): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18527
diff
changeset
|
366 "Empty the Desktop. |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
367 This kills all buffers except for internal ones and those listed |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
368 in `desktop-clear-preserve-buffers'. Furthermore, it clears the |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
369 variables listed in `desktop-globals-to-clear'." |
3404 | 370 (interactive) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
371 (dolist (var desktop-globals-to-clear) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
372 (if (symbolp var) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
373 (eval `(setq-default ,var nil)) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
374 (eval `(setq-default ,(car var) ,(cdr var))))) |
18581
45f27efe77c7
(desktop-clear-preserve-buffers): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18527
diff
changeset
|
375 (let ((buffers (buffer-list))) |
45f27efe77c7
(desktop-clear-preserve-buffers): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18527
diff
changeset
|
376 (while buffers |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
377 (let ((bufname (buffer-name (car buffers)))) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
378 (or |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
379 (null bufname) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
380 (string-match desktop-clear-preserve-buffers-regexp bufname) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
381 (member bufname desktop-clear-preserve-buffers) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
382 ;; Don't kill buffers made for internal purposes. |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
383 (and (not (equal bufname "")) (eq (aref bufname 0) ?\ )) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
384 (kill-buffer (car buffers)))) |
18581
45f27efe77c7
(desktop-clear-preserve-buffers): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18527
diff
changeset
|
385 (setq buffers (cdr buffers)))) |
5314 | 386 (delete-other-windows)) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
387 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
388 ;; ---------------------------------------------------------------------------- |
5788
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
389 (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
|
390 |
3404 | 391 (defun desktop-kill () |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
392 "If `desktop-enable' is non-nil, do what `desktop-save' says to do. |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
393 If the desktop should be saved and `desktop-dirname' |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
394 is nil, ask the user where to save the desktop." |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
395 (when |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
396 (and |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
397 desktop-enable |
51441
b9a57b098ab3
(desktop-create-buffer): Undo last change.
Juanma Barranquero <lekktu@gmail.com>
parents:
51378
diff
changeset
|
398 (let ((exists (file-exists-p (expand-file-name desktop-base-file-name desktop-dirname)))) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
399 (or |
88123 | 400 (eq desktop-save 't) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
401 (and exists (memq desktop-save '(ask-if-new if-exists))) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
402 (and |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
403 (or |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
404 (memq desktop-save '(ask ask-if-new)) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
405 (and exists (eq desktop-save 'ask-if-exists))) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
406 (y-or-n-p "Save desktop? "))))) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
407 (unless desktop-dirname |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
408 (setq desktop-dirname |
51441
b9a57b098ab3
(desktop-create-buffer): Undo last change.
Juanma Barranquero <lekktu@gmail.com>
parents:
51378
diff
changeset
|
409 (file-name-as-directory |
b9a57b098ab3
(desktop-create-buffer): Undo last change.
Juanma Barranquero <lekktu@gmail.com>
parents:
51378
diff
changeset
|
410 (expand-file-name |
b9a57b098ab3
(desktop-create-buffer): Undo last change.
Juanma Barranquero <lekktu@gmail.com>
parents:
51378
diff
changeset
|
411 (call-interactively |
b9a57b098ab3
(desktop-create-buffer): Undo last change.
Juanma Barranquero <lekktu@gmail.com>
parents:
51378
diff
changeset
|
412 (lambda (dir) (interactive "DDirectory for desktop file: ") dir)))))) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
413 (condition-case err |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
414 (desktop-save desktop-dirname) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
415 (file-error |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
416 (unless (yes-or-no-p "Error while saving the desktop. Ignore? ") |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
417 (signal (car err) (cdr err))))))) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
418 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
419 ;; ---------------------------------------------------------------------------- |
14754
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
420 (defun desktop-list* (&rest args) |
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
421 (if (null (cdr args)) |
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
422 (car args) |
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
423 (setq args (nreverse args)) |
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
424 (let ((value (cons (nth 1 args) (car args)))) |
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
425 (setq args (cdr (cdr args))) |
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
426 (while args |
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
427 (setq value (cons (car args) value)) |
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
428 (setq args (cdr args))) |
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
429 value))) |
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
430 |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
431 ;; ---------------------------------------------------------------------------- |
5788
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
432 (defun desktop-internal-v2s (val) |
10595 | 433 "Convert VALUE to a pair (QUOTE . TXT); (eval (read TXT)) gives VALUE. |
434 TXT is a string that when read and evaluated yields value. | |
435 QUOTE may be `may' (value may be quoted), | |
436 `must' (values must be quoted), or nil (value may not be quoted)." | |
5788
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
437 (cond |
9521
d53ed4fd05ca
(desktop-internal-v2s): Remove all text properties from strings.
Richard M. Stallman <rms@gnu.org>
parents:
8152
diff
changeset
|
438 ((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
|
439 (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
|
440 ((stringp val) |
10777
9f4a9820fea1
(desktop-internal-v2s): Don't use format to eliminate text properties.
Richard M. Stallman <rms@gnu.org>
parents:
10595
diff
changeset
|
441 (let ((copy (copy-sequence val))) |
9f4a9820fea1
(desktop-internal-v2s): Don't use format to eliminate text properties.
Richard M. Stallman <rms@gnu.org>
parents:
10595
diff
changeset
|
442 (set-text-properties 0 (length copy) nil copy) |
9f4a9820fea1
(desktop-internal-v2s): Don't use format to eliminate text properties.
Richard M. Stallman <rms@gnu.org>
parents:
10595
diff
changeset
|
443 ;; Get rid of text properties because we cannot read them |
9f4a9820fea1
(desktop-internal-v2s): Don't use format to eliminate text properties.
Richard M. Stallman <rms@gnu.org>
parents:
10595
diff
changeset
|
444 (cons 'may (prin1-to-string copy)))) |
5788
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
445 ((symbolp val) |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
446 (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
|
447 ((vectorp val) |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
448 (let* ((special nil) |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
449 (pass1 (mapcar |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
450 (lambda (el) |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
451 (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
|
452 (if (null (car res)) |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
453 (setq special t)) |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
454 res)) |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
455 val))) |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
456 (if special |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
457 (cons nil (concat "(vector " |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
458 (mapconcat (lambda (el) |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
459 (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
|
460 (concat "'" (cdr el)) |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
461 (cdr el))) |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
462 pass1 |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
463 " ") |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
464 ")")) |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
465 (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
|
466 ((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
|
467 (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
|
468 newlist |
14754
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
469 use-list* |
7200
eabd5e6e95de
(desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents:
7091
diff
changeset
|
470 anynil) |
eabd5e6e95de
(desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents:
7091
diff
changeset
|
471 (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
|
472 (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
|
473 (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
|
474 (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
|
475 (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
|
476 (if p |
eabd5e6e95de
(desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents:
7091
diff
changeset
|
477 (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
|
478 (el (car newlist))) |
14754
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
479 (or anynil (setq anynil (null (car last)))) |
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
480 (or anynil |
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
481 (setq newlist (cons '(must . ".") newlist))) |
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
482 (setq use-list* t) |
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
483 (setq newlist (cons last newlist)))) |
7200
eabd5e6e95de
(desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents:
7091
diff
changeset
|
484 (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
|
485 (if anynil |
eabd5e6e95de
(desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents:
7091
diff
changeset
|
486 (cons nil |
14754
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
487 (concat (if use-list* "(desktop-list* " "(list ") |
7200
eabd5e6e95de
(desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents:
7091
diff
changeset
|
488 (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
|
489 (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
|
490 (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
|
491 (cdr el))) |
eabd5e6e95de
(desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents:
7091
diff
changeset
|
492 newlist |
eabd5e6e95de
(desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents:
7091
diff
changeset
|
493 " ") |
eabd5e6e95de
(desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents:
7091
diff
changeset
|
494 ")")) |
eabd5e6e95de
(desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents:
7091
diff
changeset
|
495 (cons 'must |
eabd5e6e95de
(desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents:
7091
diff
changeset
|
496 (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
|
497 ((subrp val) |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
498 (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
|
499 (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
|
500 ")"))) |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
501 ((markerp val) |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
502 (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
|
503 (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
|
504 (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
|
505 " (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
|
506 " (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
|
507 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
|
508 (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
|
509 (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
|
510 |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
511 ;; ---------------------------------------------------------------------------- |
5465
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
512 (defun desktop-value-to-string (val) |
10595 | 513 "Convert VALUE to a string that when read evaluates to the same value. |
514 Not all types of values are supported." | |
5788
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
515 (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
|
516 (float-output-format nil) |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
517 (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
|
518 (quote (car quote.txt)) |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
519 (txt (cdr quote.txt))) |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
520 (if (eq quote 'must) |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
521 (concat "'" txt) |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
522 txt))) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
523 |
5465
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
524 ;; ---------------------------------------------------------------------------- |
13154
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
525 (defun desktop-outvar (varspec) |
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
526 "Output a setq statement for variable VAR to the desktop file. |
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
527 The argument VARSPEC may be the variable name VAR (a symbol), |
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
528 or a cons cell of the form (VAR . MAX-SIZE), |
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
529 which means to truncate VAR's value to at most MAX-SIZE elements |
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
530 \(if the value is a list) before saving the value." |
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
531 (let (var size) |
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
532 (if (consp varspec) |
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
533 (setq var (car varspec) size (cdr varspec)) |
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
534 (setq var varspec)) |
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
535 (if (boundp var) |
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
536 (progn |
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
537 (if (and (integerp size) |
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
538 (> size 0) |
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
539 (listp (eval var))) |
28719
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
540 (desktop-truncate (eval var) size)) |
13154
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
541 (insert "(setq " |
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
542 (symbol-name var) |
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
543 " " |
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
544 (desktop-value-to-string (symbol-value var)) |
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
545 ")\n"))))) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
546 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
547 ;; ---------------------------------------------------------------------------- |
5465
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
548 (defun desktop-save-buffer-p (filename bufname mode &rest dummy) |
5314 | 549 "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
|
550 FILENAME is the visited file name, BUFNAME is the buffer name, and |
3404 | 551 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
|
552 (let ((case-fold-search nil)) |
32366
40d8b29df57e
(desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30853
diff
changeset
|
553 (and (not (string-match desktop-buffers-not-to-save bufname)) |
40d8b29df57e
(desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30853
diff
changeset
|
554 (not (memq mode desktop-modes-not-to-save)) |
40d8b29df57e
(desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30853
diff
changeset
|
555 (or (and filename |
40d8b29df57e
(desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30853
diff
changeset
|
556 (not (string-match desktop-files-not-to-save filename))) |
40d8b29df57e
(desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30853
diff
changeset
|
557 (and (eq mode 'dired-mode) |
40d8b29df57e
(desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30853
diff
changeset
|
558 (save-excursion |
40d8b29df57e
(desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30853
diff
changeset
|
559 (set-buffer (get-buffer bufname)) |
40d8b29df57e
(desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30853
diff
changeset
|
560 (not (string-match desktop-files-not-to-save |
40d8b29df57e
(desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30853
diff
changeset
|
561 default-directory)))) |
40d8b29df57e
(desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30853
diff
changeset
|
562 (and (null filename) |
32447
cfae1c82d702
Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents:
32366
diff
changeset
|
563 (memq mode desktop-buffer-modes-to-save)))))) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
564 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
565 ;; ---------------------------------------------------------------------------- |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
566 (defun desktop-file-name (filename dirname) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
567 "Convert FILENAME to format specified in `desktop-file-name-format'. |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
568 DIRNAME must be the directory in which the desktop file will be saved." |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
569 (cond |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
570 ((not filename) nil) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
571 ((eq desktop-file-name-format 'tilde) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
572 (let ((relative-name (file-relative-name (expand-file-name filename) "~"))) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
573 (cond |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
574 ((file-name-absolute-p relative-name) relative-name) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
575 ((string= "./" relative-name) "~/") |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
576 ((string= "." relative-name) "~") |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
577 (t (concat "~/" relative-name))))) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
578 ((eq desktop-file-name-format 'local) (file-relative-name filename dirname)) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
579 (t (expand-file-name filename)))) |
48143
8c7919f99581
(desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents:
43831
diff
changeset
|
580 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
581 ;; ---------------------------------------------------------------------------- |
3404 | 582 (defun desktop-save (dirname) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
583 "Save the Desktop file. Parameter DIRNAME specifies where to save desktop." |
3404 | 584 (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
|
585 (run-hooks 'desktop-save-hook) |
51107
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
586 (setq dirname (file-name-as-directory (expand-file-name dirname))) |
3404 | 587 (save-excursion |
51441
b9a57b098ab3
(desktop-create-buffer): Undo last change.
Juanma Barranquero <lekktu@gmail.com>
parents:
51378
diff
changeset
|
588 (let ((filename (expand-file-name desktop-base-file-name dirname)) |
51107
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
589 (info |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
590 (mapcar |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
591 (function |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
592 (lambda (b) |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
593 (set-buffer b) |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
594 (list |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
595 (desktop-file-name (buffer-file-name) dirname) |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
596 (buffer-name) |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
597 major-mode |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
598 ;; minor modes |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
599 (let (ret) |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
600 (mapcar |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
601 #'(lambda (mim) |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
602 (and |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
603 (boundp mim) |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
604 (symbol-value mim) |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
605 (setq ret |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
606 (cons |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
607 (let ((special (assq mim desktop-minor-mode-table))) |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
608 (if special (cadr special) mim)) |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
609 ret)))) |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
610 (mapcar #'car minor-mode-alist)) |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
611 ret) |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
612 (point) |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
613 (list (mark t) mark-active) |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
614 buffer-read-only |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
615 (run-hook-with-args-until-success 'desktop-buffer-misc-functions) |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
616 (let ((locals desktop-locals-to-save) |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
617 (loclist (buffer-local-variables)) |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
618 (ll)) |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
619 (while locals |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
620 (let ((here (assq (car locals) loclist))) |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
621 (if here |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
622 (setq ll (cons here ll)) |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
623 (when (member (car locals) loclist) |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
624 (setq ll (cons (car locals) ll))))) |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
625 (setq locals (cdr locals))) |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
626 ll)))) |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
627 (buffer-list))) |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
628 (buf (get-buffer-create "*desktop*"))) |
3404 | 629 (set-buffer buf) |
630 (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
|
631 |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
632 (insert |
89483 | 633 ";; -*- coding: utf-8-emacs; -*-\n" |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
634 desktop-header |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
635 ";; Created " (current-time-string) "\n" |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
636 ";; Desktop file format version " desktop-file-version "\n" |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
637 ";; Emacs version " emacs-version "\n\n" |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
638 ";; Global section:\n") |
3404 | 639 (mapcar (function desktop-outvar) desktop-globals-to-save) |
640 (if (memq 'kill-ring desktop-globals-to-save) | |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
641 (insert |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
642 "(setq kill-ring-yank-pointer (nthcdr " |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
643 (int-to-string (- (length kill-ring) (length kill-ring-yank-pointer))) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
644 " kill-ring))\n")) |
3404 | 645 |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
646 (insert "\n;; Buffer section -- buffers listed in same order as in buffer list:\n") |
5788
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
647 (mapcar |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
648 (function |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
649 (lambda (l) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
650 (if (apply 'desktop-save-buffer-p l) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
651 (progn |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
652 (insert "(desktop-create-buffer " desktop-file-version) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
653 (mapcar |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
654 (function |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
655 (lambda (e) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
656 (insert "\n " (desktop-value-to-string e)))) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
657 l) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
658 (insert ")\n\n"))))) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
659 info) |
3404 | 660 (setq default-directory dirname) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
661 (when (file-exists-p filename) (delete-file filename)) |
88659
76e06537f60c
(desktop-save): Use utf-8-emacs coding system, not
Dave Love <fx@gnu.org>
parents:
41150
diff
changeset
|
662 (let ((coding-system-for-write 'utf-8-emacs)) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
663 (write-region (point-min) (point-max) filename nil 'nomessage)))) |
3404 | 664 (setq desktop-dirname dirname)) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
665 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
666 ;; ---------------------------------------------------------------------------- |
3404 | 667 (defun desktop-remove () |
668 "Delete the Desktop file and inactivate the desktop system." | |
669 (interactive) | |
670 (if desktop-dirname | |
51441
b9a57b098ab3
(desktop-create-buffer): Undo last change.
Juanma Barranquero <lekktu@gmail.com>
parents:
51378
diff
changeset
|
671 (let ((filename (expand-file-name desktop-base-file-name desktop-dirname))) |
b9a57b098ab3
(desktop-create-buffer): Undo last change.
Juanma Barranquero <lekktu@gmail.com>
parents:
51378
diff
changeset
|
672 (setq desktop-dirname nil) |
b9a57b098ab3
(desktop-create-buffer): Undo last change.
Juanma Barranquero <lekktu@gmail.com>
parents:
51378
diff
changeset
|
673 (if (file-exists-p filename) |
b9a57b098ab3
(desktop-create-buffer): Undo last change.
Juanma Barranquero <lekktu@gmail.com>
parents:
51378
diff
changeset
|
674 (delete-file filename))))) |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
675 ;; ---------------------------------------------------------------------------- |
21303
346595905ae4
(desktop-load-default): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents:
20772
diff
changeset
|
676 ;;;###autoload |
3404 | 677 (defun desktop-read () |
14172
da563949c7d7
(desktop-read): Do nothing in batch mode.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
678 "Read the Desktop file and the files it specifies. |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
679 This is a no-op when Emacs is running in batch mode. |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
680 Look for the desktop file according to the variables `desktop-base-file-name' |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
681 and `desktop-path'. If no desktop file is found, clear the desktop. |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
682 Returns t if it has read a desktop file, nil otherwise." |
3404 | 683 (interactive) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
684 (unless noninteractive |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
685 (let ((dirs desktop-path)) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
686 (while |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
687 (and |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
688 dirs |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
689 (not |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
690 (file-exists-p (expand-file-name desktop-base-file-name (car dirs))))) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
691 (setq dirs (cdr dirs))) |
51441
b9a57b098ab3
(desktop-create-buffer): Undo last change.
Juanma Barranquero <lekktu@gmail.com>
parents:
51378
diff
changeset
|
692 (setq desktop-dirname (and dirs (file-name-as-directory (expand-file-name (car dirs))))) |
14172
da563949c7d7
(desktop-read): Do nothing in batch mode.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
693 (if desktop-dirname |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
694 (let ((desktop-first-buffer nil)) |
51107
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
695 ;; Evaluate desktop buffer. |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
696 (load (expand-file-name desktop-base-file-name desktop-dirname) t t t) |
51107
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
697 ;; `desktop-create-buffer' puts buffers at end of the buffer list. |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
698 ;; We want buffers existing prior to evaluating the desktop (and not reused) |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
699 ;; to be placed at the end of the buffer list, so we move them here. |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
700 (mapcar 'bury-buffer |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
701 (nreverse (cdr (memq desktop-first-buffer (nreverse (buffer-list)))))) |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
702 (switch-to-buffer (car (buffer-list))) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
703 (run-hooks 'desktop-delay-hook) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
704 (setq desktop-delay-hook nil) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
705 (run-hooks 'desktop-after-read-hook) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
706 (message "Desktop loaded.") |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
707 t) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
708 (desktop-clear) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
709 (run-hooks 'desktop-no-desktop-file-hook) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
710 (message "No desktop file.") |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
711 nil)))) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
712 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
713 ;; ---------------------------------------------------------------------------- |
21303
346595905ae4
(desktop-load-default): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents:
20772
diff
changeset
|
714 ;;;###autoload |
3404 | 715 (defun desktop-load-default () |
10595 | 716 "Load the `default' start-up library manually. |
717 Also inhibit further loading of it. Call this from your `.emacs' file | |
718 to provide correct modes for autoloaded files." | |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
719 (if (not inhibit-default-init) ; safety check |
3404 | 720 (progn |
721 (load "default" t t) | |
722 (setq inhibit-default-init t)))) | |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
723 |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
724 ;; ---------------------------------------------------------------------------- |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
725 ;;;###autoload |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
726 (defun desktop-change-dir (dir) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
727 "Save and clear the desktop, then load the desktop from directory DIR. |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
728 However, if `desktop-enable' was nil at call, don't save the old desktop. |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
729 This function always sets `desktop-enable' to t." |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
730 (interactive "DNew directory: ") |
51441
b9a57b098ab3
(desktop-create-buffer): Undo last change.
Juanma Barranquero <lekktu@gmail.com>
parents:
51378
diff
changeset
|
731 (setq dir (file-name-as-directory (expand-file-name dir desktop-dirname))) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
732 (desktop-kill) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
733 (desktop-clear) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
734 (setq desktop-enable t) |
51441
b9a57b098ab3
(desktop-create-buffer): Undo last change.
Juanma Barranquero <lekktu@gmail.com>
parents:
51378
diff
changeset
|
735 (let ((desktop-path (list dir)) |
b9a57b098ab3
(desktop-create-buffer): Undo last change.
Juanma Barranquero <lekktu@gmail.com>
parents:
51378
diff
changeset
|
736 (default-directory dir)) |
b9a57b098ab3
(desktop-create-buffer): Undo last change.
Juanma Barranquero <lekktu@gmail.com>
parents:
51378
diff
changeset
|
737 (desktop-read)) |
b9a57b098ab3
(desktop-create-buffer): Undo last change.
Juanma Barranquero <lekktu@gmail.com>
parents:
51378
diff
changeset
|
738 ;; Set `desktop-dirname' even in no desktop file was found |
b9a57b098ab3
(desktop-create-buffer): Undo last change.
Juanma Barranquero <lekktu@gmail.com>
parents:
51378
diff
changeset
|
739 (setq desktop-dirname dir)) |
b9a57b098ab3
(desktop-create-buffer): Undo last change.
Juanma Barranquero <lekktu@gmail.com>
parents:
51378
diff
changeset
|
740 ;; ---------------------------------------------------------------------------- |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
741 ;;;###autoload |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
742 (defun desktop-save-in-load-dir () |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
743 "Save desktop in directory from which it was loaded." |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
744 (interactive) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
745 (if desktop-dirname |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
746 (desktop-save desktop-dirname) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
747 (call-interactively 'desktop-save)) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
748 (message "Desktop saved in %s" desktop-dirname)) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
749 |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
750 ;; ---------------------------------------------------------------------------- |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
751 ;;;###autoload |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
752 (defun desktop-revert () |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
753 "Revert to the last loaded desktop." |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
754 (interactive) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
755 (unless desktop-dirname (error "No desktop has been loaded")) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
756 (setq desktop-enable nil) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
757 (desktop-change-dir desktop-dirname)) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
758 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
759 ;; ---------------------------------------------------------------------------- |
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
760 ;; 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
|
761 ;; |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
762 |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
763 (eval-when-compile ; Just to silence the byte compiler |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
764 (defvar desktop-file-version) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
765 (defvar desktop-buffer-file-name) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
766 (defvar desktop-buffer-name) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
767 (defvar desktop-buffer-major-mode) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
768 (defvar desktop-buffer-minor-modes) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
769 (defvar desktop-buffer-point) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
770 (defvar desktop-buffer-mark) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
771 (defvar desktop-buffer-read-only) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
772 (defvar desktop-buffer-misc) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
773 (defvar desktop-buffer-locals) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
774 ) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
775 |
32447
cfae1c82d702
Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents:
32366
diff
changeset
|
776 (defun desktop-buffer-info-misc-data () |
cfae1c82d702
Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents:
32366
diff
changeset
|
777 (if (eq major-mode 'Info-mode) |
cfae1c82d702
Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents:
32366
diff
changeset
|
778 (list Info-current-file |
cfae1c82d702
Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents:
32366
diff
changeset
|
779 Info-current-node))) |
cfae1c82d702
Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents:
32366
diff
changeset
|
780 |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
781 ;; ---------------------------------------------------------------------------- |
32447
cfae1c82d702
Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents:
32366
diff
changeset
|
782 (defun desktop-buffer-dired-misc-data () |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
783 (when (eq major-mode 'dired-mode) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
784 (eval-when-compile (defvar dirname)) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
785 (cons |
51894
4dafe305a193
(desktop-buffer-dired-misc-data, desktop-buffer-dired): Handle `dired-directory'
Juanma Barranquero <lekktu@gmail.com>
parents:
51806
diff
changeset
|
786 ;; Value of `dired-directory'. |
4dafe305a193
(desktop-buffer-dired-misc-data, desktop-buffer-dired): Handle `dired-directory'
Juanma Barranquero <lekktu@gmail.com>
parents:
51806
diff
changeset
|
787 (if (consp dired-directory) |
4dafe305a193
(desktop-buffer-dired-misc-data, desktop-buffer-dired): Handle `dired-directory'
Juanma Barranquero <lekktu@gmail.com>
parents:
51806
diff
changeset
|
788 ;; Directory name followed by list of files. |
4dafe305a193
(desktop-buffer-dired-misc-data, desktop-buffer-dired): Handle `dired-directory'
Juanma Barranquero <lekktu@gmail.com>
parents:
51806
diff
changeset
|
789 (cons (desktop-file-name (car dired-directory) dirname) (cdr dired-directory)) |
4dafe305a193
(desktop-buffer-dired-misc-data, desktop-buffer-dired): Handle `dired-directory'
Juanma Barranquero <lekktu@gmail.com>
parents:
51806
diff
changeset
|
790 ;; Directory name, optionally with with shell wildcard. |
4dafe305a193
(desktop-buffer-dired-misc-data, desktop-buffer-dired): Handle `dired-directory'
Juanma Barranquero <lekktu@gmail.com>
parents:
51806
diff
changeset
|
791 (desktop-file-name dired-directory dirname)) |
4dafe305a193
(desktop-buffer-dired-misc-data, desktop-buffer-dired): Handle `dired-directory'
Juanma Barranquero <lekktu@gmail.com>
parents:
51806
diff
changeset
|
792 ;; Subdirectories in `dired-subdir-alist'. |
4dafe305a193
(desktop-buffer-dired-misc-data, desktop-buffer-dired): Handle `dired-directory'
Juanma Barranquero <lekktu@gmail.com>
parents:
51806
diff
changeset
|
793 (cdr |
4dafe305a193
(desktop-buffer-dired-misc-data, desktop-buffer-dired): Handle `dired-directory'
Juanma Barranquero <lekktu@gmail.com>
parents:
51806
diff
changeset
|
794 (nreverse |
4dafe305a193
(desktop-buffer-dired-misc-data, desktop-buffer-dired): Handle `dired-directory'
Juanma Barranquero <lekktu@gmail.com>
parents:
51806
diff
changeset
|
795 (mapcar |
4dafe305a193
(desktop-buffer-dired-misc-data, desktop-buffer-dired): Handle `dired-directory'
Juanma Barranquero <lekktu@gmail.com>
parents:
51806
diff
changeset
|
796 (function (lambda (f) (desktop-file-name (car f) dirname))) |
4dafe305a193
(desktop-buffer-dired-misc-data, desktop-buffer-dired): Handle `dired-directory'
Juanma Barranquero <lekktu@gmail.com>
parents:
51806
diff
changeset
|
797 dired-subdir-alist)))))) |
32447
cfae1c82d702
Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents:
32366
diff
changeset
|
798 |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
799 ;; ---------------------------------------------------------------------------- |
3404 | 800 (defun desktop-buffer-info () "Load an info file." |
14755
3d473ed8c718
Global vars mam, fn, bn renamed.
Richard M. Stallman <rms@gnu.org>
parents:
14754
diff
changeset
|
801 (if (eq 'Info-mode desktop-buffer-major-mode) |
3404 | 802 (progn |
32447
cfae1c82d702
Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents:
32366
diff
changeset
|
803 (let ((first (nth 0 desktop-buffer-misc)) |
cfae1c82d702
Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents:
32366
diff
changeset
|
804 (second (nth 1 desktop-buffer-misc))) |
cfae1c82d702
Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents:
32366
diff
changeset
|
805 (when (and first second) |
cfae1c82d702
Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents:
32366
diff
changeset
|
806 (require 'info) |
51806
96c06b458966
(desktop-buffer-info, desktop-buffer-mh): Use with-no-warnings.
Richard M. Stallman <rms@gnu.org>
parents:
51468
diff
changeset
|
807 (with-no-warnings |
96c06b458966
(desktop-buffer-info, desktop-buffer-mh): Use with-no-warnings.
Richard M. Stallman <rms@gnu.org>
parents:
51468
diff
changeset
|
808 (Info-find-node first second)) |
32447
cfae1c82d702
Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents:
32366
diff
changeset
|
809 (current-buffer)))))) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
810 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
811 ;; ---------------------------------------------------------------------------- |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
812 (eval-when-compile (defvar rmail-buffer)) ; Just to silence the byte compiler. |
5314 | 813 (defun desktop-buffer-rmail () "Load an RMAIL file." |
14755
3d473ed8c718
Global vars mam, fn, bn renamed.
Richard M. Stallman <rms@gnu.org>
parents:
14754
diff
changeset
|
814 (if (eq 'rmail-mode desktop-buffer-major-mode) |
8152
eecf5ae5a194
(desktop-buffer-rmail): Handle the situation
Richard M. Stallman <rms@gnu.org>
parents:
7240
diff
changeset
|
815 (condition-case error |
21316
8bfa13d10dd1
(desktop-buffer-info, desktop-buffer-rmail)
Richard M. Stallman <rms@gnu.org>
parents:
21303
diff
changeset
|
816 (progn (rmail-input desktop-buffer-file-name) |
8bfa13d10dd1
(desktop-buffer-info, desktop-buffer-rmail)
Richard M. Stallman <rms@gnu.org>
parents:
21303
diff
changeset
|
817 (if (eq major-mode 'rmail-mode) |
8bfa13d10dd1
(desktop-buffer-info, desktop-buffer-rmail)
Richard M. Stallman <rms@gnu.org>
parents:
21303
diff
changeset
|
818 (current-buffer) |
8bfa13d10dd1
(desktop-buffer-info, desktop-buffer-rmail)
Richard M. Stallman <rms@gnu.org>
parents:
21303
diff
changeset
|
819 rmail-buffer)) |
9521
d53ed4fd05ca
(desktop-internal-v2s): Remove all text properties from strings.
Richard M. Stallman <rms@gnu.org>
parents:
8152
diff
changeset
|
820 (file-locked |
d53ed4fd05ca
(desktop-internal-v2s): Remove all text properties from strings.
Richard M. Stallman <rms@gnu.org>
parents:
8152
diff
changeset
|
821 (kill-buffer (current-buffer)) |
d53ed4fd05ca
(desktop-internal-v2s): Remove all text properties from strings.
Richard M. Stallman <rms@gnu.org>
parents:
8152
diff
changeset
|
822 'ignored)))) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
823 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
824 ;; ---------------------------------------------------------------------------- |
5465
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
825 (defun desktop-buffer-mh () "Load a folder in the mh system." |
14755
3d473ed8c718
Global vars mam, fn, bn renamed.
Richard M. Stallman <rms@gnu.org>
parents:
14754
diff
changeset
|
826 (if (eq 'mh-folder-mode desktop-buffer-major-mode) |
51806
96c06b458966
(desktop-buffer-info, desktop-buffer-mh): Use with-no-warnings.
Richard M. Stallman <rms@gnu.org>
parents:
51468
diff
changeset
|
827 (with-no-warnings |
5465
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
828 (mh-find-path) |
21316
8bfa13d10dd1
(desktop-buffer-info, desktop-buffer-rmail)
Richard M. Stallman <rms@gnu.org>
parents:
21303
diff
changeset
|
829 (mh-visit-folder desktop-buffer-name) |
8bfa13d10dd1
(desktop-buffer-info, desktop-buffer-rmail)
Richard M. Stallman <rms@gnu.org>
parents:
21303
diff
changeset
|
830 (current-buffer)))) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
831 |
5465
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
832 ;; ---------------------------------------------------------------------------- |
3404 | 833 (defun desktop-buffer-dired () "Load a directory using dired." |
14755
3d473ed8c718
Global vars mam, fn, bn renamed.
Richard M. Stallman <rms@gnu.org>
parents:
14754
diff
changeset
|
834 (if (eq 'dired-mode desktop-buffer-major-mode) |
51894
4dafe305a193
(desktop-buffer-dired-misc-data, desktop-buffer-dired): Handle `dired-directory'
Juanma Barranquero <lekktu@gmail.com>
parents:
51806
diff
changeset
|
835 ;; First element of `desktop-buffer-misc' is the value of `dired-directory'. |
4dafe305a193
(desktop-buffer-dired-misc-data, desktop-buffer-dired): Handle `dired-directory'
Juanma Barranquero <lekktu@gmail.com>
parents:
51806
diff
changeset
|
836 ;; This value is a directory name, optionally with with shell wildcard or |
4dafe305a193
(desktop-buffer-dired-misc-data, desktop-buffer-dired): Handle `dired-directory'
Juanma Barranquero <lekktu@gmail.com>
parents:
51806
diff
changeset
|
837 ;; a directory name followed by list of files. |
4dafe305a193
(desktop-buffer-dired-misc-data, desktop-buffer-dired): Handle `dired-directory'
Juanma Barranquero <lekktu@gmail.com>
parents:
51806
diff
changeset
|
838 (let* ((dired-directory (car desktop-buffer-misc)) |
4dafe305a193
(desktop-buffer-dired-misc-data, desktop-buffer-dired): Handle `dired-directory'
Juanma Barranquero <lekktu@gmail.com>
parents:
51806
diff
changeset
|
839 (dir (if (consp dired-directory) (car dired-directory) dired-directory))) |
4dafe305a193
(desktop-buffer-dired-misc-data, desktop-buffer-dired): Handle `dired-directory'
Juanma Barranquero <lekktu@gmail.com>
parents:
51806
diff
changeset
|
840 (if (file-directory-p (file-name-directory dir)) |
4dafe305a193
(desktop-buffer-dired-misc-data, desktop-buffer-dired): Handle `dired-directory'
Juanma Barranquero <lekktu@gmail.com>
parents:
51806
diff
changeset
|
841 (progn |
4dafe305a193
(desktop-buffer-dired-misc-data, desktop-buffer-dired): Handle `dired-directory'
Juanma Barranquero <lekktu@gmail.com>
parents:
51806
diff
changeset
|
842 (dired dired-directory) |
4dafe305a193
(desktop-buffer-dired-misc-data, desktop-buffer-dired): Handle `dired-directory'
Juanma Barranquero <lekktu@gmail.com>
parents:
51806
diff
changeset
|
843 (mapcar 'dired-maybe-insert-subdir (cdr desktop-buffer-misc)) |
4dafe305a193
(desktop-buffer-dired-misc-data, desktop-buffer-dired): Handle `dired-directory'
Juanma Barranquero <lekktu@gmail.com>
parents:
51806
diff
changeset
|
844 (current-buffer)) |
4dafe305a193
(desktop-buffer-dired-misc-data, desktop-buffer-dired): Handle `dired-directory'
Juanma Barranquero <lekktu@gmail.com>
parents:
51806
diff
changeset
|
845 (message "Directory %s no longer exists." dir) |
4dafe305a193
(desktop-buffer-dired-misc-data, desktop-buffer-dired): Handle `dired-directory'
Juanma Barranquero <lekktu@gmail.com>
parents:
51806
diff
changeset
|
846 (sit-for 1) |
4dafe305a193
(desktop-buffer-dired-misc-data, desktop-buffer-dired): Handle `dired-directory'
Juanma Barranquero <lekktu@gmail.com>
parents:
51806
diff
changeset
|
847 'ignored)))) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
848 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
849 ;; ---------------------------------------------------------------------------- |
50532
4737239e4dad
(desktop-buffer-file): Restore major-mode if it is different from the normal
Juanma Barranquero <lekktu@gmail.com>
parents:
50507
diff
changeset
|
850 (defun desktop-buffer-file () |
4737239e4dad
(desktop-buffer-file): Restore major-mode if it is different from the normal
Juanma Barranquero <lekktu@gmail.com>
parents:
50507
diff
changeset
|
851 "Load a file." |
14755
3d473ed8c718
Global vars mam, fn, bn renamed.
Richard M. Stallman <rms@gnu.org>
parents:
14754
diff
changeset
|
852 (if desktop-buffer-file-name |
3d473ed8c718
Global vars mam, fn, bn renamed.
Richard M. Stallman <rms@gnu.org>
parents:
14754
diff
changeset
|
853 (if (or (file-exists-p desktop-buffer-file-name) |
3404 | 854 (and desktop-missing-file-warning |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
855 (y-or-n-p (format |
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
856 "File \"%s\" no longer exists. Re-create? " |
14755
3d473ed8c718
Global vars mam, fn, bn renamed.
Richard M. Stallman <rms@gnu.org>
parents:
14754
diff
changeset
|
857 desktop-buffer-file-name)))) |
32366
40d8b29df57e
(desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30853
diff
changeset
|
858 (let ((buf (find-file-noselect desktop-buffer-file-name))) |
40d8b29df57e
(desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30853
diff
changeset
|
859 (condition-case nil |
40d8b29df57e
(desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30853
diff
changeset
|
860 (switch-to-buffer buf) |
43831
7837693f5bac
(desktop-buffer-handlers): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
41150
diff
changeset
|
861 (error (pop-to-buffer buf))) |
50532
4737239e4dad
(desktop-buffer-file): Restore major-mode if it is different from the normal
Juanma Barranquero <lekktu@gmail.com>
parents:
50507
diff
changeset
|
862 (and (not (eq major-mode desktop-buffer-major-mode)) |
4737239e4dad
(desktop-buffer-file): Restore major-mode if it is different from the normal
Juanma Barranquero <lekktu@gmail.com>
parents:
50507
diff
changeset
|
863 (functionp desktop-buffer-major-mode) |
4737239e4dad
(desktop-buffer-file): Restore major-mode if it is different from the normal
Juanma Barranquero <lekktu@gmail.com>
parents:
50507
diff
changeset
|
864 (funcall desktop-buffer-major-mode)) |
43831
7837693f5bac
(desktop-buffer-handlers): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
41150
diff
changeset
|
865 buf) |
3404 | 866 'ignored))) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
867 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
868 ;; ---------------------------------------------------------------------------- |
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
869 ;; Create a buffer, load its file, set is mode, ...; called from Desktop file |
3404 | 870 ;; only. |
40210
01666fd1b210
(desktop-last-buffer): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
38798
diff
changeset
|
871 |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
872 (eval-when-compile ; Just to silence the byte compiler |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
873 (defvar desktop-first-buffer) ;; Dynamically bound in `desktop-read' |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
874 ) |
40210
01666fd1b210
(desktop-last-buffer): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
38798
diff
changeset
|
875 |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
876 (defun desktop-create-buffer ( |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
877 desktop-file-version |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
878 desktop-buffer-file-name |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
879 desktop-buffer-name |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
880 desktop-buffer-major-mode |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
881 desktop-buffer-minor-modes |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
882 desktop-buffer-point |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
883 desktop-buffer-mark |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
884 desktop-buffer-read-only |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
885 desktop-buffer-misc |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
886 &optional |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
887 desktop-buffer-locals) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
888 ;; To make desktop files with relative file names possible, we cannot |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
889 ;; allow `default-directory' to change. Therefore we save current buffer. |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
890 (save-current-buffer |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
891 (let ( |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
892 (buffer-list (buffer-list)) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
893 (hlist desktop-buffer-handlers) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
894 (result) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
895 (handler) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
896 ) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
897 ;; Call desktop-buffer-handlers to create buffer. |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
898 (while (and (not result) hlist) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
899 (setq handler (car hlist)) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
900 (setq result (funcall handler)) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
901 (setq hlist (cdr hlist))) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
902 (unless (bufferp result) (setq result nil)) |
51107
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
903 ;; Restore buffer list order with new buffer at end. Don't change |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
904 ;; the order for old desktop files (old desktop module behaviour). |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
905 (unless (< desktop-file-version 206) |
51107
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
906 (mapcar 'bury-buffer buffer-list) |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
907 (when result (bury-buffer result))) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
908 (when result |
51107
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
909 (unless (or desktop-first-buffer (< desktop-file-version 206)) |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
910 (setq desktop-first-buffer result)) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
911 (set-buffer result) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
912 (unless (equal (buffer-name) desktop-buffer-name) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
913 (rename-buffer desktop-buffer-name)) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
914 ;; minor modes |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
915 (cond ( |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
916 ;; backwards compatible |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
917 (equal '(t) desktop-buffer-minor-modes) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
918 (auto-fill-mode 1))( |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
919 (equal '(nil) desktop-buffer-minor-modes) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
920 (auto-fill-mode 0))( |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
921 t |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
922 (mapcar |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
923 #'(lambda (minor-mode) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
924 (when (functionp minor-mode) (funcall minor-mode 1))) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
925 desktop-buffer-minor-modes))) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
926 ;; Even though point and mark are non-nil when written by `desktop-save' |
51441
b9a57b098ab3
(desktop-create-buffer): Undo last change.
Juanma Barranquero <lekktu@gmail.com>
parents:
51378
diff
changeset
|
927 ;; they may be modified by handlers wanting to set point or mark themselves. |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
928 (when desktop-buffer-point (goto-char desktop-buffer-point)) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
929 (when desktop-buffer-mark |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
930 (if (consp desktop-buffer-mark) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
931 (progn |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
932 (set-mark (car desktop-buffer-mark)) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
933 (setq mark-active (car (cdr desktop-buffer-mark)))) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
934 (set-mark desktop-buffer-mark))) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
935 ;; Never override file system if the file really is read-only marked. |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
936 (if desktop-buffer-read-only (setq buffer-read-only desktop-buffer-read-only)) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
937 (while desktop-buffer-locals |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
938 (let ((this (car desktop-buffer-locals))) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
939 (if (consp this) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
940 ;; an entry of this form `(symbol . value)' |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
941 (progn |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
942 (make-local-variable (car this)) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
943 (set (car this) (cdr this))) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
944 ;; an entry of the form `symbol' |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
945 (make-local-variable this) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
946 (makunbound this))) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
947 (setq desktop-buffer-locals (cdr desktop-buffer-locals))))))) |
5465
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
948 |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
949 ;; ---------------------------------------------------------------------------- |
5465
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
950 ;; Backward compatibility -- update parameters to 205 standards. |
14755
3d473ed8c718
Global vars mam, fn, bn renamed.
Richard M. Stallman <rms@gnu.org>
parents:
14754
diff
changeset
|
951 (defun desktop-buffer (desktop-buffer-file-name desktop-buffer-name |
3d473ed8c718
Global vars mam, fn, bn renamed.
Richard M. Stallman <rms@gnu.org>
parents:
14754
diff
changeset
|
952 desktop-buffer-major-mode |
14756
aabf776c3b6a
Global var `misc' renamed.
Richard M. Stallman <rms@gnu.org>
parents:
14755
diff
changeset
|
953 mim pt mk ro tl fc cfs cr desktop-buffer-misc) |
14755
3d473ed8c718
Global vars mam, fn, bn renamed.
Richard M. Stallman <rms@gnu.org>
parents:
14754
diff
changeset
|
954 (desktop-create-buffer 205 desktop-buffer-file-name desktop-buffer-name |
14756
aabf776c3b6a
Global var `misc' renamed.
Richard M. Stallman <rms@gnu.org>
parents:
14755
diff
changeset
|
955 desktop-buffer-major-mode (cdr mim) pt mk ro |
aabf776c3b6a
Global var `misc' renamed.
Richard M. Stallman <rms@gnu.org>
parents:
14755
diff
changeset
|
956 desktop-buffer-misc |
5465
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
957 (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
|
958 (cons 'fill-column fc) |
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
959 (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
|
960 (cons 'case-replace cr) |
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
961 (cons 'overwrite-mode (car mim))))) |
50532
4737239e4dad
(desktop-buffer-file): Restore major-mode if it is different from the normal
Juanma Barranquero <lekktu@gmail.com>
parents:
50507
diff
changeset
|
962 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
963 ;; ---------------------------------------------------------------------------- |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
964 ;; When `desktop-enable' is non-nil and "--no-desktop" is not specified on the |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
965 ;; command line, we do the rest of what it takes to use desktop, but do it |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
966 ;; after finishing loading the init file. |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
967 ;; We cannot use `command-switch-alist' to process "--no-desktop" because these |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
968 ;; functions are processed after `after-init-hook'. |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
969 (add-hook |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
970 'after-init-hook |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
971 '(lambda () |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
972 (let ((key "--no-desktop")) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
973 (if (member key command-line-args) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
974 (delete key command-line-args) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
975 (when desktop-enable |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
976 (desktop-load-default) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
977 (desktop-read)))))) |
20526
ec0a8ccddd6c
(desktop-enable): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18581
diff
changeset
|
978 |
3405 | 979 (provide 'desktop) |
3404 | 980 |
32366
40d8b29df57e
(desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30853
diff
changeset
|
981 ;;; desktop.el ends here |