Mercurial > emacs
annotate lisp/desktop.el @ 57166:229978f30136
(scroll-left): Make it disabled.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 20 Sep 2004 16:14:28 +0000 |
parents | 791b0637af6d |
children | b72ba185298b 566253900690 |
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 |
52674 | 40 ;; To use this, use customize to turn on desktop-save-mode or add the |
41 ;; following line somewhere in your .emacs file: | |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
42 ;; |
52674 | 43 ;; (desktop-save-mode 1) |
5465
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
44 ;; |
52674 | 45 ;; For further usage information, look at the section |
46 ;; "Saving Emacs Sessions" in the GNU Emacs Manual. | |
3404 | 47 |
52674 | 48 ;; When the desktop module is loaded, the function `desktop-kill' is |
49 ;; added to the `kill-emacs-hook'. This function is responsible for | |
50 ;; saving the desktop when Emacs is killed. Furthermore an anonymous | |
51 ;; function is added to the `after-init-hook'. This function is | |
52 ;; responsible for loading the desktop when Emacs is started. | |
5465
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
53 |
28719
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
54 ;; 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
|
55 ;; 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
|
56 ;; 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
|
57 ;; 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
|
58 ;; `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
|
59 ;; 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
|
60 ;; are not the same. |
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
61 |
5465
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
62 ;; 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
|
63 ;; 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
|
64 ;; 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
|
65 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
66 ;; 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
|
67 ;; `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
|
68 ;; 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
|
69 |
7240
195e64dad1eb
(desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents:
7200
diff
changeset
|
70 ;; 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
|
71 ;; 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
|
72 ;; 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
|
73 ;; 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
|
74 ;; 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
|
75 ;; 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
|
76 ;; 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
|
77 ;; --------------------------------------------------------------------------- |
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
78 ;; TODO: |
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
79 ;; |
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
80 ;; Save window configuration. |
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
81 ;; Recognize more minor modes. |
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
82 ;; Save mark rings. |
3404 | 83 |
84 ;;; Code: | |
85 | |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
86 (defvar desktop-file-version "206" |
54206
ecf0e7a0567a
(desktop-file-version, desktop-after-read-hook): Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
52996
diff
changeset
|
87 "Version number of desktop file format. |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
88 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
|
89 backward compatibility.") |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
90 |
5465
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
91 ;; ---------------------------------------------------------------------------- |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
92 ;; 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
|
93 ;; ---------------------------------------------------------------------------- |
17411
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17204
diff
changeset
|
94 |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17204
diff
changeset
|
95 (defgroup desktop nil |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17204
diff
changeset
|
96 "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
|
97 :group 'frames) |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17204
diff
changeset
|
98 |
52674 | 99 ;;;###autoload |
100 (define-minor-mode desktop-save-mode | |
101 "Toggle desktop saving mode. | |
102 With numeric ARG, turn desktop saving on if ARG is positive, off | |
103 otherwise. See variable `desktop-save' for a description of when the | |
104 desktop is saved." | |
105 :global t | |
106 :group 'desktop) | |
107 | |
108 ;; Maintained for backward compatibility | |
109 (defvaralias 'desktop-enable 'desktop-save-mode) | |
110 (make-obsolete-variable 'desktop-enable 'desktop-save-mode) | |
20526
ec0a8ccddd6c
(desktop-enable): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18581
diff
changeset
|
111 |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
112 (defcustom desktop-save 'ask-if-new |
52674 | 113 "*Specifies whether the desktop should be saved when it is killed. |
114 A desktop is killed when the user changes desktop or quits Emacs. | |
115 Possible values are: | |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
116 t -- always save. |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
117 ask -- always ask. |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
118 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
|
119 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
|
120 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
|
121 nil -- never save. |
52674 | 122 The desktop is never saved when `desktop-save-mode' is nil. |
123 The variables `desktop-directory' and `desktop-base-file-name' | |
124 determine where the desktop is saved." | |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
125 :type '(choice |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
126 (const :tag "Always save" t) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
127 (const :tag "Always ask" ask) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
128 (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
|
129 (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
|
130 (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
|
131 (const :tag "Never save" nil)) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
132 :group 'desktop) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
133 |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
134 (defcustom desktop-base-file-name |
16037
a1e88c05b53c
(desktop-basefilename): Use convert-standard-filename.
Richard M. Stallman <rms@gnu.org>
parents:
14756
diff
changeset
|
135 (convert-standard-filename ".emacs.desktop") |
52674 | 136 "Name of file for Emacs desktop, excluding the directory part." |
20526
ec0a8ccddd6c
(desktop-enable): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18581
diff
changeset
|
137 :type 'file |
ec0a8ccddd6c
(desktop-enable): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18581
diff
changeset
|
138 :group 'desktop) |
50583
aea857f85930
(desktop-base-file-name): Renamed from desktop-basefilename. Add defvaralias.
Richard M. Stallman <rms@gnu.org>
parents:
50532
diff
changeset
|
139 (defvaralias 'desktop-basefilename 'desktop-base-file-name) |
3404 | 140 |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
141 (defcustom desktop-path '("." "~") |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
142 "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
|
143 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
|
144 :type '(repeat directory) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
145 :group 'desktop) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
146 |
17411
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17204
diff
changeset
|
147 (defcustom desktop-missing-file-warning nil |
55155
519f44af960a
(desktop-buffer-misc-data-function): Rename to desktop-save-buffer and change docstring.
Lars Hansen <larsh@soem.dk>
parents:
55059
diff
changeset
|
148 "*If non-nil then `desktop-read' asks if a non-existent file should be recreated. |
519f44af960a
(desktop-buffer-misc-data-function): Rename to desktop-save-buffer and change docstring.
Lars Hansen <larsh@soem.dk>
parents:
55059
diff
changeset
|
149 Also pause for a moment to display message about errors signaled in |
519f44af960a
(desktop-buffer-misc-data-function): Rename to desktop-save-buffer and change docstring.
Lars Hansen <larsh@soem.dk>
parents:
55059
diff
changeset
|
150 `desktop-buffer-mode-handlers'. |
519f44af960a
(desktop-buffer-misc-data-function): Rename to desktop-save-buffer and change docstring.
Lars Hansen <larsh@soem.dk>
parents:
55059
diff
changeset
|
151 |
519f44af960a
(desktop-buffer-misc-data-function): Rename to desktop-save-buffer and change docstring.
Lars Hansen <larsh@soem.dk>
parents:
55059
diff
changeset
|
152 If nil, just print error messages in the message buffer." |
17411
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17204
diff
changeset
|
153 :type 'boolean |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17204
diff
changeset
|
154 :group 'desktop) |
3404 | 155 |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
156 (defcustom desktop-no-desktop-file-hook nil |
52674 | 157 "Normal hook run when `desktop-read' can't find a desktop file. |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
158 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
|
159 :type 'hook |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
160 :group 'desktop) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
161 |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
162 (defcustom desktop-after-read-hook nil |
54206
ecf0e7a0567a
(desktop-file-version, desktop-after-read-hook): Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
52996
diff
changeset
|
163 "Normal hook run after a successful `desktop-read'. |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
164 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
|
165 :type 'hook |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
166 :group 'desktop) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
167 |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
168 (defcustom desktop-save-hook nil |
52674 | 169 "Normal hook run before the desktop is saved in a desktop file. |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
170 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
|
171 :type 'hook |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
172 :group 'desktop) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
173 |
57038
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
174 (defcustom desktop-globals-to-save |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
175 '(desktop-missing-file-warning |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
176 tags-file-name |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
177 tags-table-list |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
178 search-ring |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
179 regexp-search-ring |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
180 register-alist) |
52674 | 181 "List of global variables saved by `desktop-save'. |
182 An element may be variable name (a symbol) or a cons cell of the form | |
183 \(VAR . MAX-SIZE), which means to truncate VAR's value to at most | |
184 MAX-SIZE elements (if the value is a list) before saving the value. | |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
185 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
|
186 :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
|
187 :group 'desktop) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
188 |
57038
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
189 (defcustom desktop-globals-to-clear |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
190 '(kill-ring |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
191 kill-ring-yank-pointer |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
192 search-ring |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
193 search-ring-yank-pointer |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
194 regexp-search-ring |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
195 regexp-search-ring-yank-pointer) |
52674 | 196 "List of global variables to clear by `desktop-clear'. |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
197 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
|
198 \(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
|
199 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
|
200 :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
|
201 :group 'desktop) |
3404 | 202 |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
203 (defcustom desktop-clear-preserve-buffers-regexp |
52674 | 204 "^\\(\\*scratch\\*\\|\\*Messages\\*\\|\\*tramp/.+\\*\\)$" |
57038
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
205 "Regexp identifying buffers that `desktop-clear' should not delete. |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
206 See also `desktop-clear-preserve-buffers'." |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
207 :type 'regexp |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
208 :group 'desktop) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
209 |
52674 | 210 (defcustom desktop-clear-preserve-buffers nil |
211 "*List of buffer names that `desktop-clear' should not delete. | |
57038
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
212 See also `desktop-clear-preserve-buffers-regexp'." |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
213 :type '(repeat string) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
214 :group 'desktop) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
215 |
57038
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
216 (defcustom desktop-locals-to-save |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
217 '(desktop-locals-to-save ; Itself! Think it over. |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
218 truncate-lines |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
219 case-fold-search |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
220 case-replace |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
221 fill-column |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
222 overwrite-mode |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
223 change-log-default-name |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
224 line-number-mode |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
225 buffer-file-coding-system) |
10595 | 226 "List of local variables to save for each buffer. |
52674 | 227 The variables are saved only when they really are local." |
228 :type '(repeat symbol) | |
229 :group 'desktop) | |
5788
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
230 (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
|
231 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
232 ;; We skip .log files because they are normally temporary. |
14040 | 233 ;; (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
|
234 ;; 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
|
235 (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
|
236 "\\(^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
|
237 "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
|
238 :type 'regexp |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
239 :group 'desktop) |
3404 | 240 |
52674 | 241 ;; Skip tramp and ange-ftp files |
17411
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17204
diff
changeset
|
242 (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
|
243 "^/[^/:]*:" |
17411
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17204
diff
changeset
|
244 "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
|
245 :type 'regexp |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17204
diff
changeset
|
246 :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
|
247 |
32366
40d8b29df57e
(desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30853
diff
changeset
|
248 (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
|
249 "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
|
250 :type '(repeat symbol) |
40d8b29df57e
(desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30853
diff
changeset
|
251 :group 'desktop) |
40d8b29df57e
(desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30853
diff
changeset
|
252 |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
253 (defcustom desktop-file-name-format 'absolute |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
254 "*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
|
255 Possible values are: |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
256 absolute -- Absolute file name. |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
257 tilde -- Relative to ~. |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
258 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
|
259 :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
|
260 :group 'desktop) |
14755
3d473ed8c718
Global vars mam, fn, bn renamed.
Richard M. Stallman <rms@gnu.org>
parents:
14754
diff
changeset
|
261 |
55059
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
262 ;;;###autoload |
55155
519f44af960a
(desktop-buffer-misc-data-function): Rename to desktop-save-buffer and change docstring.
Lars Hansen <larsh@soem.dk>
parents:
55059
diff
changeset
|
263 (defvar desktop-save-buffer nil |
519f44af960a
(desktop-buffer-misc-data-function): Rename to desktop-save-buffer and change docstring.
Lars Hansen <larsh@soem.dk>
parents:
55059
diff
changeset
|
264 "When non-nil, save buffer status in desktop file. |
55059
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
265 This variable becomes buffer local when set. |
55155
519f44af960a
(desktop-buffer-misc-data-function): Rename to desktop-save-buffer and change docstring.
Lars Hansen <larsh@soem.dk>
parents:
55059
diff
changeset
|
266 |
519f44af960a
(desktop-buffer-misc-data-function): Rename to desktop-save-buffer and change docstring.
Lars Hansen <larsh@soem.dk>
parents:
55059
diff
changeset
|
267 If the value is a function, it called by `desktop-save' with argument |
519f44af960a
(desktop-buffer-misc-data-function): Rename to desktop-save-buffer and change docstring.
Lars Hansen <larsh@soem.dk>
parents:
55059
diff
changeset
|
268 DESKTOP-DIRNAME to obtain auxiliary information to saved in the desktop |
519f44af960a
(desktop-buffer-misc-data-function): Rename to desktop-save-buffer and change docstring.
Lars Hansen <larsh@soem.dk>
parents:
55059
diff
changeset
|
269 file along with the state of the buffer for which it was called. |
32447
cfae1c82d702
Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents:
32366
diff
changeset
|
270 |
52674 | 271 When file names are returned, they should be formatted using the call |
55059
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
272 \"(desktop-file-name FILE-NAME DESKTOP-DIRNAME)\". |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
273 |
55059
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
274 Later, when `desktop-read' calls a function in `desktop-buffer-mode-handlers' |
55155
519f44af960a
(desktop-buffer-misc-data-function): Rename to desktop-save-buffer and change docstring.
Lars Hansen <larsh@soem.dk>
parents:
55059
diff
changeset
|
275 to restore the buffer, the auxiliary information is passed as the argument |
519f44af960a
(desktop-buffer-misc-data-function): Rename to desktop-save-buffer and change docstring.
Lars Hansen <larsh@soem.dk>
parents:
55059
diff
changeset
|
276 DESKTOP-BUFFER-MISC.") |
519f44af960a
(desktop-buffer-misc-data-function): Rename to desktop-save-buffer and change docstring.
Lars Hansen <larsh@soem.dk>
parents:
55059
diff
changeset
|
277 (make-variable-buffer-local 'desktop-save-buffer) |
519f44af960a
(desktop-buffer-misc-data-function): Rename to desktop-save-buffer and change docstring.
Lars Hansen <larsh@soem.dk>
parents:
55059
diff
changeset
|
278 (make-obsolete-variable 'desktop-buffer-modes-to-save |
519f44af960a
(desktop-buffer-misc-data-function): Rename to desktop-save-buffer and change docstring.
Lars Hansen <larsh@soem.dk>
parents:
55059
diff
changeset
|
279 'desktop-save-buffer) |
55059
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
280 (make-obsolete-variable 'desktop-buffer-misc-functions |
55155
519f44af960a
(desktop-buffer-misc-data-function): Rename to desktop-save-buffer and change docstring.
Lars Hansen <larsh@soem.dk>
parents:
55059
diff
changeset
|
281 'desktop-save-buffer) |
32447
cfae1c82d702
Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents:
32366
diff
changeset
|
282 |
57038
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
283 (defcustom desktop-buffer-mode-handlers |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
284 '((dired-mode . dired-restore-desktop-buffer) |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
285 (rmail-mode . rmail-restore-desktop-buffer) |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
286 (mh-folder-mode . mh-restore-desktop-buffer) |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
287 (Info-mode . Info-restore-desktop-buffer)) |
55059
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
288 "Alist of major mode specific functions to restore a desktop buffer. |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
289 Functions are called by `desktop-read'. List elements must have the form |
55413
f30ad6214291
(desktop-buffer-mode-handlers): Fix docstring.
Lars Hansen <larsh@soem.dk>
parents:
55179
diff
changeset
|
290 \(MAJOR-MODE . RESTORE-BUFFER-FUNCTION). |
55059
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
291 |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
292 Buffers with a major mode not specified here, are restored by the default |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
293 handler `desktop-restore-file-buffer'. |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
294 |
55413
f30ad6214291
(desktop-buffer-mode-handlers): Fix docstring.
Lars Hansen <larsh@soem.dk>
parents:
55179
diff
changeset
|
295 Handlers are called with argument list |
55059
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
296 |
55418
b92f1b7ca228
(desktop-buffer-mode-handlers): Fix docstring.
Lars Hansen <larsh@soem.dk>
parents:
55413
diff
changeset
|
297 (DESKTOP-BUFFER-FILE-NAME DESKTOP-BUFFER-NAME DESKTOP-BUFFER-MISC) |
55059
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
298 |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
299 Furthermore, they may use the following variables: |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
300 |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
301 desktop-file-version |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
302 desktop-buffer-major-mode |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
303 desktop-buffer-minor-modes |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
304 desktop-buffer-point |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
305 desktop-buffer-mark |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
306 desktop-buffer-read-only |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
307 desktop-buffer-locals |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
308 |
55059
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
309 If a handler returns a buffer, then the saved mode settings |
43831
7837693f5bac
(desktop-buffer-handlers): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
41150
diff
changeset
|
310 and variable values for that buffer are copied into it." |
55059
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
311 :type 'alist |
17411
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17204
diff
changeset
|
312 :group 'desktop) |
5465
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
313 |
55059
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
314 (put 'desktop-buffer-mode-handlers 'risky-local-variable t) |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
315 (make-obsolete-variable 'desktop-buffer-handlers |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
316 'desktop-buffer-mode-handlers) |
32447
cfae1c82d702
Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents:
32366
diff
changeset
|
317 |
28719
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
318 (defcustom desktop-minor-mode-table |
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
319 '((auto-fill-function auto-fill-mode) |
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
320 (vc-mode nil)) |
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
321 "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
|
322 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
|
323 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
|
324 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
|
325 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
|
326 Only minor modes for which the name of the buffer-local variable |
55871
27173676bedf
(desktop-save): Don't save minor modes without a known mode initialization function.
Lars Hansen <larsh@soem.dk>
parents:
55418
diff
changeset
|
327 and the name of the minor mode function are different have to be added to |
28719
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
328 this table." |
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
329 :type 'sexp |
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
330 :group 'desktop) |
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
331 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
332 ;; ---------------------------------------------------------------------------- |
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
333 (defvar desktop-dirname nil |
52674 | 334 "The directory in which the desktop file should be saved.") |
3404 | 335 |
336 (defconst desktop-header | |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
337 ";; -------------------------------------------------------------------------- |
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
338 ;; Desktop File for Emacs |
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
339 ;; -------------------------------------------------------------------------- |
3404 | 340 " "*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
|
341 |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
342 (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
|
343 "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
|
344 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
345 ;; ---------------------------------------------------------------------------- |
54206
ecf0e7a0567a
(desktop-file-version, desktop-after-read-hook): Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
52996
diff
changeset
|
346 (defun desktop-truncate (list n) |
5465
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
347 "Truncate LIST to at most N elements destructively." |
54206
ecf0e7a0567a
(desktop-file-version, desktop-after-read-hook): Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
52996
diff
changeset
|
348 (let ((here (nthcdr (1- n) list))) |
5465
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
349 (if (consp here) |
5788
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
350 (setcdr here nil)))) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
351 |
5465
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
352 ;; ---------------------------------------------------------------------------- |
18581
45f27efe77c7
(desktop-clear-preserve-buffers): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18527
diff
changeset
|
353 (defun desktop-clear () |
45f27efe77c7
(desktop-clear-preserve-buffers): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18527
diff
changeset
|
354 "Empty the Desktop. |
52674 | 355 This kills all buffers except for internal ones and those matching |
356 `desktop-clear-preserve-buffers-regexp' or listed in | |
357 `desktop-clear-preserve-buffers'. Furthermore, it clears the | |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
358 variables listed in `desktop-globals-to-clear'." |
3404 | 359 (interactive) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
360 (dolist (var desktop-globals-to-clear) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
361 (if (symbolp var) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
362 (eval `(setq-default ,var nil)) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
363 (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
|
364 (let ((buffers (buffer-list))) |
45f27efe77c7
(desktop-clear-preserve-buffers): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18527
diff
changeset
|
365 (while buffers |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
366 (let ((bufname (buffer-name (car buffers)))) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
367 (or |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
368 (null bufname) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
369 (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
|
370 (member bufname desktop-clear-preserve-buffers) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
371 ;; 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
|
372 (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
|
373 (kill-buffer (car buffers)))) |
18581
45f27efe77c7
(desktop-clear-preserve-buffers): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18527
diff
changeset
|
374 (setq buffers (cdr buffers)))) |
5314 | 375 (delete-other-windows)) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
376 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
377 ;; ---------------------------------------------------------------------------- |
5788
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
378 (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
|
379 |
3404 | 380 (defun desktop-kill () |
52674 | 381 "If `desktop-save-mode' is non-nil, do what `desktop-save' says to do. |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
382 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
|
383 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
|
384 (when |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
385 (and |
52674 | 386 desktop-save-mode |
51441
b9a57b098ab3
(desktop-create-buffer): Undo last change.
Juanma Barranquero <lekktu@gmail.com>
parents:
51378
diff
changeset
|
387 (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
|
388 (or |
52217 | 389 (eq desktop-save t) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
390 (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
|
391 (and |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
392 (or |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
393 (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
|
394 (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
|
395 (y-or-n-p "Save desktop? "))))) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
396 (unless desktop-dirname |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
397 (setq desktop-dirname |
51441
b9a57b098ab3
(desktop-create-buffer): Undo last change.
Juanma Barranquero <lekktu@gmail.com>
parents:
51378
diff
changeset
|
398 (file-name-as-directory |
b9a57b098ab3
(desktop-create-buffer): Undo last change.
Juanma Barranquero <lekktu@gmail.com>
parents:
51378
diff
changeset
|
399 (expand-file-name |
b9a57b098ab3
(desktop-create-buffer): Undo last change.
Juanma Barranquero <lekktu@gmail.com>
parents:
51378
diff
changeset
|
400 (call-interactively |
b9a57b098ab3
(desktop-create-buffer): Undo last change.
Juanma Barranquero <lekktu@gmail.com>
parents:
51378
diff
changeset
|
401 (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
|
402 (condition-case err |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
403 (desktop-save desktop-dirname) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
404 (file-error |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
405 (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
|
406 (signal (car err) (cdr err))))))) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
407 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
408 ;; ---------------------------------------------------------------------------- |
14754
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
409 (defun desktop-list* (&rest args) |
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
410 (if (null (cdr args)) |
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
411 (car args) |
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
412 (setq args (nreverse args)) |
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
413 (let ((value (cons (nth 1 args) (car args)))) |
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
414 (setq args (cdr (cdr args))) |
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
415 (while args |
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
416 (setq value (cons (car args) value)) |
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
417 (setq args (cdr args))) |
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
418 value))) |
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
419 |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
420 ;; ---------------------------------------------------------------------------- |
54206
ecf0e7a0567a
(desktop-file-version, desktop-after-read-hook): Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
52996
diff
changeset
|
421 (defun desktop-internal-v2s (value) |
10595 | 422 "Convert VALUE to a pair (QUOTE . TXT); (eval (read TXT)) gives VALUE. |
423 TXT is a string that when read and evaluated yields value. | |
424 QUOTE may be `may' (value may be quoted), | |
425 `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
|
426 (cond |
54206
ecf0e7a0567a
(desktop-file-version, desktop-after-read-hook): Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
52996
diff
changeset
|
427 ((or (numberp value) (null value) (eq t value)) |
ecf0e7a0567a
(desktop-file-version, desktop-after-read-hook): Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
52996
diff
changeset
|
428 (cons 'may (prin1-to-string value))) |
ecf0e7a0567a
(desktop-file-version, desktop-after-read-hook): Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
52996
diff
changeset
|
429 ((stringp value) |
ecf0e7a0567a
(desktop-file-version, desktop-after-read-hook): Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
52996
diff
changeset
|
430 (let ((copy (copy-sequence value))) |
10777
9f4a9820fea1
(desktop-internal-v2s): Don't use format to eliminate text properties.
Richard M. Stallman <rms@gnu.org>
parents:
10595
diff
changeset
|
431 (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
|
432 ;; 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
|
433 (cons 'may (prin1-to-string copy)))) |
54206
ecf0e7a0567a
(desktop-file-version, desktop-after-read-hook): Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
52996
diff
changeset
|
434 ((symbolp value) |
ecf0e7a0567a
(desktop-file-version, desktop-after-read-hook): Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
52996
diff
changeset
|
435 (cons 'must (prin1-to-string value))) |
ecf0e7a0567a
(desktop-file-version, desktop-after-read-hook): Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
52996
diff
changeset
|
436 ((vectorp value) |
5788
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
437 (let* ((special nil) |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
438 (pass1 (mapcar |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
439 (lambda (el) |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
440 (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
|
441 (if (null (car res)) |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
442 (setq special t)) |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
443 res)) |
54206
ecf0e7a0567a
(desktop-file-version, desktop-after-read-hook): Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
52996
diff
changeset
|
444 value))) |
5788
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
445 (if special |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
446 (cons nil (concat "(vector " |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
447 (mapconcat (lambda (el) |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
448 (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
|
449 (concat "'" (cdr el)) |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
450 (cdr el))) |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
451 pass1 |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
452 " ") |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
453 ")")) |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
454 (cons 'may (concat "[" (mapconcat 'cdr pass1 " ") "]"))))) |
54206
ecf0e7a0567a
(desktop-file-version, desktop-after-read-hook): Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
52996
diff
changeset
|
455 ((consp value) |
ecf0e7a0567a
(desktop-file-version, desktop-after-read-hook): Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
52996
diff
changeset
|
456 (let ((p value) |
7200
eabd5e6e95de
(desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents:
7091
diff
changeset
|
457 newlist |
14754
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
458 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
|
459 anynil) |
eabd5e6e95de
(desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents:
7091
diff
changeset
|
460 (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
|
461 (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
|
462 (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
|
463 (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
|
464 (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
|
465 (if p |
eabd5e6e95de
(desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents:
7091
diff
changeset
|
466 (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
|
467 (el (car newlist))) |
14754
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
468 (or anynil (setq anynil (null (car last)))) |
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
469 (or anynil |
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
470 (setq newlist (cons '(must . ".") newlist))) |
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
471 (setq use-list* t) |
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
472 (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
|
473 (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
|
474 (if anynil |
eabd5e6e95de
(desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents:
7091
diff
changeset
|
475 (cons nil |
14754
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
476 (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
|
477 (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
|
478 (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
|
479 (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
|
480 (cdr el))) |
eabd5e6e95de
(desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents:
7091
diff
changeset
|
481 newlist |
eabd5e6e95de
(desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents:
7091
diff
changeset
|
482 " ") |
eabd5e6e95de
(desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents:
7091
diff
changeset
|
483 ")")) |
eabd5e6e95de
(desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents:
7091
diff
changeset
|
484 (cons 'must |
eabd5e6e95de
(desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents:
7091
diff
changeset
|
485 (concat "(" (mapconcat 'cdr newlist " ") ")"))))) |
54206
ecf0e7a0567a
(desktop-file-version, desktop-after-read-hook): Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
52996
diff
changeset
|
486 ((subrp value) |
5788
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
487 (cons nil (concat "(symbol-function '" |
54206
ecf0e7a0567a
(desktop-file-version, desktop-after-read-hook): Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
52996
diff
changeset
|
488 (substring (prin1-to-string value) 7 -1) |
5788
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
489 ")"))) |
54206
ecf0e7a0567a
(desktop-file-version, desktop-after-read-hook): Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
52996
diff
changeset
|
490 ((markerp value) |
ecf0e7a0567a
(desktop-file-version, desktop-after-read-hook): Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
52996
diff
changeset
|
491 (let ((pos (prin1-to-string (marker-position value))) |
ecf0e7a0567a
(desktop-file-version, desktop-after-read-hook): Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
52996
diff
changeset
|
492 (buf (prin1-to-string (buffer-name (marker-buffer value))))) |
5788
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
493 (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
|
494 " (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
|
495 " (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
|
496 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
|
497 (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
|
498 (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
|
499 |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
500 ;; ---------------------------------------------------------------------------- |
54206
ecf0e7a0567a
(desktop-file-version, desktop-after-read-hook): Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
52996
diff
changeset
|
501 (defun desktop-value-to-string (value) |
10595 | 502 "Convert VALUE to a string that when read evaluates to the same value. |
503 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
|
504 (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
|
505 (float-output-format nil) |
54206
ecf0e7a0567a
(desktop-file-version, desktop-after-read-hook): Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
52996
diff
changeset
|
506 (quote.txt (desktop-internal-v2s value)) |
5788
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
507 (quote (car quote.txt)) |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
508 (txt (cdr quote.txt))) |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
509 (if (eq quote 'must) |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
510 (concat "'" txt) |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
511 txt))) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
512 |
5465
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
513 ;; ---------------------------------------------------------------------------- |
13154
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
514 (defun desktop-outvar (varspec) |
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
515 "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
|
516 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
|
517 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
|
518 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
|
519 \(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
|
520 (let (var size) |
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
521 (if (consp varspec) |
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
522 (setq var (car varspec) size (cdr varspec)) |
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
523 (setq var varspec)) |
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
524 (if (boundp var) |
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
525 (progn |
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
526 (if (and (integerp size) |
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
527 (> size 0) |
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
528 (listp (eval var))) |
28719
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
529 (desktop-truncate (eval var) size)) |
13154
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
530 (insert "(setq " |
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
531 (symbol-name var) |
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
532 " " |
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
533 (desktop-value-to-string (symbol-value var)) |
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
534 ")\n"))))) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
535 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
536 ;; ---------------------------------------------------------------------------- |
5465
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
537 (defun desktop-save-buffer-p (filename bufname mode &rest dummy) |
55155
519f44af960a
(desktop-buffer-misc-data-function): Rename to desktop-save-buffer and change docstring.
Lars Hansen <larsh@soem.dk>
parents:
55059
diff
changeset
|
538 "Return t if buffer should have its state saved in the desktop file. |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
539 FILENAME is the visited file name, BUFNAME is the buffer name, and |
3404 | 540 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
|
541 (let ((case-fold-search nil)) |
32366
40d8b29df57e
(desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30853
diff
changeset
|
542 (and (not (string-match desktop-buffers-not-to-save bufname)) |
55155
519f44af960a
(desktop-buffer-misc-data-function): Rename to desktop-save-buffer and change docstring.
Lars Hansen <larsh@soem.dk>
parents:
55059
diff
changeset
|
543 (not (memq mode desktop-modes-not-to-save)) |
519f44af960a
(desktop-buffer-misc-data-function): Rename to desktop-save-buffer and change docstring.
Lars Hansen <larsh@soem.dk>
parents:
55059
diff
changeset
|
544 (or (and filename |
519f44af960a
(desktop-buffer-misc-data-function): Rename to desktop-save-buffer and change docstring.
Lars Hansen <larsh@soem.dk>
parents:
55059
diff
changeset
|
545 (not (string-match desktop-files-not-to-save filename))) |
519f44af960a
(desktop-buffer-misc-data-function): Rename to desktop-save-buffer and change docstring.
Lars Hansen <larsh@soem.dk>
parents:
55059
diff
changeset
|
546 (and (eq mode 'dired-mode) |
519f44af960a
(desktop-buffer-misc-data-function): Rename to desktop-save-buffer and change docstring.
Lars Hansen <larsh@soem.dk>
parents:
55059
diff
changeset
|
547 (with-current-buffer bufname |
519f44af960a
(desktop-buffer-misc-data-function): Rename to desktop-save-buffer and change docstring.
Lars Hansen <larsh@soem.dk>
parents:
55059
diff
changeset
|
548 (not (string-match desktop-files-not-to-save |
519f44af960a
(desktop-buffer-misc-data-function): Rename to desktop-save-buffer and change docstring.
Lars Hansen <larsh@soem.dk>
parents:
55059
diff
changeset
|
549 default-directory)))) |
519f44af960a
(desktop-buffer-misc-data-function): Rename to desktop-save-buffer and change docstring.
Lars Hansen <larsh@soem.dk>
parents:
55059
diff
changeset
|
550 (and (null filename) |
519f44af960a
(desktop-buffer-misc-data-function): Rename to desktop-save-buffer and change docstring.
Lars Hansen <larsh@soem.dk>
parents:
55059
diff
changeset
|
551 (with-current-buffer bufname desktop-save-buffer)))))) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
552 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
553 ;; ---------------------------------------------------------------------------- |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
554 (defun desktop-file-name (filename dirname) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
555 "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
|
556 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
|
557 (cond |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
558 ((not filename) nil) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
559 ((eq desktop-file-name-format 'tilde) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
560 (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
|
561 (cond |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
562 ((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
|
563 ((string= "./" relative-name) "~/") |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
564 ((string= "." relative-name) "~") |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
565 (t (concat "~/" relative-name))))) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
566 ((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
|
567 (t (expand-file-name filename)))) |
48143
8c7919f99581
(desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents:
43831
diff
changeset
|
568 |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
569 ;; ---------------------------------------------------------------------------- |
3404 | 570 (defun desktop-save (dirname) |
52674 | 571 "Save the desktop in a desktop file. |
572 Parameter DIRNAME specifies where to save the desktop file. | |
573 See also `desktop-base-file-name'." | |
3404 | 574 (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
|
575 (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
|
576 (setq dirname (file-name-as-directory (expand-file-name dirname))) |
3404 | 577 (save-excursion |
51441
b9a57b098ab3
(desktop-create-buffer): Undo last change.
Juanma Barranquero <lekktu@gmail.com>
parents:
51378
diff
changeset
|
578 (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
|
579 (info |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
580 (mapcar |
57038
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
581 #'(lambda (b) |
51107
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
582 (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
|
583 (list |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
584 (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
|
585 (buffer-name) |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
586 major-mode |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
587 ;; minor modes |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
588 (let (ret) |
55871
27173676bedf
(desktop-save): Don't save minor modes without a known mode initialization function.
Lars Hansen <larsh@soem.dk>
parents:
55418
diff
changeset
|
589 (mapc |
27173676bedf
(desktop-save): Don't save minor modes without a known mode initialization function.
Lars Hansen <larsh@soem.dk>
parents:
55418
diff
changeset
|
590 #'(lambda (minor-mode) |
51107
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
591 (and |
55871
27173676bedf
(desktop-save): Don't save minor modes without a known mode initialization function.
Lars Hansen <larsh@soem.dk>
parents:
55418
diff
changeset
|
592 (boundp minor-mode) |
27173676bedf
(desktop-save): Don't save minor modes without a known mode initialization function.
Lars Hansen <larsh@soem.dk>
parents:
55418
diff
changeset
|
593 (symbol-value minor-mode) |
27173676bedf
(desktop-save): Don't save minor modes without a known mode initialization function.
Lars Hansen <larsh@soem.dk>
parents:
55418
diff
changeset
|
594 (let ((special (assq minor-mode desktop-minor-mode-table))) |
27173676bedf
(desktop-save): Don't save minor modes without a known mode initialization function.
Lars Hansen <larsh@soem.dk>
parents:
55418
diff
changeset
|
595 (when (or special (functionp minor-mode)) |
27173676bedf
(desktop-save): Don't save minor modes without a known mode initialization function.
Lars Hansen <larsh@soem.dk>
parents:
55418
diff
changeset
|
596 (setq ret |
27173676bedf
(desktop-save): Don't save minor modes without a known mode initialization function.
Lars Hansen <larsh@soem.dk>
parents:
55418
diff
changeset
|
597 (cons |
27173676bedf
(desktop-save): Don't save minor modes without a known mode initialization function.
Lars Hansen <larsh@soem.dk>
parents:
55418
diff
changeset
|
598 (if special (cadr special) minor-mode) |
27173676bedf
(desktop-save): Don't save minor modes without a known mode initialization function.
Lars Hansen <larsh@soem.dk>
parents:
55418
diff
changeset
|
599 ret)))))) |
51107
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
600 (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
|
601 ret) |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
602 (point) |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
603 (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
|
604 buffer-read-only |
55059
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
605 ;; Auxiliary information |
55155
519f44af960a
(desktop-buffer-misc-data-function): Rename to desktop-save-buffer and change docstring.
Lars Hansen <larsh@soem.dk>
parents:
55059
diff
changeset
|
606 (when (functionp desktop-save-buffer) |
519f44af960a
(desktop-buffer-misc-data-function): Rename to desktop-save-buffer and change docstring.
Lars Hansen <larsh@soem.dk>
parents:
55059
diff
changeset
|
607 (funcall desktop-save-buffer dirname)) |
51107
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
608 (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
|
609 (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
|
610 (ll)) |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
611 (while locals |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
612 (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
|
613 (if here |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
614 (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
|
615 (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
|
616 (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
|
617 (setq locals (cdr locals))) |
57038
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
618 ll))) |
51107
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
619 (buffer-list))) |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
620 (buf (get-buffer-create "*desktop*"))) |
3404 | 621 (set-buffer buf) |
622 (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
|
623 |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
624 (insert |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
625 ";; -*- coding: emacs-mule; -*-\n" |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
626 desktop-header |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
627 ";; Created " (current-time-string) "\n" |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
628 ";; 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
|
629 ";; Emacs version " emacs-version "\n\n" |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
630 ";; Global section:\n") |
3404 | 631 (mapcar (function desktop-outvar) desktop-globals-to-save) |
632 (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
|
633 (insert |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
634 "(setq kill-ring-yank-pointer (nthcdr " |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
635 (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
|
636 " kill-ring))\n")) |
3404 | 637 |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
638 (insert "\n;; Buffer section -- buffers listed in same order as in buffer list:\n") |
57038
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
639 (mapcar #'(lambda (l) |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
640 (if (apply 'desktop-save-buffer-p l) |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
641 (progn |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
642 (insert "(desktop-create-buffer " desktop-file-version) |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
643 (mapcar #'(lambda (e) |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
644 (insert "\n " (desktop-value-to-string e))) |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
645 l) |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
646 (insert ")\n\n")))) |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
647 info) |
3404 | 648 (setq default-directory dirname) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
649 (when (file-exists-p filename) (delete-file filename)) |
38618
c41fb9fae096
(desktop-save): Bind coding-system-for-write to
Gerd Moellmann <gerd@gnu.org>
parents:
38592
diff
changeset
|
650 (let ((coding-system-for-write 'emacs-mule)) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
651 (write-region (point-min) (point-max) filename nil 'nomessage)))) |
3404 | 652 (setq desktop-dirname dirname)) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
653 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
654 ;; ---------------------------------------------------------------------------- |
3404 | 655 (defun desktop-remove () |
52674 | 656 "Delete desktop file in `desktop-dirname'. |
657 This function also sets `desktop-dirname' to nil." | |
3404 | 658 (interactive) |
52674 | 659 (when desktop-dirname |
660 (let ((filename (expand-file-name desktop-base-file-name desktop-dirname))) | |
661 (setq desktop-dirname nil) | |
662 (when (file-exists-p filename) | |
663 (delete-file filename))))) | |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
664 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
665 ;; ---------------------------------------------------------------------------- |
21303
346595905ae4
(desktop-load-default): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents:
20772
diff
changeset
|
666 ;;;###autoload |
52674 | 667 (defun desktop-read (&optional dirname) |
668 "Read and process the desktop file in directory DIRNAME. | |
669 Look for a desktop file in DIRNAME, or if DIRNAME is omitted, look in | |
670 directories listed in `desktop-path'. If a desktop file is found, it | |
671 is processed and `desktop-after-read-hook' is run. If no desktop file | |
672 is found, clear the desktop and run `desktop-no-desktop-file-hook'. | |
673 This function is a no-op when Emacs is running in batch mode. | |
674 It returns t if a desktop file was loaded, nil otherwise." | |
675 (interactive) | |
676 (unless noninteractive | |
677 (setq desktop-dirname | |
678 (file-name-as-directory | |
679 (expand-file-name | |
680 (or | |
681 ;; If DIRNAME is specified, use it. | |
682 (and (< 0 (length dirname)) dirname) | |
683 ;; Otherwise search desktop file in desktop-path. | |
684 (let ((dirs desktop-path)) | |
685 (while | |
686 (and | |
687 dirs | |
688 (not | |
689 (file-exists-p (expand-file-name desktop-base-file-name (car dirs))))) | |
690 (setq dirs (cdr dirs))) | |
691 (and dirs (car dirs))) | |
692 ;; If not found and `desktop-path' is non-nil, use its first element. | |
693 (and desktop-path (car desktop-path)) | |
694 ;; Default: Home directory. | |
695 "~")))) | |
696 (if (file-exists-p (expand-file-name desktop-base-file-name desktop-dirname)) | |
697 ;; Desktop file found, process it. | |
55059
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
698 (let ((desktop-first-buffer nil) |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
699 (desktop-buffer-ok-count 0) |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
700 (desktop-buffer-fail-count 0)) |
52674 | 701 ;; Evaluate desktop buffer. |
702 (load (expand-file-name desktop-base-file-name desktop-dirname) t t t) | |
703 ;; `desktop-create-buffer' puts buffers at end of the buffer list. | |
704 ;; We want buffers existing prior to evaluating the desktop (and not reused) | |
705 ;; to be placed at the end of the buffer list, so we move them here. | |
706 (mapcar 'bury-buffer | |
707 (nreverse (cdr (memq desktop-first-buffer (nreverse (buffer-list)))))) | |
708 (switch-to-buffer (car (buffer-list))) | |
709 (run-hooks 'desktop-delay-hook) | |
710 (setq desktop-delay-hook nil) | |
711 (run-hooks 'desktop-after-read-hook) | |
55059
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
712 (message "Desktop: %d buffer%s restored%s." |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
713 desktop-buffer-ok-count |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
714 (if (= 1 desktop-buffer-ok-count) "" "s") |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
715 (if (< 0 desktop-buffer-fail-count) |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
716 (format ", %d failed to restore" desktop-buffer-fail-count) |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
717 "")) |
52674 | 718 t) |
719 ;; No desktop file found. | |
720 (desktop-clear) | |
721 (let ((default-directory desktop-dirname)) | |
722 (run-hooks 'desktop-no-desktop-file-hook)) | |
723 (message "No desktop file.") | |
724 nil))) | |
725 | |
726 ;; ---------------------------------------------------------------------------- | |
727 ;; Maintained for backward compatibility | |
728 ;;;###autoload | |
3404 | 729 (defun desktop-load-default () |
10595 | 730 "Load the `default' start-up library manually. |
52674 | 731 Also inhibit further loading of it." |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
732 (if (not inhibit-default-init) ; safety check |
3404 | 733 (progn |
734 (load "default" t t) | |
735 (setq inhibit-default-init t)))) | |
52674 | 736 (make-obsolete 'desktop-load-default 'desktop-save-mode) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
737 |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
738 ;; ---------------------------------------------------------------------------- |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
739 ;;;###autoload |
52674 | 740 (defun desktop-change-dir (dirname) |
741 "Change to desktop saved in DIRNAME. | |
742 Kill the desktop as specified by variables `desktop-save-mode' and | |
743 `desktop-save', then clear the desktop and load the desktop file in | |
744 directory DIRNAME." | |
745 (interactive "DChange to directory: ") | |
746 (setq dirname (file-name-as-directory (expand-file-name dirname desktop-dirname))) | |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
747 (desktop-kill) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
748 (desktop-clear) |
52674 | 749 (desktop-read dirname)) |
750 | |
751 ;; ---------------------------------------------------------------------------- | |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
752 ;;;###autoload |
52674 | 753 (defun desktop-save-in-desktop-dir () |
754 "Save the desktop in directory `desktop-dirname'." | |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
755 (interactive) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
756 (if desktop-dirname |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
757 (desktop-save desktop-dirname) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
758 (call-interactively 'desktop-save)) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
759 (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
|
760 |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
761 ;; ---------------------------------------------------------------------------- |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
762 ;;;###autoload |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
763 (defun desktop-revert () |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
764 "Revert to the last loaded desktop." |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
765 (interactive) |
52674 | 766 (unless desktop-dirname |
767 (error "Unknown desktop directory")) | |
768 (unless (file-exists-p (expand-file-name desktop-base-file-name desktop-dirname)) | |
769 (error "No desktop file found")) | |
770 (desktop-clear) | |
771 (desktop-read desktop-dirname)) | |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
772 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
773 ;; ---------------------------------------------------------------------------- |
55059
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
774 (defun desktop-restore-file-buffer (desktop-buffer-file-name |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
775 desktop-buffer-name |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
776 desktop-buffer-misc) |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
777 "Restore a file buffer." |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
778 (eval-when-compile ; Just to silence the byte compiler |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
779 (defvar desktop-buffer-major-mode) |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
780 (defvar desktop-buffer-locals)) |
14755
3d473ed8c718
Global vars mam, fn, bn renamed.
Richard M. Stallman <rms@gnu.org>
parents:
14754
diff
changeset
|
781 (if desktop-buffer-file-name |
3d473ed8c718
Global vars mam, fn, bn renamed.
Richard M. Stallman <rms@gnu.org>
parents:
14754
diff
changeset
|
782 (if (or (file-exists-p desktop-buffer-file-name) |
55059
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
783 (let ((msg (format "Desktop: File \"%s\" no longer exists." |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
784 desktop-buffer-file-name))) |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
785 (if desktop-missing-file-warning |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
786 (y-or-n-p (concat msg " Re-create? ")) |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
787 (message msg) |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
788 nil))) |
52996
c9843219861e
(desktop-locals-to-save): Add buffer-file-coding-system.
Lars Hansen <larsh@soem.dk>
parents:
52674
diff
changeset
|
789 (let* ((auto-insert nil) ; Disable auto insertion |
c9843219861e
(desktop-locals-to-save): Add buffer-file-coding-system.
Lars Hansen <larsh@soem.dk>
parents:
52674
diff
changeset
|
790 (coding-system-for-read |
c9843219861e
(desktop-locals-to-save): Add buffer-file-coding-system.
Lars Hansen <larsh@soem.dk>
parents:
52674
diff
changeset
|
791 (or coding-system-for-read |
c9843219861e
(desktop-locals-to-save): Add buffer-file-coding-system.
Lars Hansen <larsh@soem.dk>
parents:
52674
diff
changeset
|
792 (cdr (assq 'buffer-file-coding-system |
c9843219861e
(desktop-locals-to-save): Add buffer-file-coding-system.
Lars Hansen <larsh@soem.dk>
parents:
52674
diff
changeset
|
793 desktop-buffer-locals)))) |
c9843219861e
(desktop-locals-to-save): Add buffer-file-coding-system.
Lars Hansen <larsh@soem.dk>
parents:
52674
diff
changeset
|
794 (buf (find-file-noselect desktop-buffer-file-name))) |
32366
40d8b29df57e
(desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30853
diff
changeset
|
795 (condition-case nil |
40d8b29df57e
(desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30853
diff
changeset
|
796 (switch-to-buffer buf) |
43831
7837693f5bac
(desktop-buffer-handlers): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
41150
diff
changeset
|
797 (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
|
798 (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
|
799 (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
|
800 (funcall desktop-buffer-major-mode)) |
43831
7837693f5bac
(desktop-buffer-handlers): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
41150
diff
changeset
|
801 buf) |
55059
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
802 nil))) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
803 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
804 ;; ---------------------------------------------------------------------------- |
55179 | 805 ;; Create a buffer, load its file, set its mode, ...; |
806 ;; called from Desktop file only. | |
40210
01666fd1b210
(desktop-last-buffer): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
38798
diff
changeset
|
807 |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
808 (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
|
809 (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
|
810 ) |
40210
01666fd1b210
(desktop-last-buffer): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
38798
diff
changeset
|
811 |
57038
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
812 (defun desktop-create-buffer |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
813 (desktop-file-version |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
814 desktop-buffer-file-name |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
815 desktop-buffer-name |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
816 desktop-buffer-major-mode |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
817 desktop-buffer-minor-modes |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
818 desktop-buffer-point |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
819 desktop-buffer-mark |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
820 desktop-buffer-read-only |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
821 desktop-buffer-misc |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
822 &optional |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
823 desktop-buffer-locals) |
55059
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
824 ;; Just to silence the byte compiler. Bound locally in `desktop-read'. |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
825 (eval-when-compile |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
826 (defvar desktop-buffer-ok-count) |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
827 (defvar desktop-buffer-fail-count)) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
828 ;; 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
|
829 ;; 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
|
830 (save-current-buffer |
57038
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
831 (let ((buffer-list (buffer-list)) |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
832 (result |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
833 (condition-case err |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
834 (funcall (or (cdr (assq desktop-buffer-major-mode |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
835 desktop-buffer-mode-handlers)) |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
836 'desktop-restore-file-buffer) |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
837 desktop-buffer-file-name |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
838 desktop-buffer-name |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
839 desktop-buffer-misc) |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
840 (error |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
841 (message "Desktop: Can't load buffer %s: %s" |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
842 desktop-buffer-name |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
843 (error-message-string err)) |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
844 (when desktop-missing-file-warning (sit-for 1)) |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
845 nil)))) |
55059
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
846 (if (bufferp result) |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
847 (setq desktop-buffer-ok-count (1+ desktop-buffer-ok-count)) |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
848 (setq desktop-buffer-fail-count (1+ desktop-buffer-fail-count)) |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
849 (setq result nil)) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
850 (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
|
851 ;; 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
|
852 ;; 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
|
853 (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
|
854 (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
|
855 (when result (bury-buffer result))) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
856 (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
|
857 (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
|
858 (setq desktop-first-buffer result)) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
859 (set-buffer result) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
860 (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
|
861 (rename-buffer desktop-buffer-name)) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
862 ;; minor modes |
57038
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
863 (cond ((equal '(t) desktop-buffer-minor-modes) ; backwards compatible |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
864 (auto-fill-mode 1)) |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
865 ((equal '(nil) desktop-buffer-minor-modes) ; backwards compatible |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
866 (auto-fill-mode 0)) |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
867 (t |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
868 (mapcar #'(lambda (minor-mode) |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
869 (when (functionp minor-mode) (funcall minor-mode 1))) |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
870 desktop-buffer-minor-modes))) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
871 ;; 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
|
872 ;; they may be modified by handlers wanting to set point or mark themselves. |
55059
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
873 (when desktop-buffer-point |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
874 (goto-char |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
875 (condition-case err |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
876 ;; Evaluate point. Thus point can be something like '(search-forward ... |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
877 (eval desktop-buffer-point) |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
878 (error (message "%s" (error-message-string err)) 1)))) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
879 (when desktop-buffer-mark |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
880 (if (consp desktop-buffer-mark) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
881 (progn |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
882 (set-mark (car desktop-buffer-mark)) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
883 (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
|
884 (set-mark desktop-buffer-mark))) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
885 ;; 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
|
886 (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
|
887 (while desktop-buffer-locals |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
888 (let ((this (car desktop-buffer-locals))) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
889 (if (consp this) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
890 ;; 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
|
891 (progn |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
892 (make-local-variable (car this)) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
893 (set (car this) (cdr this))) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
894 ;; an entry of the form `symbol' |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
895 (make-local-variable this) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
896 (makunbound this))) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
897 (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
|
898 |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
899 ;; ---------------------------------------------------------------------------- |
5465
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
900 ;; 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
|
901 (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
|
902 desktop-buffer-major-mode |
14756
aabf776c3b6a
Global var `misc' renamed.
Richard M. Stallman <rms@gnu.org>
parents:
14755
diff
changeset
|
903 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
|
904 (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
|
905 desktop-buffer-major-mode (cdr mim) pt mk ro |
aabf776c3b6a
Global var `misc' renamed.
Richard M. Stallman <rms@gnu.org>
parents:
14755
diff
changeset
|
906 desktop-buffer-misc |
5465
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
907 (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
|
908 (cons 'fill-column fc) |
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
909 (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
|
910 (cons 'case-replace cr) |
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
911 (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
|
912 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
913 ;; ---------------------------------------------------------------------------- |
52674 | 914 ;; When `desktop-save-mode' is non-nil and "--no-desktop" is not specified on the |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
915 ;; 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
|
916 ;; after finishing loading the init file. |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
917 ;; 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
|
918 ;; 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
|
919 (add-hook |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
920 'after-init-hook |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
921 '(lambda () |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
922 (let ((key "--no-desktop")) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
923 (if (member key command-line-args) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
924 (delete key command-line-args) |
52674 | 925 (when desktop-save-mode (desktop-read)))))) |
20526
ec0a8ccddd6c
(desktop-enable): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18581
diff
changeset
|
926 |
3405 | 927 (provide 'desktop) |
3404 | 928 |
52401 | 929 ;;; arch-tag: 221907c3-1771-4fd3-9c2e-c6f700c6ede9 |
32366
40d8b29df57e
(desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30853
diff
changeset
|
930 ;;; desktop.el ends here |