Mercurial > emacs
annotate lisp/desktop.el @ 107824:ffe32691e3ab
Update comint-password-prompt-regexp (Bug#2817).
* comint.el (comint-password-prompt-regexp): Use regexp-opt, and
recognize ssh-keygen prompt (Bug#2817).
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Sat, 10 Apr 2010 19:54:50 -0400 |
parents | c56cc351f300 |
children | 5e9162ac53b2 21c602686f38 |
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, |
107543 | 4 ;; 2004, 2005, 2006, 2007, 2008, 2009, 2010 |
5 ;; Free Software Foundation, Inc. | |
3404 | 6 |
7 ;; Author: Morten Welinder <terra@diku.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 | |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94425
diff
changeset
|
13 ;; GNU Emacs is free software: you can redistribute it and/or modify |
3404 | 14 ;; it under the terms of the GNU General Public License as published by |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94425
diff
changeset
|
15 ;; the Free Software Foundation, either version 3 of the License, or |
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94425
diff
changeset
|
16 ;; (at your option) any later version. |
3404 | 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 | |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94425
diff
changeset
|
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
3404 | 25 |
26 ;;; Commentary: | |
27 | |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
28 ;; Save the Desktop, i.e., |
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
29 ;; - some global variables |
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
30 ;; - the list of buffers with associated files. For each buffer also |
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
31 ;; - the major mode |
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
32 ;; - the default directory |
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
33 ;; - the point |
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
34 ;; - the mark & mark-active |
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
35 ;; - buffer-read-only |
5465
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
36 ;; - some local variables |
3404 | 37 |
52674 | 38 ;; To use this, use customize to turn on desktop-save-mode or add the |
39 ;; 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
|
40 ;; |
52674 | 41 ;; (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
|
42 ;; |
52674 | 43 ;; For further usage information, look at the section |
102698 | 44 ;; (info "(emacs)Saving Emacs Sessions") in the GNU Emacs Manual. |
3404 | 45 |
52674 | 46 ;; When the desktop module is loaded, the function `desktop-kill' is |
77115
7596f1771948
(desktop-save, desktop-create-buffer): Replace mapcar with dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76978
diff
changeset
|
47 ;; added to the `kill-emacs-hook'. This function is responsible for |
52674 | 48 ;; saving the desktop when Emacs is killed. Furthermore an anonymous |
77115
7596f1771948
(desktop-save, desktop-create-buffer): Replace mapcar with dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76978
diff
changeset
|
49 ;; function is added to the `after-init-hook'. This function is |
52674 | 50 ;; 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
|
51 |
64893
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
52 ;; Special handling. |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
53 ;; ----------------- |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
54 ;; 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
|
55 ;; 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
|
56 ;; `desktop-buffer-mode-handlers' is an alist of major mode specific functions |
77115
7596f1771948
(desktop-save, desktop-create-buffer): Replace mapcar with dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76978
diff
changeset
|
57 ;; 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
|
58 ;; |
64893
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
59 ;; (MAJOR-MODE . RESTORE-BUFFER-FUNCTION). |
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 ;; Functions listed are called by `desktop-create-buffer' when `desktop-read' |
77115
7596f1771948
(desktop-save, desktop-create-buffer): Replace mapcar with dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76978
diff
changeset
|
62 ;; evaluates the desktop file. Buffers with a major mode not specified here, |
64893
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
63 ;; 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
|
64 ;; `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
|
65 ;; non-standard minor modes. Elements must have the form |
68775
01a75c5115e7
(desktop-outvar): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
68651
diff
changeset
|
66 ;; |
64893
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
67 ;; (MINOR-MODE . RESTORE-FUNCTION). |
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 ;; 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
|
70 ;; 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
|
71 ;; 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
|
72 ;; needs a special handler, then place code like |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
73 |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
74 ;; (defun foo-restore-desktop-buffer |
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 ;; (add-to-list 'desktop-buffer-mode-handlers |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
77 ;; '(foo-mode . foo-restore-desktop-buffer)) |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
78 |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
79 ;; or |
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 ;; (defun bar-desktop-restore |
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 ;; (add-to-list 'desktop-minor-mode-handlers |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
84 ;; '(bar-mode . bar-desktop-restore)) |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
85 |
94425
780f88412851
(desktop-minor-mode-table): Add `savehist-mode'.
Juanma Barranquero <lekktu@gmail.com>
parents:
94026
diff
changeset
|
86 ;; in the module itself, and make sure that the mode function is |
77115
7596f1771948
(desktop-save, desktop-create-buffer): Replace mapcar with dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76978
diff
changeset
|
87 ;; autoloaded. See the docstrings of `desktop-buffer-mode-handlers' and |
64893
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
88 ;; `desktop-minor-mode-handlers' for more info. |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
89 |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
90 ;; Minor modes. |
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 ;; 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
|
93 ;; manual) are handled in the following way: |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
94 ;; 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
|
95 ;; 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
|
96 ;; `minor-mode-alist' that have a non-nil value. |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
97 ;; 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
|
98 ;; `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
|
99 ;; 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
|
100 ;; 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
|
101 ;; `desktop-minor-mode-table' to map minor mode variables to minor mode |
77115
7596f1771948
(desktop-save, desktop-create-buffer): Replace mapcar with dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76978
diff
changeset
|
102 ;; functions before writing `desktop-minor-modes'. If a minor mode has a |
64893
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
103 ;; 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
|
104 |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
105 ;; (NAME RESTORE-FUNCTION) |
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 ;; 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
|
108 ;; 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
|
109 ;; `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
|
110 ;; function different from the usual minor mode function. |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
111 ;; --------------------------------------------------------------------------- |
28719
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
112 |
5465
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
113 ;; 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
|
114 ;; 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
|
115 ;; 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
|
116 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
117 ;; 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
|
118 ;; `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
|
119 ;; 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
|
120 |
7240
195e64dad1eb
(desktop-files-not-to-save): New variable to exclude certain files -- magic
Karl Heuer <kwzh@gnu.org>
parents:
7200
diff
changeset
|
121 ;; 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
|
122 ;; 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
|
123 ;; 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
|
124 ;; 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
|
125 ;; 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
|
126 ;; 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
|
127 ;; 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
|
128 ;; --------------------------------------------------------------------------- |
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
129 ;; TODO: |
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 ;; Save window configuration. |
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
132 ;; Recognize more minor modes. |
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
133 ;; Save mark rings. |
3404 | 134 |
135 ;;; Code: | |
136 | |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
137 (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
|
138 "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
|
139 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
|
140 backward compatibility.") |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
141 |
5465
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
142 ;; ---------------------------------------------------------------------------- |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
143 ;; 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
|
144 ;; ---------------------------------------------------------------------------- |
17411
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17204
diff
changeset
|
145 |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17204
diff
changeset
|
146 (defgroup desktop nil |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17204
diff
changeset
|
147 "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
|
148 :group 'frames) |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17204
diff
changeset
|
149 |
52674 | 150 ;;;###autoload |
151 (define-minor-mode desktop-save-mode | |
152 "Toggle desktop saving mode. | |
153 With numeric ARG, turn desktop saving on if ARG is positive, off | |
71453
bef13fc7f695
(desktop-full-file-name): New function.
Lars Hansen <larsh@soem.dk>
parents:
70653
diff
changeset
|
154 otherwise. If desktop saving is turned on, the state of Emacs is |
bef13fc7f695
(desktop-full-file-name): New function.
Lars Hansen <larsh@soem.dk>
parents:
70653
diff
changeset
|
155 saved from one session to another. See variable `desktop-save' |
bef13fc7f695
(desktop-full-file-name): New function.
Lars Hansen <larsh@soem.dk>
parents:
70653
diff
changeset
|
156 and function `desktop-read' for details." |
52674 | 157 :global t |
158 :group 'desktop) | |
159 | |
160 ;; Maintained for backward compatibility | |
64674
b110ecf69f54
(desktop-save-buffer): Fix typos in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
64566
diff
changeset
|
161 (define-obsolete-variable-alias 'desktop-enable |
b110ecf69f54
(desktop-save-buffer): Fix typos in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
64566
diff
changeset
|
162 'desktop-save-mode "22.1") |
20526
ec0a8ccddd6c
(desktop-enable): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18581
diff
changeset
|
163 |
78046
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
164 (defun desktop-save-mode-off () |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
165 "Disable `desktop-save-mode'. Provided for use in hooks." |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
166 (desktop-save-mode 0)) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
167 |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
168 (defcustom desktop-save 'ask-if-new |
100171 | 169 "Specifies whether the desktop should be saved when it is killed. |
52674 | 170 A desktop is killed when the user changes desktop or quits Emacs. |
171 Possible values are: | |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
172 t -- always save. |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
173 ask -- always ask. |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
174 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
|
175 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
|
176 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
|
177 nil -- never save. |
52674 | 178 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
|
179 The variables `desktop-dirname' and `desktop-base-file-name' |
52674 | 180 determine where the desktop is saved." |
71453
bef13fc7f695
(desktop-full-file-name): New function.
Lars Hansen <larsh@soem.dk>
parents:
70653
diff
changeset
|
181 :type |
bef13fc7f695
(desktop-full-file-name): New function.
Lars Hansen <larsh@soem.dk>
parents:
70653
diff
changeset
|
182 '(choice |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
183 (const :tag "Always save" t) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
184 (const :tag "Always ask" ask) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
185 (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
|
186 (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
|
187 (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
|
188 (const :tag "Never save" nil)) |
58140
b72ba185298b
(desktop-buffer-mode-handlers, desktop-after-read-hook,
Lars Hansen <larsh@soem.dk>
parents:
57038
diff
changeset
|
189 :group 'desktop |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
59487
diff
changeset
|
190 :version "22.1") |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
191 |
78046
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
192 (defcustom desktop-load-locked-desktop 'ask |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
193 "Specifies whether the desktop should be loaded if locked. |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
194 Possible values are: |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
195 t -- load anyway. |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
196 nil -- don't load. |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
197 ask -- ask the user. |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
198 If the value is nil, or `ask' and the user chooses not to load the desktop, |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
199 the normal hook `desktop-not-loaded-hook' is run." |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
200 :type |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
201 '(choice |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
202 (const :tag "Load anyway" t) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
203 (const :tag "Don't load" nil) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
204 (const :tag "Ask the user" ask)) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
205 :group 'desktop |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
206 :version "22.2") |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
207 |
94026
85846e73fafe
Move non-autoloaded define-obsolete-variable-alias calls for
Glenn Morris <rgm@gnu.org>
parents:
92944
diff
changeset
|
208 (define-obsolete-variable-alias 'desktop-basefilename |
85846e73fafe
Move non-autoloaded define-obsolete-variable-alias calls for
Glenn Morris <rgm@gnu.org>
parents:
92944
diff
changeset
|
209 'desktop-base-file-name "22.1") |
85846e73fafe
Move non-autoloaded define-obsolete-variable-alias calls for
Glenn Morris <rgm@gnu.org>
parents:
92944
diff
changeset
|
210 |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
211 (defcustom desktop-base-file-name |
16037
a1e88c05b53c
(desktop-basefilename): Use convert-standard-filename.
Richard M. Stallman <rms@gnu.org>
parents:
14756
diff
changeset
|
212 (convert-standard-filename ".emacs.desktop") |
52674 | 213 "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
|
214 :type 'file |
ec0a8ccddd6c
(desktop-enable): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18581
diff
changeset
|
215 :group 'desktop) |
3404 | 216 |
78046
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
217 (defcustom desktop-base-lock-name |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
218 (convert-standard-filename ".emacs.desktop.lock") |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
219 "Name of lock file for Emacs desktop, excluding the directory part." |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
220 :type 'file |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
221 :group 'desktop |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
222 :version "22.2") |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
223 |
105031
7700dc1d76fd
(desktop-path): Check user-emacs-directory.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
103978
diff
changeset
|
224 (defcustom desktop-path (list "." user-emacs-directory "~") |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
225 "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
|
226 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
|
227 :type '(repeat directory) |
58140
b72ba185298b
(desktop-buffer-mode-handlers, desktop-after-read-hook,
Lars Hansen <larsh@soem.dk>
parents:
57038
diff
changeset
|
228 :group 'desktop |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
59487
diff
changeset
|
229 :version "22.1") |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
230 |
17411
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17204
diff
changeset
|
231 (defcustom desktop-missing-file-warning nil |
70653
019755175634
(desktop-missing-file-warning): Fix docstring.
Lars Hansen <larsh@soem.dk>
parents:
70644
diff
changeset
|
232 "If non-nil, offer to recreate the buffer of a deleted file. |
55155
519f44af960a
(desktop-buffer-misc-data-function): Rename to desktop-save-buffer and change docstring.
Lars Hansen <larsh@soem.dk>
parents:
55059
diff
changeset
|
233 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
|
234 `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
|
235 |
519f44af960a
(desktop-buffer-misc-data-function): Rename to desktop-save-buffer and change docstring.
Lars Hansen <larsh@soem.dk>
parents:
55059
diff
changeset
|
236 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
|
237 :type 'boolean |
58140
b72ba185298b
(desktop-buffer-mode-handlers, desktop-after-read-hook,
Lars Hansen <larsh@soem.dk>
parents:
57038
diff
changeset
|
238 :group 'desktop |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
59487
diff
changeset
|
239 :version "22.1") |
3404 | 240 |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
241 (defcustom desktop-no-desktop-file-hook nil |
52674 | 242 "Normal hook run when `desktop-read' can't find a desktop file. |
71453
bef13fc7f695
(desktop-full-file-name): New function.
Lars Hansen <larsh@soem.dk>
parents:
70653
diff
changeset
|
243 Run in the directory in which the desktop file was sought. |
61236
65075d5373df
(desktop-no-desktop-file-hook, desktop-after-read-hook): Fix docstring.
Lute Kamstra <lute@gnu.org>
parents:
59996
diff
changeset
|
244 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
|
245 :type 'hook |
58140
b72ba185298b
(desktop-buffer-mode-handlers, desktop-after-read-hook,
Lars Hansen <larsh@soem.dk>
parents:
57038
diff
changeset
|
246 :group 'desktop |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
59487
diff
changeset
|
247 :version "22.1") |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
248 |
78046
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
249 (defcustom desktop-not-loaded-hook nil |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
250 "Normal hook run when the user declines to re-use a desktop file. |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
251 Run in the directory in which the desktop file was found. |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
252 May be used to deal with accidental multiple Emacs jobs." |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
253 :type 'hook |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
254 :group 'desktop |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
255 :options '(desktop-save-mode-off save-buffers-kill-emacs) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
256 :version "22.2") |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
257 |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
258 (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
|
259 "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
|
260 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
|
261 :type 'hook |
58140
b72ba185298b
(desktop-buffer-mode-handlers, desktop-after-read-hook,
Lars Hansen <larsh@soem.dk>
parents:
57038
diff
changeset
|
262 :group 'desktop |
71453
bef13fc7f695
(desktop-full-file-name): New function.
Lars Hansen <larsh@soem.dk>
parents:
70653
diff
changeset
|
263 :options '(list-buffers) |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
59487
diff
changeset
|
264 :version "22.1") |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
265 |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
266 (defcustom desktop-save-hook nil |
52674 | 267 "Normal hook run before the desktop is saved in a desktop file. |
71453
bef13fc7f695
(desktop-full-file-name): New function.
Lars Hansen <larsh@soem.dk>
parents:
70653
diff
changeset
|
268 Run with the desktop buffer current with only the header present. |
bef13fc7f695
(desktop-full-file-name): New function.
Lars Hansen <larsh@soem.dk>
parents:
70653
diff
changeset
|
269 May be used to add to the desktop code or to truncate history lists, |
bef13fc7f695
(desktop-full-file-name): New function.
Lars Hansen <larsh@soem.dk>
parents:
70653
diff
changeset
|
270 for example." |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
271 :type 'hook |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
272 :group 'desktop) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
273 |
57038
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
274 (defcustom desktop-globals-to-save |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
275 '(desktop-missing-file-warning |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
276 tags-file-name |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
277 tags-table-list |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
278 search-ring |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
279 regexp-search-ring |
103723
a18909b5a393
* desktop.el (desktop-globals-to-save): Add file-name-history (Bug#2750).
Chong Yidong <cyd@stupidchicken.com>
parents:
102698
diff
changeset
|
280 register-alist |
a18909b5a393
* desktop.el (desktop-globals-to-save): Add file-name-history (Bug#2750).
Chong Yidong <cyd@stupidchicken.com>
parents:
102698
diff
changeset
|
281 file-name-history) |
52674 | 282 "List of global variables saved by `desktop-save'. |
283 An element may be variable name (a symbol) or a cons cell of the form | |
284 \(VAR . MAX-SIZE), which means to truncate VAR's value to at most | |
285 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
|
286 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
|
287 :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
|
288 :group 'desktop) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
289 |
57038
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
290 (defcustom desktop-globals-to-clear |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
291 '(kill-ring |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
292 kill-ring-yank-pointer |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
293 search-ring |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
294 search-ring-yank-pointer |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
295 regexp-search-ring |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
296 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
|
297 "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
|
298 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
|
299 \(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
|
300 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
|
301 :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
|
302 :group 'desktop |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
59487
diff
changeset
|
303 :version "22.1") |
3404 | 304 |
64893
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
305 (defcustom desktop-clear-preserve-buffers |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
306 '("\\*scratch\\*" "\\*Messages\\*" "\\*server\\*" "\\*tramp/.+\\*") |
100171 | 307 "List of buffers that `desktop-clear' should not delete. |
64893
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
308 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
|
309 these won't be deleted." |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
310 :type '(repeat string) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
311 :group 'desktop) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
312 |
64893
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
313 ;;;###autoload |
57038
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
314 (defcustom desktop-locals-to-save |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
315 '(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
|
316 truncate-lines |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
317 case-fold-search |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
318 case-replace |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
319 fill-column |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
320 overwrite-mode |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
321 change-log-default-name |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
322 line-number-mode |
64893
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
323 column-number-mode |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
324 size-indication-mode |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
325 buffer-file-coding-system |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
326 indent-tabs-mode |
71453
bef13fc7f695
(desktop-full-file-name): New function.
Lars Hansen <larsh@soem.dk>
parents:
70653
diff
changeset
|
327 tab-width |
64893
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
328 indicate-buffer-boundaries |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
329 indicate-empty-lines |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
330 show-trailing-whitespace) |
10595 | 331 "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
|
332 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
|
333 modes are restored automatically; they should not be listed here." |
52674 | 334 :type '(repeat symbol) |
335 :group 'desktop) | |
5465
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
336 |
103958
f261612c30a6
(desktop-buffers-not-to-save): Default value is nil. Accept nil in
Eli Zaretskii <eliz@gnu.org>
parents:
103872
diff
changeset
|
337 (defcustom desktop-buffers-not-to-save nil |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
338 "Regexp identifying buffers that are to be excluded from saving." |
103958
f261612c30a6
(desktop-buffers-not-to-save): Default value is nil. Accept nil in
Eli Zaretskii <eliz@gnu.org>
parents:
103872
diff
changeset
|
339 :type '(choice (const :tag "None" nil) |
f261612c30a6
(desktop-buffers-not-to-save): Default value is nil. Accept nil in
Eli Zaretskii <eliz@gnu.org>
parents:
103872
diff
changeset
|
340 regexp) |
103978
53e741f0367a
(desktop-buffers-not-to-save): Set :version tag.
Glenn Morris <rgm@gnu.org>
parents:
103958
diff
changeset
|
341 :version "23.2" ; set to nil |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
342 :group 'desktop) |
3404 | 343 |
52674 | 344 ;; 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
|
345 (defcustom desktop-files-not-to-save |
103958
f261612c30a6
(desktop-buffers-not-to-save): Default value is nil. Accept nil in
Eli Zaretskii <eliz@gnu.org>
parents:
103872
diff
changeset
|
346 "\\(^/[^/:]*:\\|(ftp)$\\)" |
17411
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17204
diff
changeset
|
347 "Regexp identifying files whose buffers are to be excluded from saving." |
103958
f261612c30a6
(desktop-buffers-not-to-save): Default value is nil. Accept nil in
Eli Zaretskii <eliz@gnu.org>
parents:
103872
diff
changeset
|
348 :type '(choice (const :tag "None" nil) |
f261612c30a6
(desktop-buffers-not-to-save): Default value is nil. Accept nil in
Eli Zaretskii <eliz@gnu.org>
parents:
103872
diff
changeset
|
349 regexp) |
17411
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17204
diff
changeset
|
350 :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
|
351 |
66278
8926d6f2f267
(desktop-buffers-not-to-save): Remove TAGS from the default value.
Juri Linkov <juri@jurta.org>
parents:
66037
diff
changeset
|
352 ;; 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
|
353 (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
|
354 '(tags-table-mode) |
32366
40d8b29df57e
(desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30853
diff
changeset
|
355 "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
|
356 :type '(repeat symbol) |
40d8b29df57e
(desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30853
diff
changeset
|
357 :group 'desktop) |
40d8b29df57e
(desktop-modes-not-to-save): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
30853
diff
changeset
|
358 |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
359 (defcustom desktop-file-name-format 'absolute |
100171 | 360 "Format in which desktop file names should be saved. |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
361 Possible values are: |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
362 absolute -- Absolute file name. |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
363 tilde -- Relative to ~. |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
364 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
|
365 :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
|
366 :group 'desktop |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
59487
diff
changeset
|
367 :version "22.1") |
14755
3d473ed8c718
Global vars mam, fn, bn renamed.
Richard M. Stallman <rms@gnu.org>
parents:
14754
diff
changeset
|
368 |
59412
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
369 (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
|
370 "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
|
371 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
|
372 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
|
373 :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
|
374 :group 'desktop |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
59487
diff
changeset
|
375 :version "22.1") |
59412
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
376 |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
377 (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
|
378 "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
|
379 :type 'boolean |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
380 :group 'desktop |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
59487
diff
changeset
|
381 :version "22.1") |
59412
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
382 |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
383 (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
|
384 "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
|
385 See `desktop-restore-eager'." |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
386 :type 'integer |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
387 :group 'desktop |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
59487
diff
changeset
|
388 :version "22.1") |
59412
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
389 |
55059
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
390 ;;;###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
|
391 (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
|
392 "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
|
393 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
|
394 |
64674
b110ecf69f54
(desktop-save-buffer): Fix typos in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
64566
diff
changeset
|
395 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
|
396 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
|
397 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
|
398 |
52674 | 399 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
|
400 \"(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
|
401 |
64893
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
402 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
|
403 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
|
404 `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
|
405 (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
|
406 (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
|
407 'desktop-save-buffer "22.1") |
55059
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
408 (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
|
409 '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
|
410 |
64893
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
411 ;;;###autoload |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
412 (defvar desktop-buffer-mode-handlers |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
413 nil |
55059
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
414 "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
|
415 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
|
416 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
|
417 |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
418 (MAJOR-MODE . RESTORE-BUFFER-FUNCTION). |
55059
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
419 |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
420 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
|
421 handler `desktop-restore-file-buffer'. |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
422 |
55413
f30ad6214291
(desktop-buffer-mode-handlers): Fix docstring.
Lars Hansen <larsh@soem.dk>
parents:
55179
diff
changeset
|
423 Handlers are called with argument list |
55059
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
424 |
55418
b92f1b7ca228
(desktop-buffer-mode-handlers): Fix docstring.
Lars Hansen <larsh@soem.dk>
parents:
55413
diff
changeset
|
425 (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
|
426 |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
427 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
|
428 |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
429 desktop-file-version |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
430 desktop-buffer-major-mode |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
431 desktop-buffer-minor-modes |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
432 desktop-buffer-point |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
433 desktop-buffer-mark |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
434 desktop-buffer-read-only |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
435 desktop-buffer-locals |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
436 |
55059
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
437 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
|
438 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
|
439 |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
440 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
|
441 code like |
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 (defun foo-restore-desktop-buffer |
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 (add-to-list 'desktop-buffer-mode-handlers |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
446 '(foo-mode . foo-restore-desktop-buffer)) |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
447 |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
448 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
|
449 |
64963
527df96e5eda
Put autoload cookie at risky-local-variable declarations.
Andreas Schwab <schwab@suse.de>
parents:
64893
diff
changeset
|
450 ;;;###autoload |
55059
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
451 (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
|
452 (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
|
453 '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
|
454 |
28719
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
455 (defcustom desktop-minor-mode-table |
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
456 '((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
|
457 (vc-mode nil) |
85771
a7aa5ee6bc3a
Revert bad erc-track change; ignore erc-track-minor-mode properly in desktop
Michael Olson <mwolson@gnu.org>
parents:
85697
diff
changeset
|
458 (vc-dired-mode nil) |
94425
780f88412851
(desktop-minor-mode-table): Add `savehist-mode'.
Juanma Barranquero <lekktu@gmail.com>
parents:
94026
diff
changeset
|
459 (erc-track-minor-mode nil) |
780f88412851
(desktop-minor-mode-table): Add `savehist-mode'.
Juanma Barranquero <lekktu@gmail.com>
parents:
94026
diff
changeset
|
460 (savehist-mode nil)) |
28719
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
461 "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
|
462 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
|
463 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
|
464 mode is active. RESTORE-FUNCTION is the function to activate the minor mode. |
77991
a5fe5ff427e0
(desktop-minor-mode-table): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
77115
diff
changeset
|
465 RESTORE-FUNCTION nil means don't try to restore the minor mode. |
28719
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
466 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
|
467 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
|
468 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
|
469 :type 'sexp |
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
470 :group 'desktop) |
f56c181fb849
(desktop-save): Save list of minor modes.
Gerd Moellmann <gerd@gnu.org>
parents:
27577
diff
changeset
|
471 |
64893
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
472 ;;;###autoload |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
473 (defvar desktop-minor-mode-handlers |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
474 nil |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
475 "Alist of functions to restore non-standard minor modes. |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
476 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
|
477 List elements must have the form |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
478 |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
479 (MINOR-MODE . RESTORE-FUNCTION). |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
480 |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
481 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
|
482 function. |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
483 |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
484 Handlers are called with argument list |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
485 |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
486 (DESKTOP-BUFFER-LOCALS) |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
487 |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
488 Furthermore, they may use the following variables: |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
489 |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
490 desktop-file-version |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
491 desktop-buffer-file-name |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
492 desktop-buffer-name |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
493 desktop-buffer-major-mode |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
494 desktop-buffer-minor-modes |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
495 desktop-buffer-point |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
496 desktop-buffer-mark |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
497 desktop-buffer-read-only |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
498 desktop-buffer-misc |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
499 |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
500 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
|
501 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
|
502 created and set. |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
503 |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
504 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
|
505 code like |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
506 |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
507 (defun foo-desktop-restore |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
508 ... |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
509 (add-to-list 'desktop-minor-mode-handlers |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
510 '(foo-mode . foo-desktop-restore)) |
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 Furthermore the minor mode function must be autoloaded. |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
513 |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
514 See also `desktop-minor-mode-table'.") |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
515 |
64963
527df96e5eda
Put autoload cookie at risky-local-variable declarations.
Andreas Schwab <schwab@suse.de>
parents:
64893
diff
changeset
|
516 ;;;###autoload |
64893
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
517 (put 'desktop-minor-mode-handlers 'risky-local-variable t) |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
518 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
519 ;; ---------------------------------------------------------------------------- |
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
520 (defvar desktop-dirname nil |
52674 | 521 "The directory in which the desktop file should be saved.") |
3404 | 522 |
71453
bef13fc7f695
(desktop-full-file-name): New function.
Lars Hansen <larsh@soem.dk>
parents:
70653
diff
changeset
|
523 (defun desktop-full-file-name (&optional dirname) |
bef13fc7f695
(desktop-full-file-name): New function.
Lars Hansen <larsh@soem.dk>
parents:
70653
diff
changeset
|
524 "Return the full name of the desktop file in DIRNAME. |
bef13fc7f695
(desktop-full-file-name): New function.
Lars Hansen <larsh@soem.dk>
parents:
70653
diff
changeset
|
525 DIRNAME omitted or nil means use `desktop-dirname'." |
bef13fc7f695
(desktop-full-file-name): New function.
Lars Hansen <larsh@soem.dk>
parents:
70653
diff
changeset
|
526 (expand-file-name desktop-base-file-name (or dirname desktop-dirname))) |
bef13fc7f695
(desktop-full-file-name): New function.
Lars Hansen <larsh@soem.dk>
parents:
70653
diff
changeset
|
527 |
78046
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
528 (defun desktop-full-lock-name (&optional dirname) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
529 "Return the full name of the desktop lock file in DIRNAME. |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
530 DIRNAME omitted or nil means use `desktop-dirname'." |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
531 (expand-file-name desktop-base-lock-name (or dirname desktop-dirname))) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
532 |
3404 | 533 (defconst desktop-header |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
534 ";; -------------------------------------------------------------------------- |
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
535 ;; Desktop File for Emacs |
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
536 ;; -------------------------------------------------------------------------- |
3404 | 537 " "*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
|
538 |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
539 (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
|
540 "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
|
541 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
542 ;; ---------------------------------------------------------------------------- |
78046
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
543 ;; Desktop file conflict detection |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
544 (defvar desktop-file-modtime nil |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
545 "When the desktop file was last modified to the knowledge of this Emacs. |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
546 Used to detect desktop file conflicts.") |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
547 |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
548 (defun desktop-owner (&optional dirname) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
549 "Return the PID of the Emacs process that owns the desktop file in DIRNAME. |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
550 Return nil if no desktop file found or no Emacs process is using it. |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
551 DIRNAME omitted or nil means use `desktop-dirname'." |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
552 (let (owner) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
553 (and (file-exists-p (desktop-full-lock-name dirname)) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
554 (condition-case nil |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
555 (with-temp-buffer |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
556 (insert-file-contents-literally (desktop-full-lock-name dirname)) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
557 (goto-char (point-min)) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
558 (setq owner (read (current-buffer))) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
559 (integerp owner)) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
560 (error nil)) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
561 owner))) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
562 |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
563 (defun desktop-claim-lock (&optional dirname) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
564 "Record this Emacs process as the owner of the desktop file in DIRNAME. |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
565 DIRNAME omitted or nil means use `desktop-dirname'." |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
566 (write-region (number-to-string (emacs-pid)) nil |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
567 (desktop-full-lock-name dirname))) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
568 |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
569 (defun desktop-release-lock (&optional dirname) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
570 "Remove the lock file for the desktop in DIRNAME. |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
571 DIRNAME omitted or nil means use `desktop-dirname'." |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
572 (let ((file (desktop-full-lock-name dirname))) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
573 (when (file-exists-p file) (delete-file file)))) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
574 |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
575 ;; ---------------------------------------------------------------------------- |
54206
ecf0e7a0567a
(desktop-file-version, desktop-after-read-hook): Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
52996
diff
changeset
|
576 (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
|
577 "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
|
578 (let ((here (nthcdr (1- n) list))) |
78046
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
579 (when (consp here) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
580 (setcdr here nil)))) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
581 |
5465
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
582 ;; ---------------------------------------------------------------------------- |
71453
bef13fc7f695
(desktop-full-file-name): New function.
Lars Hansen <larsh@soem.dk>
parents:
70653
diff
changeset
|
583 ;;;###autoload |
18581
45f27efe77c7
(desktop-clear-preserve-buffers): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18527
diff
changeset
|
584 (defun desktop-clear () |
45f27efe77c7
(desktop-clear-preserve-buffers): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18527
diff
changeset
|
585 "Empty the Desktop. |
64893
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
586 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
|
587 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
|
588 Furthermore, it clears the variables listed in `desktop-globals-to-clear'." |
3404 | 589 (interactive) |
59412
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
590 (desktop-lazy-abort) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
591 (dolist (var desktop-globals-to-clear) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
592 (if (symbolp var) |
78046
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
593 (eval `(setq-default ,var nil)) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
594 (eval `(setq-default ,(car var) ,(cdr var))))) |
64893
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
595 (let ((buffers (buffer-list)) |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
596 (preserve-regexp (concat "^\\(" |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
597 (mapconcat (lambda (regexp) |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
598 (concat "\\(" regexp "\\)")) |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
599 desktop-clear-preserve-buffers |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
600 "\\|") |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
601 "\\)$"))) |
18581
45f27efe77c7
(desktop-clear-preserve-buffers): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18527
diff
changeset
|
602 (while buffers |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
603 (let ((bufname (buffer-name (car buffers)))) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
604 (or |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
605 (null bufname) |
64893
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
606 (string-match preserve-regexp bufname) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
607 ;; 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
|
608 (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
|
609 (kill-buffer (car buffers)))) |
18581
45f27efe77c7
(desktop-clear-preserve-buffers): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18527
diff
changeset
|
610 (setq buffers (cdr buffers)))) |
5314 | 611 (delete-other-windows)) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
612 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
613 ;; ---------------------------------------------------------------------------- |
5788
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
614 (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
|
615 |
3404 | 616 (defun desktop-kill () |
52674 | 617 "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
|
618 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
|
619 is nil, ask the user where to save the desktop." |
71453
bef13fc7f695
(desktop-full-file-name): New function.
Lars Hansen <larsh@soem.dk>
parents:
70653
diff
changeset
|
620 (when (and desktop-save-mode |
bef13fc7f695
(desktop-full-file-name): New function.
Lars Hansen <larsh@soem.dk>
parents:
70653
diff
changeset
|
621 (let ((exists (file-exists-p (desktop-full-file-name)))) |
bef13fc7f695
(desktop-full-file-name): New function.
Lars Hansen <larsh@soem.dk>
parents:
70653
diff
changeset
|
622 (or (eq desktop-save t) |
bef13fc7f695
(desktop-full-file-name): New function.
Lars Hansen <larsh@soem.dk>
parents:
70653
diff
changeset
|
623 (and exists (memq desktop-save '(ask-if-new if-exists))) |
bef13fc7f695
(desktop-full-file-name): New function.
Lars Hansen <larsh@soem.dk>
parents:
70653
diff
changeset
|
624 (and |
bef13fc7f695
(desktop-full-file-name): New function.
Lars Hansen <larsh@soem.dk>
parents:
70653
diff
changeset
|
625 (or (memq desktop-save '(ask ask-if-new)) |
bef13fc7f695
(desktop-full-file-name): New function.
Lars Hansen <larsh@soem.dk>
parents:
70653
diff
changeset
|
626 (and exists (eq desktop-save 'ask-if-exists))) |
bef13fc7f695
(desktop-full-file-name): New function.
Lars Hansen <larsh@soem.dk>
parents:
70653
diff
changeset
|
627 (y-or-n-p "Save desktop? "))))) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
628 (unless desktop-dirname |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
629 (setq desktop-dirname |
71453
bef13fc7f695
(desktop-full-file-name): New function.
Lars Hansen <larsh@soem.dk>
parents:
70653
diff
changeset
|
630 (file-name-as-directory |
bef13fc7f695
(desktop-full-file-name): New function.
Lars Hansen <larsh@soem.dk>
parents:
70653
diff
changeset
|
631 (expand-file-name |
78046
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
632 (read-directory-name "Directory for desktop file: " nil nil t))))) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
633 (condition-case err |
78046
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
634 (desktop-save desktop-dirname t) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
635 (file-error |
71453
bef13fc7f695
(desktop-full-file-name): New function.
Lars Hansen <larsh@soem.dk>
parents:
70653
diff
changeset
|
636 (unless (yes-or-no-p "Error while saving the desktop. Ignore? ") |
78046
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
637 (signal (car err) (cdr err)))))) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
638 ;; If we own it, we don't anymore. |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
639 (when (eq (emacs-pid) (desktop-owner)) (desktop-release-lock))) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
640 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
641 ;; ---------------------------------------------------------------------------- |
14754
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
642 (defun desktop-list* (&rest args) |
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
643 (if (null (cdr args)) |
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
644 (car args) |
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
645 (setq args (nreverse args)) |
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
646 (let ((value (cons (nth 1 args) (car args)))) |
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
647 (setq args (cdr (cdr args))) |
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
648 (while args |
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
649 (setq value (cons (car args) value)) |
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
650 (setq args (cdr args))) |
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
651 value))) |
9955249f9b0f
(desktop-list*): New function.
Richard M. Stallman <rms@gnu.org>
parents:
14172
diff
changeset
|
652 |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
653 ;; ---------------------------------------------------------------------------- |
78046
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
654 (defun desktop-buffer-info (buffer) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
655 (set-buffer buffer) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
656 (list |
91841
93224b3daf2a
(uniquify-managed): Don't defvar.
Juanma Barranquero <lekktu@gmail.com>
parents:
91810
diff
changeset
|
657 ;; base name of the buffer; replaces the buffer name if managed by uniquify |
93224b3daf2a
(uniquify-managed): Don't defvar.
Juanma Barranquero <lekktu@gmail.com>
parents:
91810
diff
changeset
|
658 (and (fboundp 'uniquify-buffer-base-name) (uniquify-buffer-base-name)) |
78046
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
659 ;; basic information |
78110
33c9a00ace1e
(desktop-buffer-info, desktop-save): Use `desktop-dirname' instead of `dirname'.
Juanma Barranquero <lekktu@gmail.com>
parents:
78046
diff
changeset
|
660 (desktop-file-name (buffer-file-name) desktop-dirname) |
91841
93224b3daf2a
(uniquify-managed): Don't defvar.
Juanma Barranquero <lekktu@gmail.com>
parents:
91810
diff
changeset
|
661 (buffer-name) |
78046
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
662 major-mode |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
663 ;; minor modes |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
664 (let (ret) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
665 (mapc |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
666 #'(lambda (minor-mode) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
667 (and (boundp minor-mode) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
668 (symbol-value minor-mode) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
669 (let* ((special (assq minor-mode desktop-minor-mode-table)) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
670 (value (cond (special (cadr special)) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
671 ((functionp minor-mode) minor-mode)))) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
672 (when value (add-to-list 'ret value))))) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
673 (mapcar #'car minor-mode-alist)) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
674 ret) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
675 ;; point and mark, and read-only status |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
676 (point) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
677 (list (mark t) mark-active) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
678 buffer-read-only |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
679 ;; auxiliary information |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
680 (when (functionp desktop-save-buffer) |
78110
33c9a00ace1e
(desktop-buffer-info, desktop-save): Use `desktop-dirname' instead of `dirname'.
Juanma Barranquero <lekktu@gmail.com>
parents:
78046
diff
changeset
|
681 (funcall desktop-save-buffer desktop-dirname)) |
78046
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
682 ;; local variables |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
683 (let ((locals desktop-locals-to-save) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
684 (loclist (buffer-local-variables)) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
685 (ll)) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
686 (while locals |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
687 (let ((here (assq (car locals) loclist))) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
688 (if here |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
689 (setq ll (cons here ll)) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
690 (when (member (car locals) loclist) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
691 (setq ll (cons (car locals) ll))))) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
692 (setq locals (cdr locals))) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
693 ll))) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
694 |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
695 ;; ---------------------------------------------------------------------------- |
54206
ecf0e7a0567a
(desktop-file-version, desktop-after-read-hook): Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
52996
diff
changeset
|
696 (defun desktop-internal-v2s (value) |
10595 | 697 "Convert VALUE to a pair (QUOTE . TXT); (eval (read TXT)) gives VALUE. |
698 TXT is a string that when read and evaluated yields value. | |
699 QUOTE may be `may' (value may be quoted), | |
700 `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
|
701 (cond |
78046
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
702 ((or (numberp value) (null value) (eq t value) (keywordp value)) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
703 (cons 'may (prin1-to-string value))) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
704 ((stringp value) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
705 (let ((copy (copy-sequence value))) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
706 (set-text-properties 0 (length copy) nil copy) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
707 ;; Get rid of text properties because we cannot read them |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
708 (cons 'may (prin1-to-string copy)))) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
709 ((symbolp value) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
710 (cons 'must (prin1-to-string value))) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
711 ((vectorp value) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
712 (let* ((special nil) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
713 (pass1 (mapcar |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
714 (lambda (el) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
715 (let ((res (desktop-internal-v2s el))) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
716 (if (null (car res)) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
717 (setq special t)) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
718 res)) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
719 value))) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
720 (if special |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
721 (cons nil (concat "(vector " |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
722 (mapconcat (lambda (el) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
723 (if (eq (car el) 'must) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
724 (concat "'" (cdr el)) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
725 (cdr el))) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
726 pass1 |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
727 " ") |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
728 ")")) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
729 (cons 'may (concat "[" (mapconcat 'cdr pass1 " ") "]"))))) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
730 ((consp value) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
731 (let ((p value) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
732 newlist |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
733 use-list* |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
734 anynil) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
735 (while (consp p) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
736 (let ((q.txt (desktop-internal-v2s (car p)))) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
737 (or anynil (setq anynil (null (car q.txt)))) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
738 (setq newlist (cons q.txt newlist))) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
739 (setq p (cdr p))) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
740 (if p |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
741 (let ((last (desktop-internal-v2s p))) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
742 (or anynil (setq anynil (null (car last)))) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
743 (or anynil |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
744 (setq newlist (cons '(must . ".") newlist))) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
745 (setq use-list* t) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
746 (setq newlist (cons last newlist)))) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
747 (setq newlist (nreverse newlist)) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
748 (if anynil |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
749 (cons nil |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
750 (concat (if use-list* "(desktop-list* " "(list ") |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
751 (mapconcat (lambda (el) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
752 (if (eq (car el) 'must) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
753 (concat "'" (cdr el)) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
754 (cdr el))) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
755 newlist |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
756 " ") |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
757 ")")) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
758 (cons 'must |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
759 (concat "(" (mapconcat 'cdr newlist " ") ")"))))) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
760 ((subrp value) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
761 (cons nil (concat "(symbol-function '" |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
762 (substring (prin1-to-string value) 7 -1) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
763 ")"))) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
764 ((markerp value) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
765 (let ((pos (prin1-to-string (marker-position value))) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
766 (buf (prin1-to-string (buffer-name (marker-buffer value))))) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
767 (cons nil (concat "(let ((mk (make-marker)))" |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
768 " (add-hook 'desktop-delay-hook" |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
769 " (list 'lambda '() (list 'set-marker mk " |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
770 pos " (get-buffer " buf ")))) mk)")))) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
771 (t ; save as text |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
772 (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
|
773 |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
774 ;; ---------------------------------------------------------------------------- |
54206
ecf0e7a0567a
(desktop-file-version, desktop-after-read-hook): Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
52996
diff
changeset
|
775 (defun desktop-value-to-string (value) |
10595 | 776 "Convert VALUE to a string that when read evaluates to the same value. |
777 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
|
778 (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
|
779 (float-output-format nil) |
54206
ecf0e7a0567a
(desktop-file-version, desktop-after-read-hook): Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
52996
diff
changeset
|
780 (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
|
781 (quote (car quote.txt)) |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
782 (txt (cdr quote.txt))) |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
783 (if (eq quote 'must) |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
784 (concat "'" txt) |
913f27480fad
(desktop-internal-v2s): Allow saving of markers and subrs.
Richard M. Stallman <rms@gnu.org>
parents:
5465
diff
changeset
|
785 txt))) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
786 |
5465
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
787 ;; ---------------------------------------------------------------------------- |
13154
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
788 (defun desktop-outvar (varspec) |
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
789 "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
|
790 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
|
791 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
|
792 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
|
793 \(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
|
794 (let (var size) |
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
795 (if (consp varspec) |
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
796 (setq var (car varspec) size (cdr varspec)) |
f86e18ff3736
(desktop-outvar): Support truncation.
Richard M. Stallman <rms@gnu.org>
parents:
11224
diff
changeset
|
797 (setq var varspec)) |
78046
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
798 (when (boundp var) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
799 (when (and (integerp size) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
800 (> size 0) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
801 (listp (eval var))) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
802 (desktop-truncate (eval var) size)) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
803 (insert "(setq " |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
804 (symbol-name var) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
805 " " |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
806 (desktop-value-to-string (symbol-value var)) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
807 ")\n")))) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
808 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
809 ;; ---------------------------------------------------------------------------- |
5465
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
810 (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
|
811 "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
|
812 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
|
813 MODE is the major mode. |
01a75c5115e7
(desktop-outvar): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
68651
diff
changeset
|
814 \n\(fn FILENAME BUFNAME MODE)" |
107543 | 815 (let ((case-fold-search nil) |
816 dired-skip) | |
103958
f261612c30a6
(desktop-buffers-not-to-save): Default value is nil. Accept nil in
Eli Zaretskii <eliz@gnu.org>
parents:
103872
diff
changeset
|
817 (and (not (and (stringp desktop-buffers-not-to-save) |
f261612c30a6
(desktop-buffers-not-to-save): Default value is nil. Accept nil in
Eli Zaretskii <eliz@gnu.org>
parents:
103872
diff
changeset
|
818 (not filename) |
f261612c30a6
(desktop-buffers-not-to-save): Default value is nil. Accept nil in
Eli Zaretskii <eliz@gnu.org>
parents:
103872
diff
changeset
|
819 (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
|
820 (not (memq mode desktop-modes-not-to-save)) |
107543 | 821 ;; FIXME this is broken if desktop-files-not-to-save is 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
|
822 (or (and filename |
103958
f261612c30a6
(desktop-buffers-not-to-save): Default value is nil. Accept nil in
Eli Zaretskii <eliz@gnu.org>
parents:
103872
diff
changeset
|
823 (stringp desktop-files-not-to-save) |
55155
519f44af960a
(desktop-buffer-misc-data-function): Rename to desktop-save-buffer and change docstring.
Lars Hansen <larsh@soem.dk>
parents:
55059
diff
changeset
|
824 (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
|
825 (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
|
826 (with-current-buffer bufname |
107543 | 827 (not (setq dired-skip |
828 (string-match desktop-files-not-to-save | |
829 default-directory))))) | |
55155
519f44af960a
(desktop-buffer-misc-data-function): Rename to desktop-save-buffer and change docstring.
Lars Hansen <larsh@soem.dk>
parents:
55059
diff
changeset
|
830 (and (null filename) |
107543 | 831 (null dired-skip) ; bug#5755 |
55155
519f44af960a
(desktop-buffer-misc-data-function): Rename to desktop-save-buffer and change docstring.
Lars Hansen <larsh@soem.dk>
parents:
55059
diff
changeset
|
832 (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
|
833 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
834 ;; ---------------------------------------------------------------------------- |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
835 (defun desktop-file-name (filename dirname) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
836 "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
|
837 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
|
838 (cond |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
839 ((not filename) nil) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
840 ((eq desktop-file-name-format 'tilde) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
841 (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
|
842 (cond |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
843 ((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
|
844 ((string= "./" relative-name) "~/") |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
845 ((string= "." relative-name) "~") |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
846 (t (concat "~/" relative-name))))) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
847 ((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
|
848 (t (expand-file-name filename)))) |
48143
8c7919f99581
(desktop-relative-file-names): New variable.
Juanma Barranquero <lekktu@gmail.com>
parents:
43831
diff
changeset
|
849 |
90951 | 850 |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
851 ;; ---------------------------------------------------------------------------- |
71453
bef13fc7f695
(desktop-full-file-name): New function.
Lars Hansen <larsh@soem.dk>
parents:
70653
diff
changeset
|
852 ;;;###autoload |
78046
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
853 (defun desktop-save (dirname &optional release) |
52674 | 854 "Save the desktop in a desktop file. |
855 Parameter DIRNAME specifies where to save the desktop file. | |
78046
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
856 Optional parameter RELEASE says whether we're done with this desktop. |
52674 | 857 See also `desktop-base-file-name'." |
3404 | 858 (interactive "DDirectory to save desktop file in: ") |
78046
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
859 (setq desktop-dirname (file-name-as-directory (expand-file-name dirname))) |
3404 | 860 (save-excursion |
78046
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
861 (let ((eager desktop-restore-eager) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
862 (new-modtime (nth 5 (file-attributes (desktop-full-file-name))))) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
863 (when |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
864 (or (not new-modtime) ; nothing to overwrite |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
865 (equal desktop-file-modtime new-modtime) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
866 (yes-or-no-p (if desktop-file-modtime |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
867 (if (> (float-time new-modtime) (float-time desktop-file-modtime)) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
868 "Desktop file is more recent than the one loaded. Save anyway? " |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
869 "Desktop file isn't the one loaded. Overwrite it? ") |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
870 "Current desktop was not loaded from a file. Overwrite this desktop file? ")) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
871 (unless release (error "Desktop file conflict"))) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
872 |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
873 ;; If we're done with it, release the lock. |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
874 ;; Otherwise, claim it if it's unclaimed or if we created it. |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
875 (if release |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
876 (desktop-release-lock) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
877 (unless (and new-modtime (desktop-owner)) (desktop-claim-lock))) |
3404 | 878 |
78046
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
879 (with-temp-buffer |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
880 (insert |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
881 ";; -*- mode: emacs-lisp; coding: emacs-mule; -*-\n" |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
882 desktop-header |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
883 ";; Created " (current-time-string) "\n" |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
884 ";; Desktop file format version " desktop-file-version "\n" |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
885 ";; Emacs version " emacs-version "\n") |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
886 (save-excursion (run-hooks 'desktop-save-hook)) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
887 (goto-char (point-max)) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
888 (insert "\n;; Global section:\n") |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
889 (mapc (function desktop-outvar) desktop-globals-to-save) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
890 (when (memq 'kill-ring desktop-globals-to-save) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
891 (insert |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
892 "(setq kill-ring-yank-pointer (nthcdr " |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
893 (int-to-string (- (length kill-ring) (length kill-ring-yank-pointer))) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
894 " kill-ring))\n")) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
895 |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
896 (insert "\n;; Buffer section -- buffers listed in same order as in buffer list:\n") |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
897 (dolist (l (mapcar 'desktop-buffer-info (buffer-list))) |
91841
93224b3daf2a
(uniquify-managed): Don't defvar.
Juanma Barranquero <lekktu@gmail.com>
parents:
91810
diff
changeset
|
898 (let ((base (pop l))) |
93224b3daf2a
(uniquify-managed): Don't defvar.
Juanma Barranquero <lekktu@gmail.com>
parents:
91810
diff
changeset
|
899 (when (apply 'desktop-save-buffer-p l) |
93224b3daf2a
(uniquify-managed): Don't defvar.
Juanma Barranquero <lekktu@gmail.com>
parents:
91810
diff
changeset
|
900 (insert "(" |
93224b3daf2a
(uniquify-managed): Don't defvar.
Juanma Barranquero <lekktu@gmail.com>
parents:
91810
diff
changeset
|
901 (if (or (not (integerp eager)) |
93224b3daf2a
(uniquify-managed): Don't defvar.
Juanma Barranquero <lekktu@gmail.com>
parents:
91810
diff
changeset
|
902 (if (zerop eager) |
93224b3daf2a
(uniquify-managed): Don't defvar.
Juanma Barranquero <lekktu@gmail.com>
parents:
91810
diff
changeset
|
903 nil |
93224b3daf2a
(uniquify-managed): Don't defvar.
Juanma Barranquero <lekktu@gmail.com>
parents:
91810
diff
changeset
|
904 (setq eager (1- eager)))) |
93224b3daf2a
(uniquify-managed): Don't defvar.
Juanma Barranquero <lekktu@gmail.com>
parents:
91810
diff
changeset
|
905 "desktop-create-buffer" |
93224b3daf2a
(uniquify-managed): Don't defvar.
Juanma Barranquero <lekktu@gmail.com>
parents:
91810
diff
changeset
|
906 "desktop-append-buffer-args") |
93224b3daf2a
(uniquify-managed): Don't defvar.
Juanma Barranquero <lekktu@gmail.com>
parents:
91810
diff
changeset
|
907 " " |
93224b3daf2a
(uniquify-managed): Don't defvar.
Juanma Barranquero <lekktu@gmail.com>
parents:
91810
diff
changeset
|
908 desktop-file-version) |
92328
04dddf68dfc0
(desktop-save): Save the buffer name if the uniquified base name is empty.
Juanma Barranquero <lekktu@gmail.com>
parents:
91841
diff
changeset
|
909 ;; If there's a non-empty base name, we save it instead of the buffer name |
04dddf68dfc0
(desktop-save): Save the buffer name if the uniquified base name is empty.
Juanma Barranquero <lekktu@gmail.com>
parents:
91841
diff
changeset
|
910 (when (and base (not (string= base ""))) |
04dddf68dfc0
(desktop-save): Save the buffer name if the uniquified base name is empty.
Juanma Barranquero <lekktu@gmail.com>
parents:
91841
diff
changeset
|
911 (setcar (nthcdr 1 l) base)) |
91841
93224b3daf2a
(uniquify-managed): Don't defvar.
Juanma Barranquero <lekktu@gmail.com>
parents:
91810
diff
changeset
|
912 (dolist (e l) |
93224b3daf2a
(uniquify-managed): Don't defvar.
Juanma Barranquero <lekktu@gmail.com>
parents:
91810
diff
changeset
|
913 (insert "\n " (desktop-value-to-string e))) |
93224b3daf2a
(uniquify-managed): Don't defvar.
Juanma Barranquero <lekktu@gmail.com>
parents:
91810
diff
changeset
|
914 (insert ")\n\n")))) |
78046
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
915 |
78110
33c9a00ace1e
(desktop-buffer-info, desktop-save): Use `desktop-dirname' instead of `dirname'.
Juanma Barranquero <lekktu@gmail.com>
parents:
78046
diff
changeset
|
916 (setq default-directory desktop-dirname) |
78046
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
917 (let ((coding-system-for-write 'emacs-mule)) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
918 (write-region (point-min) (point-max) (desktop-full-file-name) nil 'nomessage)) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
919 ;; We remember when it was modified (which is presumably just now). |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
920 (setq desktop-file-modtime (nth 5 (file-attributes (desktop-full-file-name))))))))) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
921 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
922 ;; ---------------------------------------------------------------------------- |
71453
bef13fc7f695
(desktop-full-file-name): New function.
Lars Hansen <larsh@soem.dk>
parents:
70653
diff
changeset
|
923 ;;;###autoload |
3404 | 924 (defun desktop-remove () |
52674 | 925 "Delete desktop file in `desktop-dirname'. |
926 This function also sets `desktop-dirname' to nil." | |
3404 | 927 (interactive) |
52674 | 928 (when desktop-dirname |
71453
bef13fc7f695
(desktop-full-file-name): New function.
Lars Hansen <larsh@soem.dk>
parents:
70653
diff
changeset
|
929 (let ((filename (desktop-full-file-name))) |
52674 | 930 (setq desktop-dirname nil) |
931 (when (file-exists-p filename) | |
932 (delete-file filename))))) | |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
933 |
59412
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
934 (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
|
935 "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
|
936 |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
937 (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
|
938 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
939 ;; ---------------------------------------------------------------------------- |
21303
346595905ae4
(desktop-load-default): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents:
20772
diff
changeset
|
940 ;;;###autoload |
52674 | 941 (defun desktop-read (&optional dirname) |
942 "Read and process the desktop file in directory DIRNAME. | |
943 Look for a desktop file in DIRNAME, or if DIRNAME is omitted, look in | |
944 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
|
945 is processed and `desktop-after-read-hook' is run. If no desktop file |
52674 | 946 is found, clear the desktop and run `desktop-no-desktop-file-hook'. |
947 This function is a no-op when Emacs is running in batch mode. | |
948 It returns t if a desktop file was loaded, nil otherwise." | |
949 (interactive) | |
950 (unless noninteractive | |
951 (setq desktop-dirname | |
71453
bef13fc7f695
(desktop-full-file-name): New function.
Lars Hansen <larsh@soem.dk>
parents:
70653
diff
changeset
|
952 (file-name-as-directory |
bef13fc7f695
(desktop-full-file-name): New function.
Lars Hansen <larsh@soem.dk>
parents:
70653
diff
changeset
|
953 (expand-file-name |
bef13fc7f695
(desktop-full-file-name): New function.
Lars Hansen <larsh@soem.dk>
parents:
70653
diff
changeset
|
954 (or |
bef13fc7f695
(desktop-full-file-name): New function.
Lars Hansen <larsh@soem.dk>
parents:
70653
diff
changeset
|
955 ;; If DIRNAME is specified, use it. |
bef13fc7f695
(desktop-full-file-name): New function.
Lars Hansen <larsh@soem.dk>
parents:
70653
diff
changeset
|
956 (and (< 0 (length dirname)) dirname) |
bef13fc7f695
(desktop-full-file-name): New function.
Lars Hansen <larsh@soem.dk>
parents:
70653
diff
changeset
|
957 ;; Otherwise search desktop file in desktop-path. |
bef13fc7f695
(desktop-full-file-name): New function.
Lars Hansen <larsh@soem.dk>
parents:
70653
diff
changeset
|
958 (let ((dirs desktop-path)) |
bef13fc7f695
(desktop-full-file-name): New function.
Lars Hansen <larsh@soem.dk>
parents:
70653
diff
changeset
|
959 (while (and dirs |
bef13fc7f695
(desktop-full-file-name): New function.
Lars Hansen <larsh@soem.dk>
parents:
70653
diff
changeset
|
960 (not (file-exists-p |
bef13fc7f695
(desktop-full-file-name): New function.
Lars Hansen <larsh@soem.dk>
parents:
70653
diff
changeset
|
961 (desktop-full-file-name (car dirs))))) |
bef13fc7f695
(desktop-full-file-name): New function.
Lars Hansen <larsh@soem.dk>
parents:
70653
diff
changeset
|
962 (setq dirs (cdr dirs))) |
bef13fc7f695
(desktop-full-file-name): New function.
Lars Hansen <larsh@soem.dk>
parents:
70653
diff
changeset
|
963 (and dirs (car dirs))) |
bef13fc7f695
(desktop-full-file-name): New function.
Lars Hansen <larsh@soem.dk>
parents:
70653
diff
changeset
|
964 ;; If not found and `desktop-path' is non-nil, use its first element. |
bef13fc7f695
(desktop-full-file-name): New function.
Lars Hansen <larsh@soem.dk>
parents:
70653
diff
changeset
|
965 (and desktop-path (car desktop-path)) |
bef13fc7f695
(desktop-full-file-name): New function.
Lars Hansen <larsh@soem.dk>
parents:
70653
diff
changeset
|
966 ;; Default: Home directory. |
bef13fc7f695
(desktop-full-file-name): New function.
Lars Hansen <larsh@soem.dk>
parents:
70653
diff
changeset
|
967 "~")))) |
bef13fc7f695
(desktop-full-file-name): New function.
Lars Hansen <larsh@soem.dk>
parents:
70653
diff
changeset
|
968 (if (file-exists-p (desktop-full-file-name)) |
78046
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
969 ;; Desktop file found, but is it already in use? |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
970 (let ((desktop-first-buffer nil) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
971 (desktop-buffer-ok-count 0) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
972 (desktop-buffer-fail-count 0) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
973 (owner (desktop-owner)) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
974 ;; Avoid desktop saving during evaluation of desktop buffer. |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
975 (desktop-save nil)) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
976 (if (and owner |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
977 (memq desktop-load-locked-desktop '(nil ask)) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
978 (or (null desktop-load-locked-desktop) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
979 (not (y-or-n-p (format "Warning: desktop file appears to be in use by PID %s.\n\ |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
980 Using it may cause conflicts. Use it anyway? " owner))))) |
92364
4cf1d5a7cc52
(desktop-read): Set `desktop-dirname' to nil before running
Juanma Barranquero <lekktu@gmail.com>
parents:
92328
diff
changeset
|
981 (let ((default-directory desktop-dirname)) |
78046
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
982 (setq desktop-dirname nil) |
92364
4cf1d5a7cc52
(desktop-read): Set `desktop-dirname' to nil before running
Juanma Barranquero <lekktu@gmail.com>
parents:
92328
diff
changeset
|
983 (run-hooks 'desktop-not-loaded-hook) |
4cf1d5a7cc52
(desktop-read): Set `desktop-dirname' to nil before running
Juanma Barranquero <lekktu@gmail.com>
parents:
92328
diff
changeset
|
984 (unless desktop-dirname |
4cf1d5a7cc52
(desktop-read): Set `desktop-dirname' to nil before running
Juanma Barranquero <lekktu@gmail.com>
parents:
92328
diff
changeset
|
985 (message "Desktop file in use; not loaded."))) |
78046
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
986 (desktop-lazy-abort) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
987 ;; Evaluate desktop buffer and remember when it was modified. |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
988 (load (desktop-full-file-name) t t t) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
989 (setq desktop-file-modtime (nth 5 (file-attributes (desktop-full-file-name)))) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
990 ;; If it wasn't already, mark it as in-use, to bother other |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
991 ;; desktop instances. |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
992 (unless owner |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
993 (condition-case nil |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
994 (desktop-claim-lock) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
995 (file-error (message "Couldn't record use of desktop file") |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
996 (sit-for 1)))) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
997 |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
998 ;; `desktop-create-buffer' puts buffers at end of the buffer list. |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
999 ;; We want buffers existing prior to evaluating the desktop (and |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
1000 ;; not reused) to be placed at the end of the buffer list, so we |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
1001 ;; move them here. |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
1002 (mapc 'bury-buffer |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
1003 (nreverse (cdr (memq desktop-first-buffer (nreverse (buffer-list)))))) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
1004 (switch-to-buffer (car (buffer-list))) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
1005 (run-hooks 'desktop-delay-hook) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
1006 (setq desktop-delay-hook nil) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
1007 (run-hooks 'desktop-after-read-hook) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
1008 (message "Desktop: %d buffer%s restored%s%s." |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
1009 desktop-buffer-ok-count |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
1010 (if (= 1 desktop-buffer-ok-count) "" "s") |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
1011 (if (< 0 desktop-buffer-fail-count) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
1012 (format ", %d failed to restore" desktop-buffer-fail-count) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
1013 "") |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
1014 (if desktop-buffer-args-list |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
1015 (format ", %d to restore lazily" |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
1016 (length desktop-buffer-args-list)) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
1017 "")) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
1018 t)) |
52674 | 1019 ;; No desktop file found. |
1020 (desktop-clear) | |
1021 (let ((default-directory desktop-dirname)) | |
1022 (run-hooks 'desktop-no-desktop-file-hook)) | |
1023 (message "No desktop file.") | |
1024 nil))) | |
1025 | |
1026 ;; ---------------------------------------------------------------------------- | |
1027 ;; Maintained for backward compatibility | |
1028 ;;;###autoload | |
3404 | 1029 (defun desktop-load-default () |
10595 | 1030 "Load the `default' start-up library manually. |
52674 | 1031 Also inhibit further loading of it." |
64674
b110ecf69f54
(desktop-save-buffer): Fix typos in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
64566
diff
changeset
|
1032 (unless inhibit-default-init ; safety check |
b110ecf69f54
(desktop-save-buffer): Fix typos in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
64566
diff
changeset
|
1033 (load "default" t t) |
b110ecf69f54
(desktop-save-buffer): Fix typos in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
64566
diff
changeset
|
1034 (setq inhibit-default-init t))) |
b110ecf69f54
(desktop-save-buffer): Fix typos in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
64566
diff
changeset
|
1035 (make-obsolete 'desktop-load-default |
b110ecf69f54
(desktop-save-buffer): Fix typos in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
64566
diff
changeset
|
1036 'desktop-save-mode "22.1") |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1037 |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1038 ;; ---------------------------------------------------------------------------- |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1039 ;;;###autoload |
52674 | 1040 (defun desktop-change-dir (dirname) |
1041 "Change to desktop saved in DIRNAME. | |
1042 Kill the desktop as specified by variables `desktop-save-mode' and | |
1043 `desktop-save', then clear the desktop and load the desktop file in | |
1044 directory DIRNAME." | |
1045 (interactive "DChange to directory: ") | |
1046 (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
|
1047 (desktop-kill) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1048 (desktop-clear) |
52674 | 1049 (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
|
1050 |
52674 | 1051 ;; ---------------------------------------------------------------------------- |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1052 ;;;###autoload |
52674 | 1053 (defun desktop-save-in-desktop-dir () |
1054 "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
|
1055 (interactive) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1056 (if desktop-dirname |
64674
b110ecf69f54
(desktop-save-buffer): Fix typos in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
64566
diff
changeset
|
1057 (desktop-save desktop-dirname) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1058 (call-interactively 'desktop-save)) |
100906
43e72c1cf36e
* desktop.el (desktop-save-in-desktop-dir): Use `abbreviate-file-name'
Juanma Barranquero <lekktu@gmail.com>
parents:
100171
diff
changeset
|
1059 (message "Desktop saved in %s" (abbreviate-file-name desktop-dirname))) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1060 |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1061 ;; ---------------------------------------------------------------------------- |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1062 ;;;###autoload |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1063 (defun desktop-revert () |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1064 "Revert to the last loaded desktop." |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1065 (interactive) |
52674 | 1066 (unless desktop-dirname |
1067 (error "Unknown desktop directory")) | |
71453
bef13fc7f695
(desktop-full-file-name): New function.
Lars Hansen <larsh@soem.dk>
parents:
70653
diff
changeset
|
1068 (unless (file-exists-p (desktop-full-file-name)) |
52674 | 1069 (error "No desktop file found")) |
1070 (desktop-clear) | |
1071 (desktop-read desktop-dirname)) | |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1072 |
77115
7596f1771948
(desktop-save, desktop-create-buffer): Replace mapcar with dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76978
diff
changeset
|
1073 (defvar desktop-buffer-major-mode) |
7596f1771948
(desktop-save, desktop-create-buffer): Replace mapcar with dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76978
diff
changeset
|
1074 (defvar desktop-buffer-locals) |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
1075 ;; ---------------------------------------------------------------------------- |
55059
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
1076 (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
|
1077 desktop-buffer-name |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
1078 desktop-buffer-misc) |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
1079 "Restore a file buffer." |
78046
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
1080 (when desktop-buffer-file-name |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
1081 (if (or (file-exists-p desktop-buffer-file-name) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
1082 (let ((msg (format "Desktop: File \"%s\" no longer exists." |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
1083 desktop-buffer-file-name))) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
1084 (if desktop-missing-file-warning |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
1085 (y-or-n-p (concat msg " Re-create buffer? ")) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
1086 (message "%s" msg) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
1087 nil))) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
1088 (let* ((auto-insert nil) ; Disable auto insertion |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
1089 (coding-system-for-read |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
1090 (or coding-system-for-read |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
1091 (cdr (assq 'buffer-file-coding-system |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
1092 desktop-buffer-locals)))) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
1093 (buf (find-file-noselect desktop-buffer-file-name))) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
1094 (condition-case nil |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
1095 (switch-to-buffer buf) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
1096 (error (pop-to-buffer buf))) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
1097 (and (not (eq major-mode desktop-buffer-major-mode)) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
1098 (functionp desktop-buffer-major-mode) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
1099 (funcall desktop-buffer-major-mode)) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
1100 buf) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
1101 nil))) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1102 |
64893
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
1103 (defun desktop-load-file (function) |
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
1104 "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
|
1105 (when function |
68344
ffdb60daf52a
(desktop-load-file): Check for `fboundp' before calling `symbol-function'.
Juri Linkov <juri@jurta.org>
parents:
67560
diff
changeset
|
1106 (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
|
1107 (when (and (listp fcell) |
89bec3b605ff
(desktop-load-file): Do nothing when FUNCTION is nil.
Lars Hansen <larsh@soem.dk>
parents:
65582
diff
changeset
|
1108 (eq 'autoload (car fcell))) |
89bec3b605ff
(desktop-load-file): Do nothing when FUNCTION is nil.
Lars Hansen <larsh@soem.dk>
parents:
65582
diff
changeset
|
1109 (load (cadr fcell)))))) |
64893
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
1110 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
1111 ;; ---------------------------------------------------------------------------- |
55179 | 1112 ;; Create a buffer, load its file, set its mode, ...; |
1113 ;; called from Desktop file only. | |
40210
01666fd1b210
(desktop-last-buffer): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
38798
diff
changeset
|
1114 |
64893
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
1115 ;; Just to silence the byte compiler. |
77115
7596f1771948
(desktop-save, desktop-create-buffer): Replace mapcar with dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76978
diff
changeset
|
1116 |
7596f1771948
(desktop-save, desktop-create-buffer): Replace mapcar with dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76978
diff
changeset
|
1117 (defvar desktop-first-buffer) ; Dynamically bound in `desktop-read' |
7596f1771948
(desktop-save, desktop-create-buffer): Replace mapcar with dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76978
diff
changeset
|
1118 |
7596f1771948
(desktop-save, desktop-create-buffer): Replace mapcar with dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76978
diff
changeset
|
1119 ;; Bound locally in `desktop-read'. |
7596f1771948
(desktop-save, desktop-create-buffer): Replace mapcar with dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76978
diff
changeset
|
1120 (defvar desktop-buffer-ok-count) |
7596f1771948
(desktop-save, desktop-create-buffer): Replace mapcar with dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76978
diff
changeset
|
1121 (defvar desktop-buffer-fail-count) |
40210
01666fd1b210
(desktop-last-buffer): New variable.
Gerd Moellmann <gerd@gnu.org>
parents:
38798
diff
changeset
|
1122 |
57038
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
1123 (defun desktop-create-buffer |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
1124 (desktop-file-version |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
1125 desktop-buffer-file-name |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
1126 desktop-buffer-name |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
1127 desktop-buffer-major-mode |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
1128 desktop-buffer-minor-modes |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
1129 desktop-buffer-point |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
1130 desktop-buffer-mark |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
1131 desktop-buffer-read-only |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
1132 desktop-buffer-misc |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
1133 &optional |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
1134 desktop-buffer-locals) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1135 ;; 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
|
1136 ;; 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
|
1137 (save-current-buffer |
64893
2c0fe8b09aaa
(desktop-buffer-mode-handlers): Make
Lars Hansen <larsh@soem.dk>
parents:
64762
diff
changeset
|
1138 ;; 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
|
1139 (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
|
1140 (let ((buffer-list (buffer-list)) |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
1141 (result |
92944
6dea71380597
(desktop-create-buffer): Don't catch errors if debug-on-error is set.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
92364
diff
changeset
|
1142 (condition-case-no-debug err |
57038
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
1143 (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
|
1144 desktop-buffer-mode-handlers)) |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
1145 'desktop-restore-file-buffer) |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
1146 desktop-buffer-file-name |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
1147 desktop-buffer-name |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
1148 desktop-buffer-misc) |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
1149 (error |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
1150 (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
|
1151 desktop-buffer-name |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
1152 (error-message-string err)) |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
1153 (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
|
1154 nil)))) |
55059
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
1155 (if (bufferp result) |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
1156 (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
|
1157 (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
|
1158 (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
|
1159 ;; 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
|
1160 ;; 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
|
1161 (unless (< desktop-file-version 206) |
58537
619031e477a8
(desktop-read): Replace mapcar with mapc.
Lars Hansen <larsh@soem.dk>
parents:
58180
diff
changeset
|
1162 (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
|
1163 (when result (bury-buffer result))) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1164 (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
|
1165 (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
|
1166 (setq desktop-first-buffer result)) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1167 (set-buffer result) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1168 (unless (equal (buffer-name) desktop-buffer-name) |
79237
80e25357226e
(uniquify-managed): Pacify byte compiler.
Juanma Barranquero <lekktu@gmail.com>
parents:
78236
diff
changeset
|
1169 (rename-buffer desktop-buffer-name t)) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1170 ;; minor modes |
57038
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
1171 (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
|
1172 (auto-fill-mode 1)) |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
1173 ((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
|
1174 (auto-fill-mode 0)) |
791b0637af6d
(desktop-clear-preserve-buffers): Remove make-obsolete-variable.
Lars Hansen <larsh@soem.dk>
parents:
55871
diff
changeset
|
1175 (t |
77115
7596f1771948
(desktop-save, desktop-create-buffer): Replace mapcar with dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76978
diff
changeset
|
1176 (dolist (minor-mode desktop-buffer-minor-modes) |
7596f1771948
(desktop-save, desktop-create-buffer): Replace mapcar with dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76978
diff
changeset
|
1177 ;; Give minor mode module a chance to add a handler. |
7596f1771948
(desktop-save, desktop-create-buffer): Replace mapcar with dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76978
diff
changeset
|
1178 (desktop-load-file minor-mode) |
7596f1771948
(desktop-save, desktop-create-buffer): Replace mapcar with dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76978
diff
changeset
|
1179 (let ((handler (cdr (assq minor-mode desktop-minor-mode-handlers)))) |
7596f1771948
(desktop-save, desktop-create-buffer): Replace mapcar with dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76978
diff
changeset
|
1180 (if handler |
7596f1771948
(desktop-save, desktop-create-buffer): Replace mapcar with dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76978
diff
changeset
|
1181 (funcall handler desktop-buffer-locals) |
7596f1771948
(desktop-save, desktop-create-buffer): Replace mapcar with dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76978
diff
changeset
|
1182 (when (functionp minor-mode) |
7596f1771948
(desktop-save, desktop-create-buffer): Replace mapcar with dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76978
diff
changeset
|
1183 (funcall minor-mode 1))))))) |
7596f1771948
(desktop-save, desktop-create-buffer): Replace mapcar with dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76978
diff
changeset
|
1184 ;; Even though point and mark are non-nil when written by |
7596f1771948
(desktop-save, desktop-create-buffer): Replace mapcar with dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76978
diff
changeset
|
1185 ;; `desktop-save', they may be modified by handlers wanting to set |
7596f1771948
(desktop-save, desktop-create-buffer): Replace mapcar with dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76978
diff
changeset
|
1186 ;; point or mark themselves. |
55059
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
1187 (when desktop-buffer-point |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
1188 (goto-char |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
1189 (condition-case err |
77115
7596f1771948
(desktop-save, desktop-create-buffer): Replace mapcar with dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76978
diff
changeset
|
1190 ;; Evaluate point. Thus point can be something like |
7596f1771948
(desktop-save, desktop-create-buffer): Replace mapcar with dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76978
diff
changeset
|
1191 ;; '(search-forward ... |
55059
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
1192 (eval desktop-buffer-point) |
fa9573e2db2a
(desktop-buffer-mode-handlers): New variabel. Alist
Lars Hansen <larsh@soem.dk>
parents:
54206
diff
changeset
|
1193 (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
|
1194 (when desktop-buffer-mark |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1195 (if (consp desktop-buffer-mark) |
78046
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
1196 (progn |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
1197 (set-mark (car desktop-buffer-mark)) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
1198 (setq mark-active (car (cdr desktop-buffer-mark)))) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1199 (set-mark desktop-buffer-mark))) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1200 ;; Never override file system if the file really is read-only marked. |
78046
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
1201 (when desktop-buffer-read-only (setq buffer-read-only desktop-buffer-read-only)) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1202 (while desktop-buffer-locals |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1203 (let ((this (car desktop-buffer-locals))) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1204 (if (consp this) |
78046
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
1205 ;; an entry of this form `(symbol . value)' |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
1206 (progn |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
1207 (make-local-variable (car this)) |
c395c022a035
(desktop-read): Run `desktop-not-loaded-hook' in the directory where the desktop
Juanma Barranquero <lekktu@gmail.com>
parents:
77991
diff
changeset
|
1208 (set (car this) (cdr this))) |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1209 ;; an entry of the form `symbol' |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1210 (make-local-variable this) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1211 (makunbound this))) |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1212 (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
|
1213 |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1214 ;; ---------------------------------------------------------------------------- |
5465
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
1215 ;; 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
|
1216 (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
|
1217 desktop-buffer-major-mode |
14756
aabf776c3b6a
Global var `misc' renamed.
Richard M. Stallman <rms@gnu.org>
parents:
14755
diff
changeset
|
1218 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
|
1219 (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
|
1220 desktop-buffer-major-mode (cdr mim) pt mk ro |
aabf776c3b6a
Global var `misc' renamed.
Richard M. Stallman <rms@gnu.org>
parents:
14755
diff
changeset
|
1221 desktop-buffer-misc |
5465
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
1222 (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
|
1223 (cons 'fill-column fc) |
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
1224 (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
|
1225 (cons 'case-replace cr) |
9fcfca1caec7
(desktop-buffer-mh): New function for mh mail system.
Richard M. Stallman <rms@gnu.org>
parents:
5314
diff
changeset
|
1226 (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
|
1227 |
59412
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1228 (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
|
1229 "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
|
1230 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
|
1231 (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
|
1232 (unless desktop-lazy-timer |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1233 (setq desktop-lazy-timer |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1234 (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
|
1235 |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1236 (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
|
1237 "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
|
1238 (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
|
1239 (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
|
1240 (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
|
1241 (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
|
1242 (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
|
1243 buffer-name remaining))) |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1244 (when desktop-lazy-verbose |
65582
4d1085b02d64
Message format spec fixes (1)
Deepak Goel <deego@gnufans.org>
parents:
64963
diff
changeset
|
1245 (message "%s" msg)) |
59412
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1246 (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
|
1247 (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
|
1248 (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
|
1249 (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
|
1250 (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
|
1251 (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
|
1252 (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
|
1253 (when desktop-lazy-verbose |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1254 (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
|
1255 |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1256 (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
|
1257 "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
|
1258 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
|
1259 (let ((repeat 1)) |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1260 (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
|
1261 (save-window-excursion |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1262 (desktop-lazy-create-buffer)) |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1263 (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
|
1264 (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
|
1265 (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
|
1266 (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
|
1267 (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
|
1268 (sit-for 3) |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1269 (message ""))))) |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1270 |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1271 (defun desktop-lazy-complete () |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1272 "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
|
1273 (interactive) |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1274 (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
|
1275 (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
|
1276 (save-window-excursion |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1277 (desktop-lazy-create-buffer))) |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1278 (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
|
1279 |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1280 (defun desktop-lazy-abort () |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1281 "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
|
1282 (interactive) |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1283 (when desktop-lazy-timer |
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1284 (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
|
1285 (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
|
1286 (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
|
1287 (setq desktop-buffer-args-list nil) |
105372
bd2966850aac
Use `called-interactively-p' instead of `interactive-p'.
Juanma Barranquero <lekktu@gmail.com>
parents:
105031
diff
changeset
|
1288 (when (called-interactively-p 'interactive) |
59412
0ddd142616f1
(desktop-restore-eager, desktop-lazy-verbose, desktop-lazy-idle-delay):
Lars Hansen <larsh@soem.dk>
parents:
58537
diff
changeset
|
1289 (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
|
1290 |
4830
a61307ac474e
Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents:
3405
diff
changeset
|
1291 ;; ---------------------------------------------------------------------------- |
52674 | 1292 ;; 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
|
1293 ;; 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
|
1294 ;; after finishing loading the init file. |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1295 ;; 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
|
1296 ;; 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
|
1297 (add-hook |
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1298 'after-init-hook |
77115
7596f1771948
(desktop-save, desktop-create-buffer): Replace mapcar with dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76978
diff
changeset
|
1299 (lambda () |
50507
110c0e29159c
Handle multiple desktop files in different dirs.
Richard M. Stallman <rms@gnu.org>
parents:
48143
diff
changeset
|
1300 (let ((key "--no-desktop")) |
61638
ef63bf685348
Make "--no-desktop" turn off `desktop-save-mode'.
Lars Hansen <larsh@soem.dk>
parents:
61236
diff
changeset
|
1301 (when (member key command-line-args) |
ef63bf685348
Make "--no-desktop" turn off `desktop-save-mode'.
Lars Hansen <larsh@soem.dk>
parents:
61236
diff
changeset
|
1302 (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
|
1303 (setq desktop-save-mode nil))) |
91810
81c282959319
(after-init-hook): Set inhibit-startup-screen to t
Juri Linkov <juri@jurta.org>
parents:
91327
diff
changeset
|
1304 (when desktop-save-mode |
81c282959319
(after-init-hook): Set inhibit-startup-screen to t
Juri Linkov <juri@jurta.org>
parents:
91327
diff
changeset
|
1305 (desktop-read) |
81c282959319
(after-init-hook): Set inhibit-startup-screen to t
Juri Linkov <juri@jurta.org>
parents:
91327
diff
changeset
|
1306 (setq inhibit-startup-screen t)))) |
20526
ec0a8ccddd6c
(desktop-enable): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
18581
diff
changeset
|
1307 |
3405 | 1308 (provide 'desktop) |
3404 | 1309 |
77115
7596f1771948
(desktop-save, desktop-create-buffer): Replace mapcar with dolist.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
76978
diff
changeset
|
1310 ;; 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
|
1311 ;;; desktop.el ends here |