annotate lisp/desktop.el @ 54440:aabf30299e6c

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