Mercurial > emacs
annotate lisp/desktop.el @ 70511:cd1e2cf9f28c
* xresmini.texi (GTK resources): Inserted GTK description.
author | Jan Djärv <jan.h.d@swipnet.se> |
---|---|
date | Sun, 07 May 2006 19:39:28 +0000 |
parents | 01a75c5115e7 |
children | 75ac416582c4 4b3d39451150 |
rev | line source |
---|---|
3404 | 1 ;;; desktop.el --- save partial status of Emacs when killed |
2 | |
64762
41bb365f41c4
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64674
diff
changeset
|
3 ;; Copyright (C) 1993, 1994, 1995, 1997, 2000, 2001, 2002, 2003, |
68651
3bd95f4f2941
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
68344
diff
changeset
|
4 ;; 2004, 2005, 2006 Free Software Foundation, Inc. |
3404 | 5 |
6 ;; Author: Morten Welinder <terra@diku.dk> | |
64254 | 7 ;; Maintainter: Lars Hansen <larsh@soem.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 |
64091 | 25 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
26 ;; Boston, MA 02110-1301, 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 |
64893
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
54 ;; Special handling. |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
55 ;; ----------------- |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
56 ;; Variables `desktop-buffer-mode-handlers' and `desktop-minor-mode-handlers' |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
57 ;; are supplied to handle special major and minor modes respectively. |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
58 ;; `desktop-buffer-mode-handlers' is an alist of major mode specific functions |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
59 ;; to restore a desktop buffer. Elements must have the form |
68775
01a75c5115e7
(desktop-outvar): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
68651
diff
changeset
|
60 ;; |
64893
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
61 ;; (MAJOR-MODE . RESTORE-BUFFER-FUNCTION). |
68775
01a75c5115e7
(desktop-outvar): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
68651
diff
changeset
|
62 ;; |
64893
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
63 ;; Functions listed are called by `desktop-create-buffer' when `desktop-read' |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
64 ;; evaluates the desktop file. Buffers with a major mode not specified here, |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
65 ;; are restored by the default handler `desktop-restore-file-buffer'. |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
66 ;; `desktop-minor-mode-handlers' is an alist of functions to restore |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
67 ;; non-standard minor modes. Elements must have the form |
68775
01a75c5115e7
(desktop-outvar): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
68651
diff
changeset
|
68 ;; |
64893
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
69 ;; (MINOR-MODE . RESTORE-FUNCTION). |
68775
01a75c5115e7
(desktop-outvar): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
68651
diff
changeset
|
70 ;; |
64893
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
71 ;; Functions are called by `desktop-create-buffer' to restore minor modes. |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
72 ;; Minor modes not specified here, are restored by the standard minor mode |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
73 ;; function. If you write a module that defines a major or minor mode that |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
74 ;; needs a special handler, then place code like |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
75 |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
76 ;; (defun foo-restore-desktop-buffer |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
77 ;; ... |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
78 ;; (add-to-list 'desktop-buffer-mode-handlers |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
79 ;; '(foo-mode . foo-restore-desktop-buffer)) |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
80 |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
81 ;; or |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
82 |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
83 ;; (defun bar-desktop-restore |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
84 ;; ... |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
85 ;; (add-to-list 'desktop-minor-mode-handlers |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
86 ;; '(bar-mode . bar-desktop-restore)) |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
87 |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
88 ;; in the module itself, and make shure that the mode function is |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
89 ;; autoloaded. See the docstrings of `desktop-buffer-mode-handlers' and |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
90 ;; `desktop-minor-mode-handlers' for more info. |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
91 |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
92 ;; Minor modes. |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
93 ;; ------------ |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
94 ;; Conventional minor modes (see node "Minor Mode Conventions" in the elisp |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
95 ;; manual) are handled in the following way: |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
96 ;; When `desktop-save' saves the state of a buffer to the desktop file, it |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
97 ;; saves as `desktop-minor-modes' the list of names of those variables in |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
98 ;; `minor-mode-alist' that have a non-nil value. |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
99 ;; When `desktop-create' restores the buffer, each of the symbols in |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
100 ;; `desktop-minor-modes' is called as function with parameter 1. |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
101 ;; The variables `desktop-minor-mode-table' and `desktop-minor-mode-handlers' |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
102 ;; are used to handle non-conventional minor modes. `desktop-save' uses |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
103 ;; `desktop-minor-mode-table' to map minor mode variables to minor mode |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
104 ;; functions before writing `desktop-minor-modes'. If a minor mode has a |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
105 ;; variable name that is different form its function name, an entry |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
106 |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
107 ;; (NAME RESTORE-FUNCTION) |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
108 |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
109 ;; should be added to `desktop-minor-mode-table'. If a minor mode should not |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
110 ;; be restored, RESTORE-FUNCTION should be set to nil. `desktop-create' uses |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
111 ;; `desktop-minor-mode-handlers' to lookup minor modes that needs a restore |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
112 ;; function different from the usual minor mode function. |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
113 ;; --------------------------------------------------------------------------- |
28719
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
114 |
5465
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
115 ;; 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
|
116 ;; 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
|
117 ;; 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
|
118 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
119 ;; 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
|
120 ;; `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
|
121 ;; 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
|
122 |
7240
195e64dad1eb
(desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents:
7200
diff
changeset
|
123 ;; 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
|
124 ;; 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
|
125 ;; 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
|
126 ;; 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
|
127 ;; 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
|
128 ;; 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
|
129 ;; 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
|
130 ;; --------------------------------------------------------------------------- |
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
131 ;; TODO: |
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
132 ;; |
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
133 ;; Save window configuration. |
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
134 ;; Recognize more minor modes. |
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
135 ;; Save mark rings. |
3404 | 136 |
137 ;;; Code: | |
138 | |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
139 (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
|
140 "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
|
141 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
|
142 backward compatibility.") |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
143 |
5465
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
144 ;; ---------------------------------------------------------------------------- |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
145 ;; 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
|
146 ;; ---------------------------------------------------------------------------- |
17411
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17204
diff
changeset
|
147 |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17204
diff
changeset
|
148 (defgroup desktop nil |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17204
diff
changeset
|
149 "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
|
150 :group 'frames) |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17204
diff
changeset
|
151 |
52674 | 152 ;;;###autoload |
153 (define-minor-mode desktop-save-mode | |
154 "Toggle desktop saving mode. | |
155 With numeric ARG, turn desktop saving on if ARG is positive, off | |
156 otherwise. See variable `desktop-save' for a description of when the | |
157 desktop is saved." | |
158 :global t | |
159 :group 'desktop) | |
160 | |
161 ;; Maintained for backward compatibility | |
64674
b110ecf69f54
(desktop-save-buffer): Fix typos in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
64566
diff
changeset
|
162 (define-obsolete-variable-alias 'desktop-enable |
b110ecf69f54
(desktop-save-buffer): Fix typos in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
64566
diff
changeset
|
163 'desktop-save-mode "22.1") |
20526
ec0a8ccddd6c
(desktop-enable): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18581
diff
changeset
|
164 |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
165 (defcustom desktop-save 'ask-if-new |
52674 | 166 "*Specifies whether the desktop should be saved when it is killed. |
167 A desktop is killed when the user changes desktop or quits Emacs. | |
168 Possible values are: | |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
169 t -- always save. |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
170 ask -- always ask. |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
171 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
|
172 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
|
173 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
|
174 nil -- never save. |
52674 | 175 The desktop is never saved when `desktop-save-mode' is nil. |
64490
e22e42dbaf76
(desktop-enable, desktop-buffer-modes-to-save, (desktop-buffer-misc-functions,
Juanma Barranquero <lekktu@gmail.com>
parents:
64254
diff
changeset
|
176 The variables `desktop-dirname' and `desktop-base-file-name' |
52674 | 177 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
|
178 :type '(choice |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
179 (const :tag "Always save" t) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
180 (const :tag "Always ask" ask) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
181 (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
|
182 (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
|
183 (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
|
184 (const :tag "Never save" nil)) |
58140
b72ba185298b
(desktop-buffer-mode-handlers, desktop-after-read-hook,
Lars Hansen <larsh@soem.dk>
parents:
57038
diff
changeset
|
185 :group 'desktop |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
59487
diff
changeset
|
186 :version "22.1") |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
187 |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
188 (defcustom desktop-base-file-name |
16037
a1e88c05b53c
(desktop-basefilename): Use convert-standard-filename.
Richard M. Stallman <rms@gnu.org>
parents:
14756
diff
changeset
|
189 (convert-standard-filename ".emacs.desktop") |
52674 | 190 "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
|
191 :type 'file |
ec0a8ccddd6c
(desktop-enable): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18581
diff
changeset
|
192 :group 'desktop) |
64674
b110ecf69f54
(desktop-save-buffer): Fix typos in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
64566
diff
changeset
|
193 (define-obsolete-variable-alias 'desktop-basefilename |
b110ecf69f54
(desktop-save-buffer): Fix typos in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
64566
diff
changeset
|
194 'desktop-base-file-name "22.1") |
3404 | 195 |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
196 (defcustom desktop-path '("." "~") |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
197 "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
|
198 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
|
199 :type '(repeat directory) |
58140
b72ba185298b
(desktop-buffer-mode-handlers, desktop-after-read-hook,
Lars Hansen <larsh@soem.dk>
parents:
57038
diff
changeset
|
200 :group 'desktop |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
59487
diff
changeset
|
201 :version "22.1") |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
202 |
17411
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17204
diff
changeset
|
203 (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
|
204 "*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
|
205 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
|
206 `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
|
207 |
519f44af960a
(desktop-buffer-misc-data-function): Rename to desktop-save-buffer and change docstring.
Lars Hansen <larsh@soem.dk>
parents:
55059
diff
changeset
|
208 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
|
209 :type 'boolean |
58140
b72ba185298b
(desktop-buffer-mode-handlers, desktop-after-read-hook,
Lars Hansen <larsh@soem.dk>
parents:
57038
diff
changeset
|
210 :group 'desktop |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
59487
diff
changeset
|
211 :version "22.1") |
3404 | 212 |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
213 (defcustom desktop-no-desktop-file-hook nil |
52674 | 214 "Normal hook run when `desktop-read' can't find a desktop file. |
61236
65075d5373df
(desktop-no-desktop-file-hook, desktop-after-read-hook): Fix docstring.
Lute Kamstra <lute@gnu.org>
parents:
59996
diff
changeset
|
215 May be used to show a dired buffer." |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
216 :type 'hook |
58140
b72ba185298b
(desktop-buffer-mode-handlers, desktop-after-read-hook,
Lars Hansen <larsh@soem.dk>
parents:
57038
diff
changeset
|
217 :group 'desktop |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
59487
diff
changeset
|
218 :version "22.1") |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
219 |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
220 (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
|
221 "Normal hook run after a successful `desktop-read'. |
61236
65075d5373df
(desktop-no-desktop-file-hook, desktop-after-read-hook): Fix docstring.
Lute Kamstra <lute@gnu.org>
parents:
59996
diff
changeset
|
222 May be used to show a buffer list." |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
223 :type 'hook |
58140
b72ba185298b
(desktop-buffer-mode-handlers, desktop-after-read-hook,
Lars Hansen <larsh@soem.dk>
parents:
57038
diff
changeset
|
224 :group 'desktop |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
59487
diff
changeset
|
225 :version "22.1") |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
226 |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
227 (defcustom desktop-save-hook nil |
52674 | 228 "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
|
229 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
|
230 :type 'hook |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
231 :group 'desktop) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
232 |
57038
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
233 (defcustom desktop-globals-to-save |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
234 '(desktop-missing-file-warning |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
235 tags-file-name |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
236 tags-table-list |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
237 search-ring |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
238 regexp-search-ring |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
239 register-alist) |
52674 | 240 "List of global variables saved by `desktop-save'. |
241 An element may be variable name (a symbol) or a cons cell of the form | |
242 \(VAR . MAX-SIZE), which means to truncate VAR's value to at most | |
243 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
|
244 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
|
245 :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
|
246 :group 'desktop) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
247 |
57038
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
248 (defcustom desktop-globals-to-clear |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
249 '(kill-ring |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
250 kill-ring-yank-pointer |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
251 search-ring |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
252 search-ring-yank-pointer |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
253 regexp-search-ring |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
254 regexp-search-ring-yank-pointer) |
59412
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
255 "List of global variables that `desktop-clear' will clear. |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
256 An element may be variable name (a symbol) or a cons cell of the form |
64490
e22e42dbaf76
(desktop-enable, desktop-buffer-modes-to-save, (desktop-buffer-misc-functions,
Juanma Barranquero <lekktu@gmail.com>
parents:
64254
diff
changeset
|
257 \(VAR . FORM). Symbols are set to nil and for cons cells VAR is set |
e22e42dbaf76
(desktop-enable, desktop-buffer-modes-to-save, (desktop-buffer-misc-functions,
Juanma Barranquero <lekktu@gmail.com>
parents:
64254
diff
changeset
|
258 to the value obtained by evaluating FORM." |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
259 :type '(repeat (restricted-sexp :match-alternatives (symbolp consp))) |
58140
b72ba185298b
(desktop-buffer-mode-handlers, desktop-after-read-hook,
Lars Hansen <larsh@soem.dk>
parents:
57038
diff
changeset
|
260 :group 'desktop |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
59487
diff
changeset
|
261 :version "22.1") |
3404 | 262 |
64893
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
263 (defcustom desktop-clear-preserve-buffers |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
264 '("\\*scratch\\*" "\\*Messages\\*" "\\*server\\*" "\\*tramp/.+\\*") |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
265 "*List of buffers that `desktop-clear' should not delete. |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
266 Each element is a regular expression. Buffers with a name matched by any of |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
267 these won't be deleted." |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
268 :type '(repeat string) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
269 :group 'desktop) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
270 |
64893
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
271 ;;;###autoload |
57038
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
272 (defcustom desktop-locals-to-save |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
273 '(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
|
274 truncate-lines |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
275 case-fold-search |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
276 case-replace |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
277 fill-column |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
278 overwrite-mode |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
279 change-log-default-name |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
280 line-number-mode |
64893
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
281 column-number-mode |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
282 size-indication-mode |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
283 buffer-file-coding-system |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
284 indent-tabs-mode |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
285 indicate-buffer-boundaries |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
286 indicate-empty-lines |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
287 show-trailing-whitespace) |
10595 | 288 "List of local variables to save for each buffer. |
64893
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
289 The variables are saved only when they really are local. Conventional minor |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
290 modes are restored automatically; they should not be listed here." |
52674 | 291 :type '(repeat symbol) |
292 :group 'desktop) | |
5465
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
293 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
294 ;; We skip .log files because they are normally temporary. |
14040 | 295 ;; (ftp) files because they require passwords and whatnot. |
17411
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17204
diff
changeset
|
296 (defcustom desktop-buffers-not-to-save |
66278
8926d6f2f267
(desktop-buffers-not-to-save): Remove TAGS from the default value.
Juri Linkov <juri@jurta.org>
parents:
66037
diff
changeset
|
297 "\\(^nn\\.a[0-9]+\\|\\.log\\|(ftp)\\)$" |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
298 "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
|
299 :type 'regexp |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
300 :group 'desktop) |
3404 | 301 |
52674 | 302 ;; 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
|
303 (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
|
304 "^/[^/:]*:" |
17411
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17204
diff
changeset
|
305 "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
|
306 :type 'regexp |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17204
diff
changeset
|
307 :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
|
308 |
66278
8926d6f2f267
(desktop-buffers-not-to-save): Remove TAGS from the default value.
Juri Linkov <juri@jurta.org>
parents:
66037
diff
changeset
|
309 ;; We skip TAGS files to save time (tags-file-name is saved instead). |
8926d6f2f267
(desktop-buffers-not-to-save): Remove TAGS from the default value.
Juri Linkov <juri@jurta.org>
parents:
66037
diff
changeset
|
310 (defcustom desktop-modes-not-to-save |
8926d6f2f267
(desktop-buffers-not-to-save): Remove TAGS from the default value.
Juri Linkov <juri@jurta.org>
parents:
66037
diff
changeset
|
311 '(tags-table-mode) |
32366
40d8b29df57e
(desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30853
diff
changeset
|
312 "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
|
313 :type '(repeat symbol) |
40d8b29df57e
(desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30853
diff
changeset
|
314 :group 'desktop) |
40d8b29df57e
(desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30853
diff
changeset
|
315 |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
316 (defcustom desktop-file-name-format 'absolute |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
317 "*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
|
318 Possible values are: |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
319 absolute -- Absolute file name. |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
320 tilde -- Relative to ~. |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
321 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
|
322 :type '(choice (const absolute) (const tilde) (const local)) |
58140
b72ba185298b
(desktop-buffer-mode-handlers, desktop-after-read-hook,
Lars Hansen <larsh@soem.dk>
parents:
57038
diff
changeset
|
323 :group 'desktop |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
59487
diff
changeset
|
324 :version "22.1") |
14755
3d473ed8c718
Global vars mam, fn, bn renamed.
Richard M. Stallman <rms@gnu.org>
parents:
14754
diff
changeset
|
325 |
59412
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
326 (defcustom desktop-restore-eager t |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
327 "Number of buffers to restore immediately. |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
328 Remaining buffers are restored lazily (when Emacs is idle). |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
329 If value is t, all buffers are restored immediately." |
59436
1b7f2dc9f5f6
(desktop-restore-eager): Fix typo in type.
David Kastrup <dak@gnu.org>
parents:
59412
diff
changeset
|
330 :type '(choice (const t) integer) |
59412
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
331 :group 'desktop |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
59487
diff
changeset
|
332 :version "22.1") |
59412
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
333 |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
334 (defcustom desktop-lazy-verbose t |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
335 "Verbose reporting of lazily created buffers." |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
336 :type 'boolean |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
337 :group 'desktop |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
59487
diff
changeset
|
338 :version "22.1") |
59412
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
339 |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
340 (defcustom desktop-lazy-idle-delay 5 |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
341 "Idle delay before starting to create buffers. |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
342 See `desktop-restore-eager'." |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
343 :type 'integer |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
344 :group 'desktop |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
59487
diff
changeset
|
345 :version "22.1") |
59412
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
346 |
55059
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
347 ;;;###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
|
348 (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
|
349 "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
|
350 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
|
351 |
64674
b110ecf69f54
(desktop-save-buffer): Fix typos in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
64566
diff
changeset
|
352 If the value is a function, it is called by `desktop-save' with argument |
b110ecf69f54
(desktop-save-buffer): Fix typos in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
64566
diff
changeset
|
353 DESKTOP-DIRNAME to obtain auxiliary information to save in the desktop |
55155
519f44af960a
(desktop-buffer-misc-data-function): Rename to desktop-save-buffer and change docstring.
Lars Hansen <larsh@soem.dk>
parents:
55059
diff
changeset
|
354 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
|
355 |
52674 | 356 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
|
357 \"(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
|
358 |
64893
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
359 Later, when `desktop-read' evaluates the desktop file, auxiliary information |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
360 is passed as the argument DESKTOP-BUFFER-MISC to functions in |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
361 `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
|
362 (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
|
363 (make-obsolete-variable 'desktop-buffer-modes-to-save |
64490
e22e42dbaf76
(desktop-enable, desktop-buffer-modes-to-save, (desktop-buffer-misc-functions,
Juanma Barranquero <lekktu@gmail.com>
parents:
64254
diff
changeset
|
364 'desktop-save-buffer "22.1") |
55059
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
365 (make-obsolete-variable 'desktop-buffer-misc-functions |
64490
e22e42dbaf76
(desktop-enable, desktop-buffer-modes-to-save, (desktop-buffer-misc-functions,
Juanma Barranquero <lekktu@gmail.com>
parents:
64254
diff
changeset
|
366 'desktop-save-buffer "22.1") |
32447
cfae1c82d702
Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents:
32366
diff
changeset
|
367 |
64893
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
368 ;;;###autoload |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
369 (defvar desktop-buffer-mode-handlers |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
370 nil |
55059
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
371 "Alist of major mode specific functions to restore a desktop buffer. |
64893
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
372 Functions listed are called by `desktop-create-buffer' when `desktop-read' |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
373 evaluates the desktop file. List elements must have the form |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
374 |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
375 (MAJOR-MODE . RESTORE-BUFFER-FUNCTION). |
55059
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
376 |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
377 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
|
378 handler `desktop-restore-file-buffer'. |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
379 |
55413
f30ad6214291
(desktop-buffer-mode-handlers): Fix docstring.
Lars Hansen <larsh@soem.dk>
parents:
55179
diff
changeset
|
380 Handlers are called with argument list |
55059
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
381 |
55418
b92f1b7ca228
(desktop-buffer-mode-handlers): Fix docstring.
Lars Hansen <larsh@soem.dk>
parents:
55413
diff
changeset
|
382 (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
|
383 |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
384 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
|
385 |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
386 desktop-file-version |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
387 desktop-buffer-major-mode |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
388 desktop-buffer-minor-modes |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
389 desktop-buffer-point |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
390 desktop-buffer-mark |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
391 desktop-buffer-read-only |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
392 desktop-buffer-locals |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
393 |
55059
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
394 If a handler returns a buffer, then the saved mode settings |
64893
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
395 and variable values for that buffer are copied into it. |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
396 |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
397 Modules that define a major mode that needs a special handler should contain |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
398 code like |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
399 |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
400 (defun foo-restore-desktop-buffer |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
401 ... |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
402 (add-to-list 'desktop-buffer-mode-handlers |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
403 '(foo-mode . foo-restore-desktop-buffer)) |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
404 |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
405 Furthermore the major mode function must be autoloaded.") |
5465
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
406 |
64963
527df96e5eda
Put autoload cookie at risky-local-variable declarations.
Andreas Schwab <schwab@suse.de>
parents:
64893
diff
changeset
|
407 ;;;###autoload |
55059
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
408 (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
|
409 (make-obsolete-variable 'desktop-buffer-handlers |
64490
e22e42dbaf76
(desktop-enable, desktop-buffer-modes-to-save, (desktop-buffer-misc-functions,
Juanma Barranquero <lekktu@gmail.com>
parents:
64254
diff
changeset
|
410 'desktop-buffer-mode-handlers "22.1") |
32447
cfae1c82d702
Added extensible special buffer support to desktop.el. See the
John Wiegley <johnw@newartisans.com>
parents:
32366
diff
changeset
|
411 |
28719
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
412 (defcustom desktop-minor-mode-table |
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
413 '((auto-fill-function auto-fill-mode) |
67560
2d2062823ea5
(desktop-minor-mode-table): Add vc-dired-mode with nil.
Juri Linkov <juri@jurta.org>
parents:
66278
diff
changeset
|
414 (vc-mode nil) |
2d2062823ea5
(desktop-minor-mode-table): Add vc-dired-mode with nil.
Juri Linkov <juri@jurta.org>
parents:
66278
diff
changeset
|
415 (vc-dired-mode nil)) |
28719
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
416 "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
|
417 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
|
418 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
|
419 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
|
420 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
|
421 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
|
422 and the name of the minor mode function are different have to be added to |
64893
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
423 this table. See also `desktop-minor-mode-handlers'." |
28719
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
424 :type 'sexp |
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
425 :group 'desktop) |
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
426 |
64893
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
427 ;;;###autoload |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
428 (defvar desktop-minor-mode-handlers |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
429 nil |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
430 "Alist of functions to restore non-standard minor modes. |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
431 Functions are called by `desktop-create-buffer' to restore minor modes. |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
432 List elements must have the form |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
433 |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
434 (MINOR-MODE . RESTORE-FUNCTION). |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
435 |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
436 Minor modes not specified here, are restored by the standard minor mode |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
437 function. |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
438 |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
439 Handlers are called with argument list |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
440 |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
441 (DESKTOP-BUFFER-LOCALS) |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
442 |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
443 Furthermore, they may use the following variables: |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
444 |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
445 desktop-file-version |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
446 desktop-buffer-file-name |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
447 desktop-buffer-name |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
448 desktop-buffer-major-mode |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
449 desktop-buffer-minor-modes |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
450 desktop-buffer-point |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
451 desktop-buffer-mark |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
452 desktop-buffer-read-only |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
453 desktop-buffer-misc |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
454 |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
455 When a handler is called, the buffer has been created and the major mode has |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
456 been set, but local variables listed in desktop-buffer-locals has not yet been |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
457 created and set. |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
458 |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
459 Modules that define a minor mode that needs a special handler should contain |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
460 code like |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
461 |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
462 (defun foo-desktop-restore |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
463 ... |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
464 (add-to-list 'desktop-minor-mode-handlers |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
465 '(foo-mode . foo-desktop-restore)) |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
466 |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
467 Furthermore the minor mode function must be autoloaded. |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
468 |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
469 See also `desktop-minor-mode-table'.") |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
470 |
64963
527df96e5eda
Put autoload cookie at risky-local-variable declarations.
Andreas Schwab <schwab@suse.de>
parents:
64893
diff
changeset
|
471 ;;;###autoload |
64893
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
472 (put 'desktop-minor-mode-handlers 'risky-local-variable t) |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
473 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
474 ;; ---------------------------------------------------------------------------- |
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
475 (defvar desktop-dirname nil |
52674 | 476 "The directory in which the desktop file should be saved.") |
3404 | 477 |
478 (defconst desktop-header | |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
479 ";; -------------------------------------------------------------------------- |
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
480 ;; Desktop File for Emacs |
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
481 ;; -------------------------------------------------------------------------- |
3404 | 482 " "*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
|
483 |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
484 (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
|
485 "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
|
486 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
487 ;; ---------------------------------------------------------------------------- |
54206
ecf0e7a0567a
(desktop-file-version, desktop-after-read-hook): Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
52996
diff
changeset
|
488 (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
|
489 "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
|
490 (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
|
491 (if (consp here) |
5788
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
492 (setcdr here nil)))) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
493 |
5465
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
494 ;; ---------------------------------------------------------------------------- |
18581
45f27efe77c7
(desktop-clear-preserve-buffers): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18527
diff
changeset
|
495 (defun desktop-clear () |
45f27efe77c7
(desktop-clear-preserve-buffers): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18527
diff
changeset
|
496 "Empty the Desktop. |
64893
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
497 This kills all buffers except for internal ones and those with names matched by |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
498 a regular expression in the list `desktop-clear-preserve-buffers'. |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
499 Furthermore, it clears the variables listed in `desktop-globals-to-clear'." |
3404 | 500 (interactive) |
59412
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
501 (desktop-lazy-abort) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
502 (dolist (var desktop-globals-to-clear) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
503 (if (symbolp var) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
504 (eval `(setq-default ,var nil)) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
505 (eval `(setq-default ,(car var) ,(cdr var))))) |
64893
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
506 (let ((buffers (buffer-list)) |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
507 (preserve-regexp (concat "^\\(" |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
508 (mapconcat (lambda (regexp) |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
509 (concat "\\(" regexp "\\)")) |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
510 desktop-clear-preserve-buffers |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
511 "\\|") |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
512 "\\)$"))) |
18581
45f27efe77c7
(desktop-clear-preserve-buffers): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18527
diff
changeset
|
513 (while buffers |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
514 (let ((bufname (buffer-name (car buffers)))) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
515 (or |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
516 (null bufname) |
64893
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
517 (string-match preserve-regexp bufname) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
518 ;; Don't kill buffers made for internal purposes. |
64519
a9ca2e64f9c1
(desktop-enable, desktop-basefilename): Declare with
Juanma Barranquero <lekktu@gmail.com>
parents:
64490
diff
changeset
|
519 (and (not (equal bufname "")) (eq (aref bufname 0) ?\s)) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
520 (kill-buffer (car buffers)))) |
18581
45f27efe77c7
(desktop-clear-preserve-buffers): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18527
diff
changeset
|
521 (setq buffers (cdr buffers)))) |
5314 | 522 (delete-other-windows)) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
523 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
524 ;; ---------------------------------------------------------------------------- |
5788
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
525 (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
|
526 |
3404 | 527 (defun desktop-kill () |
52674 | 528 "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
|
529 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
|
530 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
|
531 (when |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
532 (and |
52674 | 533 desktop-save-mode |
51441
b9a57b098ab3
(desktop-create-buffer): Undo last change.
Juanma Barranquero <lekktu@gmail.com>
parents:
51378
diff
changeset
|
534 (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
|
535 (or |
52217 | 536 (eq desktop-save t) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
537 (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
|
538 (and |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
539 (or |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
540 (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
|
541 (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
|
542 (y-or-n-p "Save desktop? "))))) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
543 (unless desktop-dirname |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
544 (setq desktop-dirname |
51441
b9a57b098ab3
(desktop-create-buffer): Undo last change.
Juanma Barranquero <lekktu@gmail.com>
parents:
51378
diff
changeset
|
545 (file-name-as-directory |
b9a57b098ab3
(desktop-create-buffer): Undo last change.
Juanma Barranquero <lekktu@gmail.com>
parents:
51378
diff
changeset
|
546 (expand-file-name |
b9a57b098ab3
(desktop-create-buffer): Undo last change.
Juanma Barranquero <lekktu@gmail.com>
parents:
51378
diff
changeset
|
547 (call-interactively |
b9a57b098ab3
(desktop-create-buffer): Undo last change.
Juanma Barranquero <lekktu@gmail.com>
parents:
51378
diff
changeset
|
548 (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
|
549 (condition-case err |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
550 (desktop-save desktop-dirname) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
551 (file-error |
64490
e22e42dbaf76
(desktop-enable, desktop-buffer-modes-to-save, (desktop-buffer-misc-functions,
Juanma Barranquero <lekktu@gmail.com>
parents:
64254
diff
changeset
|
552 (unless (yes-or-no-p "Error while saving the desktop. Ignore? ") |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
553 (signal (car err) (cdr err))))))) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
554 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
555 ;; ---------------------------------------------------------------------------- |
14754
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
556 (defun desktop-list* (&rest args) |
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
557 (if (null (cdr args)) |
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
558 (car args) |
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
559 (setq args (nreverse args)) |
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
560 (let ((value (cons (nth 1 args) (car args)))) |
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
561 (setq args (cdr (cdr args))) |
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
562 (while args |
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
563 (setq value (cons (car args) value)) |
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
564 (setq args (cdr args))) |
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
565 value))) |
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
566 |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
567 ;; ---------------------------------------------------------------------------- |
54206
ecf0e7a0567a
(desktop-file-version, desktop-after-read-hook): Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
52996
diff
changeset
|
568 (defun desktop-internal-v2s (value) |
10595 | 569 "Convert VALUE to a pair (QUOTE . TXT); (eval (read TXT)) gives VALUE. |
570 TXT is a string that when read and evaluated yields value. | |
571 QUOTE may be `may' (value may be quoted), | |
572 `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
|
573 (cond |
64519
a9ca2e64f9c1
(desktop-enable, desktop-basefilename): Declare with
Juanma Barranquero <lekktu@gmail.com>
parents:
64490
diff
changeset
|
574 ((or (numberp value) (null value) (eq t value) (keywordp value)) |
54206
ecf0e7a0567a
(desktop-file-version, desktop-after-read-hook): Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
52996
diff
changeset
|
575 (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
|
576 ((stringp value) |
ecf0e7a0567a
(desktop-file-version, desktop-after-read-hook): Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
52996
diff
changeset
|
577 (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
|
578 (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
|
579 ;; 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
|
580 (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
|
581 ((symbolp value) |
ecf0e7a0567a
(desktop-file-version, desktop-after-read-hook): Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
52996
diff
changeset
|
582 (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
|
583 ((vectorp value) |
5788
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
584 (let* ((special nil) |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
585 (pass1 (mapcar |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
586 (lambda (el) |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
587 (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
|
588 (if (null (car res)) |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
589 (setq special t)) |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
590 res)) |
54206
ecf0e7a0567a
(desktop-file-version, desktop-after-read-hook): Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
52996
diff
changeset
|
591 value))) |
5788
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
592 (if special |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
593 (cons nil (concat "(vector " |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
594 (mapconcat (lambda (el) |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
595 (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
|
596 (concat "'" (cdr el)) |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
597 (cdr el))) |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
598 pass1 |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
599 " ") |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
600 ")")) |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
601 (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
|
602 ((consp value) |
ecf0e7a0567a
(desktop-file-version, desktop-after-read-hook): Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
52996
diff
changeset
|
603 (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
|
604 newlist |
14754
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
605 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
|
606 anynil) |
eabd5e6e95de
(desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents:
7091
diff
changeset
|
607 (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
|
608 (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
|
609 (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
|
610 (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
|
611 (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
|
612 (if p |
eabd5e6e95de
(desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents:
7091
diff
changeset
|
613 (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
|
614 (el (car newlist))) |
14754
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
615 (or anynil (setq anynil (null (car last)))) |
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
616 (or anynil |
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
617 (setq newlist (cons '(must . ".") newlist))) |
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
618 (setq use-list* t) |
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
619 (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
|
620 (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
|
621 (if anynil |
eabd5e6e95de
(desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents:
7091
diff
changeset
|
622 (cons nil |
14754
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
623 (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
|
624 (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
|
625 (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
|
626 (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
|
627 (cdr el))) |
eabd5e6e95de
(desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents:
7091
diff
changeset
|
628 newlist |
eabd5e6e95de
(desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents:
7091
diff
changeset
|
629 " ") |
eabd5e6e95de
(desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents:
7091
diff
changeset
|
630 ")")) |
eabd5e6e95de
(desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents:
7091
diff
changeset
|
631 (cons 'must |
eabd5e6e95de
(desktop-internal-v2s): Default case fixed to return correct quote flag.
Richard M. Stallman <rms@gnu.org>
parents:
7091
diff
changeset
|
632 (concat "(" (mapconcat 'cdr newlist " ") ")"))))) |
54206
ecf0e7a0567a
(desktop-file-version, desktop-after-read-hook): Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
52996
diff
changeset
|
633 ((subrp value) |
5788
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
634 (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
|
635 (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
|
636 ")"))) |
54206
ecf0e7a0567a
(desktop-file-version, desktop-after-read-hook): Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
52996
diff
changeset
|
637 ((markerp value) |
ecf0e7a0567a
(desktop-file-version, desktop-after-read-hook): Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
52996
diff
changeset
|
638 (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
|
639 (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
|
640 (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
|
641 " (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
|
642 " (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
|
643 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
|
644 (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
|
645 (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
|
646 |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
647 ;; ---------------------------------------------------------------------------- |
54206
ecf0e7a0567a
(desktop-file-version, desktop-after-read-hook): Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
52996
diff
changeset
|
648 (defun desktop-value-to-string (value) |
10595 | 649 "Convert VALUE to a string that when read evaluates to the same value. |
650 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
|
651 (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
|
652 (float-output-format nil) |
54206
ecf0e7a0567a
(desktop-file-version, desktop-after-read-hook): Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
52996
diff
changeset
|
653 (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
|
654 (quote (car quote.txt)) |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
655 (txt (cdr quote.txt))) |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
656 (if (eq quote 'must) |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
657 (concat "'" txt) |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
658 txt))) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
659 |
5465
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
660 ;; ---------------------------------------------------------------------------- |
13154
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
661 (defun desktop-outvar (varspec) |
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
662 "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
|
663 The argument VARSPEC may be the variable name VAR (a symbol), |
68775
01a75c5115e7
(desktop-outvar): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
68651
diff
changeset
|
664 or a cons cell of the form (VAR . MAX-SIZE), |
13154
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
665 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
|
666 \(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
|
667 (let (var size) |
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
668 (if (consp varspec) |
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
669 (setq var (car varspec) size (cdr varspec)) |
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
670 (setq var varspec)) |
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
671 (if (boundp var) |
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
672 (progn |
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
673 (if (and (integerp size) |
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
674 (> size 0) |
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
675 (listp (eval var))) |
28719
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
676 (desktop-truncate (eval var) size)) |
13154
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
677 (insert "(setq " |
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
678 (symbol-name var) |
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
679 " " |
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
680 (desktop-value-to-string (symbol-value var)) |
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
681 ")\n"))))) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
682 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
683 ;; ---------------------------------------------------------------------------- |
5465
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
684 (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
|
685 "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
|
686 FILENAME is the visited file name, BUFNAME is the buffer name, and |
68775
01a75c5115e7
(desktop-outvar): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
68651
diff
changeset
|
687 MODE is the major mode. |
01a75c5115e7
(desktop-outvar): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
68651
diff
changeset
|
688 \n\(fn FILENAME BUFNAME MODE)" |
7240
195e64dad1eb
(desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents:
7200
diff
changeset
|
689 (let ((case-fold-search nil)) |
32366
40d8b29df57e
(desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30853
diff
changeset
|
690 (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
|
691 (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
|
692 (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
|
693 (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
|
694 (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
|
695 (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
|
696 (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
|
697 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
|
698 (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
|
699 (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
|
700 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
701 ;; ---------------------------------------------------------------------------- |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
702 (defun desktop-file-name (filename dirname) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
703 "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
|
704 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
|
705 (cond |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
706 ((not filename) nil) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
707 ((eq desktop-file-name-format 'tilde) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
708 (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
|
709 (cond |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
710 ((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
|
711 ((string= "./" relative-name) "~/") |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
712 ((string= "." relative-name) "~") |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
713 (t (concat "~/" relative-name))))) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
714 ((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
|
715 (t (expand-file-name filename)))) |
48143
8c7919f99581
(desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents:
43831
diff
changeset
|
716 |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
717 ;; ---------------------------------------------------------------------------- |
3404 | 718 (defun desktop-save (dirname) |
52674 | 719 "Save the desktop in a desktop file. |
720 Parameter DIRNAME specifies where to save the desktop file. | |
721 See also `desktop-base-file-name'." | |
3404 | 722 (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
|
723 (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
|
724 (setq dirname (file-name-as-directory (expand-file-name dirname))) |
3404 | 725 (save-excursion |
51441
b9a57b098ab3
(desktop-create-buffer): Undo last change.
Juanma Barranquero <lekktu@gmail.com>
parents:
51378
diff
changeset
|
726 (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
|
727 (info |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
728 (mapcar |
57038
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
729 #'(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
|
730 (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
|
731 (list |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
732 (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
|
733 (buffer-name) |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
734 major-mode |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
735 ;; minor modes |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
736 (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
|
737 (mapc |
27173676bedf
(desktop-save): Don't save minor modes without a known mode initialization function.
Lars Hansen <larsh@soem.dk>
parents:
55418
diff
changeset
|
738 #'(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
|
739 (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
|
740 (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
|
741 (symbol-value minor-mode) |
64893
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
742 (let* ((special (assq minor-mode desktop-minor-mode-table)) |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
743 (value (cond (special (cadr special)) |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
744 ((functionp minor-mode) minor-mode)))) |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
745 (when value (add-to-list 'ret value))))) |
51107
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
746 (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
|
747 ret) |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
748 (point) |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
749 (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
|
750 buffer-read-only |
55059
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
751 ;; 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
|
752 (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
|
753 (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
|
754 (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
|
755 (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
|
756 (ll)) |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
757 (while locals |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
758 (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
|
759 (if here |
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
760 (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
|
761 (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
|
762 (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
|
763 (setq locals (cdr locals))) |
57038
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
764 ll))) |
51107
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
765 (buffer-list))) |
59412
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
766 (eager desktop-restore-eager) |
51107
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
767 (buf (get-buffer-create "*desktop*"))) |
3404 | 768 (set-buffer buf) |
769 (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
|
770 |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
771 (insert |
59487
c1de47aaf80f
(desktop-save): Add `mode: emacs-lisp' to the local
Juri Linkov <juri@jurta.org>
parents:
59436
diff
changeset
|
772 ";; -*- mode: emacs-lisp; coding: emacs-mule; -*-\n" |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
773 desktop-header |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
774 ";; Created " (current-time-string) "\n" |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
775 ";; 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
|
776 ";; Emacs version " emacs-version "\n\n" |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
777 ";; Global section:\n") |
58180
fa5bfbfb3478
(desktop-create-buffer, desktop-save): Avoid some consing by using mapc
Eli Zaretskii <eliz@gnu.org>
parents:
58140
diff
changeset
|
778 (mapc (function desktop-outvar) desktop-globals-to-save) |
3404 | 779 (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
|
780 (insert |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
781 "(setq kill-ring-yank-pointer (nthcdr " |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
782 (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
|
783 " kill-ring))\n")) |
3404 | 784 |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
785 (insert "\n;; Buffer section -- buffers listed in same order as in buffer list:\n") |
58180
fa5bfbfb3478
(desktop-create-buffer, desktop-save): Avoid some consing by using mapc
Eli Zaretskii <eliz@gnu.org>
parents:
58140
diff
changeset
|
786 (mapc #'(lambda (l) |
59412
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
787 (when (apply 'desktop-save-buffer-p l) |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
788 (insert "(" |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
789 (if (or (not (integerp eager)) |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
790 (unless (zerop eager) |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
791 (setq eager (1- eager)) |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
792 t)) |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
793 "desktop-create-buffer" |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
794 "desktop-append-buffer-args") |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
795 " " |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
796 desktop-file-version) |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
797 (mapc #'(lambda (e) |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
798 (insert "\n " (desktop-value-to-string e))) |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
799 l) |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
800 (insert ")\n\n"))) |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
801 info) |
3404 | 802 (setq default-directory dirname) |
38618
c41fb9fae096
(desktop-save): Bind coding-system-for-write to
Gerd Moellmann <gerd@gnu.org>
parents:
38592
diff
changeset
|
803 (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
|
804 (write-region (point-min) (point-max) filename nil 'nomessage)))) |
3404 | 805 (setq desktop-dirname dirname)) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
806 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
807 ;; ---------------------------------------------------------------------------- |
3404 | 808 (defun desktop-remove () |
52674 | 809 "Delete desktop file in `desktop-dirname'. |
810 This function also sets `desktop-dirname' to nil." | |
3404 | 811 (interactive) |
52674 | 812 (when desktop-dirname |
813 (let ((filename (expand-file-name desktop-base-file-name desktop-dirname))) | |
814 (setq desktop-dirname nil) | |
815 (when (file-exists-p filename) | |
816 (delete-file filename))))) | |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
817 |
59412
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
818 (defvar desktop-buffer-args-list nil |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
819 "List of args for `desktop-create-buffer'.") |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
820 |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
821 (defvar desktop-lazy-timer nil) |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
822 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
823 ;; ---------------------------------------------------------------------------- |
21303
346595905ae4
(desktop-load-default): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents:
20772
diff
changeset
|
824 ;;;###autoload |
52674 | 825 (defun desktop-read (&optional dirname) |
826 "Read and process the desktop file in directory DIRNAME. | |
827 Look for a desktop file in DIRNAME, or if DIRNAME is omitted, look in | |
828 directories listed in `desktop-path'. If a desktop file is found, it | |
64490
e22e42dbaf76
(desktop-enable, desktop-buffer-modes-to-save, (desktop-buffer-misc-functions,
Juanma Barranquero <lekktu@gmail.com>
parents:
64254
diff
changeset
|
829 is processed and `desktop-after-read-hook' is run. If no desktop file |
52674 | 830 is found, clear the desktop and run `desktop-no-desktop-file-hook'. |
831 This function is a no-op when Emacs is running in batch mode. | |
832 It returns t if a desktop file was loaded, nil otherwise." | |
833 (interactive) | |
834 (unless noninteractive | |
835 (setq desktop-dirname | |
836 (file-name-as-directory | |
837 (expand-file-name | |
838 (or | |
839 ;; If DIRNAME is specified, use it. | |
840 (and (< 0 (length dirname)) dirname) | |
841 ;; Otherwise search desktop file in desktop-path. | |
842 (let ((dirs desktop-path)) | |
843 (while | |
844 (and | |
845 dirs | |
846 (not | |
847 (file-exists-p (expand-file-name desktop-base-file-name (car dirs))))) | |
848 (setq dirs (cdr dirs))) | |
849 (and dirs (car dirs))) | |
850 ;; If not found and `desktop-path' is non-nil, use its first element. | |
851 (and desktop-path (car desktop-path)) | |
852 ;; Default: Home directory. | |
853 "~")))) | |
854 (if (file-exists-p (expand-file-name desktop-base-file-name desktop-dirname)) | |
855 ;; Desktop file found, process it. | |
55059
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
856 (let ((desktop-first-buffer nil) |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
857 (desktop-buffer-ok-count 0) |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
858 (desktop-buffer-fail-count 0)) |
59412
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
859 (setq desktop-lazy-timer nil) |
52674 | 860 ;; Evaluate desktop buffer. |
861 (load (expand-file-name desktop-base-file-name desktop-dirname) t t t) | |
862 ;; `desktop-create-buffer' puts buffers at end of the buffer list. | |
863 ;; We want buffers existing prior to evaluating the desktop (and not reused) | |
864 ;; to be placed at the end of the buffer list, so we move them here. | |
58537
619031e477a8
(desktop-read): Replace mapcar with mapc.
Lars Hansen <larsh@soem.dk>
parents:
58180
diff
changeset
|
865 (mapc 'bury-buffer |
619031e477a8
(desktop-read): Replace mapcar with mapc.
Lars Hansen <larsh@soem.dk>
parents:
58180
diff
changeset
|
866 (nreverse (cdr (memq desktop-first-buffer (nreverse (buffer-list)))))) |
52674 | 867 (switch-to-buffer (car (buffer-list))) |
868 (run-hooks 'desktop-delay-hook) | |
869 (setq desktop-delay-hook nil) | |
870 (run-hooks 'desktop-after-read-hook) | |
59412
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
871 (message "Desktop: %d buffer%s restored%s%s." |
55059
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
872 desktop-buffer-ok-count |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
873 (if (= 1 desktop-buffer-ok-count) "" "s") |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
874 (if (< 0 desktop-buffer-fail-count) |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
875 (format ", %d failed to restore" desktop-buffer-fail-count) |
59412
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
876 "") |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
877 (if desktop-buffer-args-list |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
878 (format ", %d to restore lazily" |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
879 (length desktop-buffer-args-list)) |
55059
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
880 "")) |
52674 | 881 t) |
882 ;; No desktop file found. | |
883 (desktop-clear) | |
884 (let ((default-directory desktop-dirname)) | |
885 (run-hooks 'desktop-no-desktop-file-hook)) | |
886 (message "No desktop file.") | |
887 nil))) | |
888 | |
889 ;; ---------------------------------------------------------------------------- | |
890 ;; Maintained for backward compatibility | |
891 ;;;###autoload | |
3404 | 892 (defun desktop-load-default () |
10595 | 893 "Load the `default' start-up library manually. |
52674 | 894 Also inhibit further loading of it." |
64674
b110ecf69f54
(desktop-save-buffer): Fix typos in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
64566
diff
changeset
|
895 (unless inhibit-default-init ; safety check |
b110ecf69f54
(desktop-save-buffer): Fix typos in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
64566
diff
changeset
|
896 (load "default" t t) |
b110ecf69f54
(desktop-save-buffer): Fix typos in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
64566
diff
changeset
|
897 (setq inhibit-default-init t))) |
b110ecf69f54
(desktop-save-buffer): Fix typos in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
64566
diff
changeset
|
898 (make-obsolete 'desktop-load-default |
b110ecf69f54
(desktop-save-buffer): Fix typos in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
64566
diff
changeset
|
899 'desktop-save-mode "22.1") |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
900 |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
901 ;; ---------------------------------------------------------------------------- |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
902 ;;;###autoload |
52674 | 903 (defun desktop-change-dir (dirname) |
904 "Change to desktop saved in DIRNAME. | |
905 Kill the desktop as specified by variables `desktop-save-mode' and | |
906 `desktop-save', then clear the desktop and load the desktop file in | |
907 directory DIRNAME." | |
908 (interactive "DChange to directory: ") | |
909 (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
|
910 (desktop-kill) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
911 (desktop-clear) |
52674 | 912 (desktop-read dirname)) |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
59487
diff
changeset
|
913 |
52674 | 914 ;; ---------------------------------------------------------------------------- |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
915 ;;;###autoload |
52674 | 916 (defun desktop-save-in-desktop-dir () |
917 "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
|
918 (interactive) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
919 (if desktop-dirname |
64674
b110ecf69f54
(desktop-save-buffer): Fix typos in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
64566
diff
changeset
|
920 (desktop-save desktop-dirname) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
921 (call-interactively 'desktop-save)) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
922 (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
|
923 |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
924 ;; ---------------------------------------------------------------------------- |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
925 ;;;###autoload |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
926 (defun desktop-revert () |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
927 "Revert to the last loaded desktop." |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
928 (interactive) |
52674 | 929 (unless desktop-dirname |
930 (error "Unknown desktop directory")) | |
931 (unless (file-exists-p (expand-file-name desktop-base-file-name desktop-dirname)) | |
932 (error "No desktop file found")) | |
933 (desktop-clear) | |
934 (desktop-read desktop-dirname)) | |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
935 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
936 ;; ---------------------------------------------------------------------------- |
55059
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
937 (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
|
938 desktop-buffer-name |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
939 desktop-buffer-misc) |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
940 "Restore a file buffer." |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
941 (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
|
942 (defvar desktop-buffer-major-mode) |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
943 (defvar desktop-buffer-locals)) |
14755
3d473ed8c718
Global vars mam, fn, bn renamed.
Richard M. Stallman <rms@gnu.org>
parents:
14754
diff
changeset
|
944 (if desktop-buffer-file-name |
3d473ed8c718
Global vars mam, fn, bn renamed.
Richard M. Stallman <rms@gnu.org>
parents:
14754
diff
changeset
|
945 (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
|
946 (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
|
947 desktop-buffer-file-name))) |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
948 (if desktop-missing-file-warning |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
949 (y-or-n-p (concat msg " Re-create? ")) |
65582
4d1085b02d64
Message format spec fixes (1)
Deepak Goel <deego@gnufans.org>
parents:
64963
diff
changeset
|
950 (message "%s" msg) |
55059
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
951 nil))) |
52996
c9843219861e
(desktop-locals-to-save): Add buffer-file-coding-system.
Lars Hansen <larsh@soem.dk>
parents:
52674
diff
changeset
|
952 (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
|
953 (coding-system-for-read |
c9843219861e
(desktop-locals-to-save): Add buffer-file-coding-system.
Lars Hansen <larsh@soem.dk>
parents:
52674
diff
changeset
|
954 (or coding-system-for-read |
c9843219861e
(desktop-locals-to-save): Add buffer-file-coding-system.
Lars Hansen <larsh@soem.dk>
parents:
52674
diff
changeset
|
955 (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
|
956 desktop-buffer-locals)))) |
c9843219861e
(desktop-locals-to-save): Add buffer-file-coding-system.
Lars Hansen <larsh@soem.dk>
parents:
52674
diff
changeset
|
957 (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
|
958 (condition-case nil |
40d8b29df57e
(desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30853
diff
changeset
|
959 (switch-to-buffer buf) |
43831
7837693f5bac
(desktop-buffer-handlers): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
41150
diff
changeset
|
960 (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
|
961 (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
|
962 (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
|
963 (funcall desktop-buffer-major-mode)) |
43831
7837693f5bac
(desktop-buffer-handlers): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
41150
diff
changeset
|
964 buf) |
55059
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
965 nil))) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
966 |
64893
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
967 (defun desktop-load-file (function) |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
968 "Load the file where auto loaded FUNCTION is defined." |
66037
89bec3b605ff
(desktop-load-file): Do nothing when FUNCTION is nil.
Lars Hansen <larsh@soem.dk>
parents:
65582
diff
changeset
|
969 (when function |
68344
ffdb60daf52a
(desktop-load-file): Check for `fboundp' before calling `symbol-function'.
Juri Linkov <juri@jurta.org>
parents:
67560
diff
changeset
|
970 (let ((fcell (and (fboundp function) (symbol-function function)))) |
66037
89bec3b605ff
(desktop-load-file): Do nothing when FUNCTION is nil.
Lars Hansen <larsh@soem.dk>
parents:
65582
diff
changeset
|
971 (when (and (listp fcell) |
89bec3b605ff
(desktop-load-file): Do nothing when FUNCTION is nil.
Lars Hansen <larsh@soem.dk>
parents:
65582
diff
changeset
|
972 (eq 'autoload (car fcell))) |
89bec3b605ff
(desktop-load-file): Do nothing when FUNCTION is nil.
Lars Hansen <larsh@soem.dk>
parents:
65582
diff
changeset
|
973 (load (cadr fcell)))))) |
64893
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
974 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
975 ;; ---------------------------------------------------------------------------- |
55179 | 976 ;; Create a buffer, load its file, set its mode, ...; |
977 ;; called from Desktop file only. | |
40210
01666fd1b210
(desktop-last-buffer): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
38798
diff
changeset
|
978 |
64893
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
979 ;; Just to silence the byte compiler. |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
980 (eval-when-compile |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
981 (defvar desktop-first-buffer)) ; Dynamically bound in `desktop-read' |
40210
01666fd1b210
(desktop-last-buffer): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
38798
diff
changeset
|
982 |
57038
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
983 (defun desktop-create-buffer |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
984 (desktop-file-version |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
985 desktop-buffer-file-name |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
986 desktop-buffer-name |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
987 desktop-buffer-major-mode |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
988 desktop-buffer-minor-modes |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
989 desktop-buffer-point |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
990 desktop-buffer-mark |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
991 desktop-buffer-read-only |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
992 desktop-buffer-misc |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
993 &optional |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
994 desktop-buffer-locals) |
55059
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
995 ;; 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
|
996 (eval-when-compile |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
997 (defvar desktop-buffer-ok-count) |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
998 (defvar desktop-buffer-fail-count)) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
999 ;; 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
|
1000 ;; 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
|
1001 (save-current-buffer |
64893
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
1002 ;; Give major mode module a chance to add a handler. |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
1003 (desktop-load-file desktop-buffer-major-mode) |
57038
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
1004 (let ((buffer-list (buffer-list)) |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
1005 (result |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
1006 (condition-case err |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
1007 (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
|
1008 desktop-buffer-mode-handlers)) |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
1009 'desktop-restore-file-buffer) |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
1010 desktop-buffer-file-name |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
1011 desktop-buffer-name |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
1012 desktop-buffer-misc) |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
1013 (error |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
1014 (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
|
1015 desktop-buffer-name |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
1016 (error-message-string err)) |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
1017 (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
|
1018 nil)))) |
55059
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
1019 (if (bufferp result) |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
1020 (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
|
1021 (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
|
1022 (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
|
1023 ;; 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
|
1024 ;; 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
|
1025 (unless (< desktop-file-version 206) |
58537
619031e477a8
(desktop-read): Replace mapcar with mapc.
Lars Hansen <larsh@soem.dk>
parents:
58180
diff
changeset
|
1026 (mapc 'bury-buffer buffer-list) |
51107
0c33d2fd9ae4
(desktop-save): Ensure parameter is expanded and ends with a slash before
Juanma Barranquero <lekktu@gmail.com>
parents:
50642
diff
changeset
|
1027 (when result (bury-buffer result))) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1028 (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
|
1029 (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
|
1030 (setq desktop-first-buffer result)) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1031 (set-buffer result) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1032 (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
|
1033 (rename-buffer desktop-buffer-name)) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1034 ;; minor modes |
57038
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
1035 (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
|
1036 (auto-fill-mode 1)) |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
1037 ((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
|
1038 (auto-fill-mode 0)) |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
1039 (t |
58180
fa5bfbfb3478
(desktop-create-buffer, desktop-save): Avoid some consing by using mapc
Eli Zaretskii <eliz@gnu.org>
parents:
58140
diff
changeset
|
1040 (mapc #'(lambda (minor-mode) |
64893
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
1041 ;; Give minor mode module a chance to add a handler. |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
1042 (desktop-load-file minor-mode) |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
1043 (let ((handler (cdr (assq minor-mode desktop-minor-mode-handlers)))) |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
1044 (if handler |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
1045 (funcall handler desktop-buffer-locals) |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
1046 (when (functionp minor-mode) |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
1047 (funcall minor-mode 1))))) |
58180
fa5bfbfb3478
(desktop-create-buffer, desktop-save): Avoid some consing by using mapc
Eli Zaretskii <eliz@gnu.org>
parents:
58140
diff
changeset
|
1048 desktop-buffer-minor-modes))) |
64893
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
1049 ;; 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
|
1050 ;; 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
|
1051 (when desktop-buffer-point |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
1052 (goto-char |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
1053 (condition-case err |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
1054 ;; 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
|
1055 (eval desktop-buffer-point) |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
1056 (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
|
1057 (when desktop-buffer-mark |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1058 (if (consp desktop-buffer-mark) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1059 (progn |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1060 (set-mark (car desktop-buffer-mark)) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1061 (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
|
1062 (set-mark desktop-buffer-mark))) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1063 ;; 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
|
1064 (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
|
1065 (while desktop-buffer-locals |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1066 (let ((this (car desktop-buffer-locals))) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1067 (if (consp this) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1068 ;; 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
|
1069 (progn |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1070 (make-local-variable (car this)) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1071 (set (car this) (cdr this))) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1072 ;; an entry of the form `symbol' |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1073 (make-local-variable this) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1074 (makunbound this))) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1075 (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
|
1076 |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1077 ;; ---------------------------------------------------------------------------- |
5465
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
1078 ;; 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
|
1079 (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
|
1080 desktop-buffer-major-mode |
14756
aabf776c3b6a
Global var `misc' renamed.
Richard M. Stallman <rms@gnu.org>
parents:
14755
diff
changeset
|
1081 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
|
1082 (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
|
1083 desktop-buffer-major-mode (cdr mim) pt mk ro |
aabf776c3b6a
Global var `misc' renamed.
Richard M. Stallman <rms@gnu.org>
parents:
14755
diff
changeset
|
1084 desktop-buffer-misc |
5465
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
1085 (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
|
1086 (cons 'fill-column fc) |
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
1087 (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
|
1088 (cons 'case-replace cr) |
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
1089 (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
|
1090 |
59412
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1091 (defun desktop-append-buffer-args (&rest args) |
64490
e22e42dbaf76
(desktop-enable, desktop-buffer-modes-to-save, (desktop-buffer-misc-functions,
Juanma Barranquero <lekktu@gmail.com>
parents:
64254
diff
changeset
|
1092 "Append ARGS at end of `desktop-buffer-args-list'. |
59412
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1093 ARGS must be an argument list for `desktop-create-buffer'." |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1094 (setq desktop-buffer-args-list (nconc desktop-buffer-args-list (list args))) |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1095 (unless desktop-lazy-timer |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1096 (setq desktop-lazy-timer |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1097 (run-with-idle-timer desktop-lazy-idle-delay t 'desktop-idle-create-buffers)))) |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1098 |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1099 (defun desktop-lazy-create-buffer () |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1100 "Pop args from `desktop-buffer-args-list', create buffer and bury it." |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1101 (when desktop-buffer-args-list |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1102 (let* ((remaining (length desktop-buffer-args-list)) |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1103 (args (pop desktop-buffer-args-list)) |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1104 (buffer-name (nth 2 args)) |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1105 (msg (format "Desktop lazily opening %s (%s remaining)..." |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1106 buffer-name remaining))) |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1107 (when desktop-lazy-verbose |
65582
4d1085b02d64
Message format spec fixes (1)
Deepak Goel <deego@gnufans.org>
parents:
64963
diff
changeset
|
1108 (message "%s" msg)) |
59412
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1109 (let ((desktop-first-buffer nil) |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1110 (desktop-buffer-ok-count 0) |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1111 (desktop-buffer-fail-count 0)) |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1112 (apply 'desktop-create-buffer args) |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1113 (run-hooks 'desktop-delay-hook) |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1114 (setq desktop-delay-hook nil) |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1115 (bury-buffer (get-buffer buffer-name)) |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1116 (when desktop-lazy-verbose |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1117 (message "%s%s" msg (if (> desktop-buffer-ok-count 0) "done" "failed"))))))) |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1118 |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1119 (defun desktop-idle-create-buffers () |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1120 "Create buffers until the user does something, then stop. |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1121 If there are no buffers left to create, kill the timer." |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1122 (let ((repeat 1)) |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1123 (while (and repeat desktop-buffer-args-list) |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1124 (save-window-excursion |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1125 (desktop-lazy-create-buffer)) |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1126 (setq repeat (sit-for 0.2)) |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1127 (unless desktop-buffer-args-list |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1128 (cancel-timer desktop-lazy-timer) |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1129 (setq desktop-lazy-timer nil) |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1130 (message "Lazy desktop load complete") |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1131 (sit-for 3) |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1132 (message ""))))) |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1133 |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1134 (defun desktop-lazy-complete () |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1135 "Run the desktop load to completion." |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1136 (interactive) |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1137 (let ((desktop-lazy-verbose t)) |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1138 (while desktop-buffer-args-list |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1139 (save-window-excursion |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1140 (desktop-lazy-create-buffer))) |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1141 (message "Lazy desktop load complete"))) |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1142 |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1143 (defun desktop-lazy-abort () |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1144 "Abort lazy loading of the desktop." |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1145 (interactive) |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1146 (when desktop-lazy-timer |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1147 (cancel-timer desktop-lazy-timer) |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1148 (setq desktop-lazy-timer nil)) |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1149 (when desktop-buffer-args-list |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1150 (setq desktop-buffer-args-list nil) |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1151 (when (interactive-p) |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1152 (message "Lazy desktop load aborted")))) |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1153 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
1154 ;; ---------------------------------------------------------------------------- |
52674 | 1155 ;; 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
|
1156 ;; 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
|
1157 ;; after finishing loading the init file. |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1158 ;; 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
|
1159 ;; 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
|
1160 (add-hook |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1161 'after-init-hook |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1162 '(lambda () |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1163 (let ((key "--no-desktop")) |
61638
ef63bf685348
Make "--no-desktop" turn off `desktop-save-mode'.
Lars Hansen <larsh@soem.dk>
parents:
61236
diff
changeset
|
1164 (when (member key command-line-args) |
ef63bf685348
Make "--no-desktop" turn off `desktop-save-mode'.
Lars Hansen <larsh@soem.dk>
parents:
61236
diff
changeset
|
1165 (setq command-line-args (delete key command-line-args)) |
ef63bf685348
Make "--no-desktop" turn off `desktop-save-mode'.
Lars Hansen <larsh@soem.dk>
parents:
61236
diff
changeset
|
1166 (setq desktop-save-mode nil))) |
ef63bf685348
Make "--no-desktop" turn off `desktop-save-mode'.
Lars Hansen <larsh@soem.dk>
parents:
61236
diff
changeset
|
1167 (when desktop-save-mode (desktop-read)))) |
20526
ec0a8ccddd6c
(desktop-enable): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18581
diff
changeset
|
1168 |
3405 | 1169 (provide 'desktop) |
3404 | 1170 |
52401 | 1171 ;;; 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
|
1172 ;;; desktop.el ends here |