annotate lisp/desktop.el @ 5314:e65e125e5334

Add keywords. (desktop-outvar): clean-up output using fewer quotes and \n for newlines. (desktop-save): print buffer information using \n for newlines. (desktop-save-buffer-p): doc fix. (desktop-save): bug in mark-activity saving. (desktop-buffer-rmail): doc fix. (desktop-buffer-rmail, desktop-buffer-dired, desktop-buffer): Use `eq' instead of `equal'. (desktop-clear): end up with one window.
author Richard M. Stallman <rms@gnu.org>
date Thu, 23 Dec 1993 04:59:47 +0000
parents a61307ac474e
children 9fcfca1caec7
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
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3 ;; Copyright (C) 1993 Free Software Foundation, Inc.
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5 ;; Author: Morten Welinder <terra@diku.dk>
5314
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
6 ;; Version: 2.03
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
7 ;; Keywords: customization
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
8 ;; Favourite-brand-of-beer: None, I hate beer.
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10 ;; This file is part of GNU Emacs.
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; 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
14 ;; the Free Software Foundation; either version 2, or (at your option)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; any later version.
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; GNU General Public License for more details.
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 ;; along with GNU Emacs; see the file COPYING. If not, write to
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26 ;;; Commentary:
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
28 ;; Save the Desktop, i.e.,
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
29 ;; - some global variables
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
30 ;; - the list of buffers with associated files. For each buffer also
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
31 ;; - the major mode
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
32 ;; - the default directory
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
33 ;; - the point
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
34 ;; - the mark & mark-active
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
35 ;; - buffer-read-only
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
36 ;; - truncate-lines
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
37 ;; - case-fold-search
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
38 ;; - case-replace
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
39 ;; - fill-column
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
41 ;; To use this, first put these three lines in the bottom of your .emacs
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
42 ;; file (the later the better):
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
43 ;;
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
44 ;; (load "desktop")
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
45 ;; (desktop-load-default)
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
46 ;; (desktop-read)
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
47 ;;
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
49 ;; Start Emacs in the root directory of your "project". The desktop saver
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
50 ;; is inactive by default. You activate it by M-x desktop-save RET. When
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
51 ;; you exit the next time the above data will be saved. This ensures that
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
52 ;; all the files you were editing will be reloaded the next time you start
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
53 ;; Emacs from the same directory and that points will be set where you
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
54 ;; left them.
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
55 ;;
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
56 ;; 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
57 ;; `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
58 ;; things you did not mean to keep. Use M-x desktop-clear RET.
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
59 ;;
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
60 ;; Thanks to hetrick@phys.uva.nl (Jim Hetrick) for useful ideas.
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
61 ;; avk@rtsg.mot.com (Andrew V. Klein) for a dired tip.
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
62 ;; chris@tecc.co.uk (Chris Boucher) for a mark tip.
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
63 ;; ---------------------------------------------------------------------------
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
64 ;; TODO:
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
65 ;;
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
66 ;; Save window configuration.
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
67 ;; Recognize more minor modes.
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
68 ;; Save mark rings.
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
69 ;; Start-up with buffer-menu???
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 ;;; Code:
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
73 ;; 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
74 ;; ----------------------------------------------------------------------------
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
75 (defconst desktop-basefilename
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 (if (equal system-type 'ms-dos)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 "emacs.dsk" ; Ms-Dos does not support multiple dots in file name
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 ".emacs.desktop")
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 "File for Emacs desktop. A directory name will be prepended to this name.")
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
81 (defvar desktop-missing-file-warning t
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 "*If non-nil then issue warning if a file no longer exists.
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 Otherwise simply ignore the file.")
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
85 (defvar desktop-globals-to-save
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 (list 'desktop-missing-file-warning
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
87 ;; Feature: saving kill-ring implies saving kill-ring-yank-pointer
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
88 ;; 'kill-ring
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
89 'tags-file-name
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
90 'tags-table-list
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
91 ;; 'desktop-globals-to-save ; Itself!
5314
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
92 )
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 "List of global variables to save when killing Emacs.")
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
95 ;; We skip .log files because they are normally temporary.
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
96 ;; (ftp) files because they require passwords and whatsnot.
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
97 ;; TAGS files to save time (tags-file-name is saved instead).
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 (defvar desktop-buffers-not-to-save
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
99 "\\(\\.log\\|(ftp)\\|^tags\\|^TAGS\\)$"
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 "Regexp identifying buffers that are to be excluded from saving.")
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 (defvar desktop-buffer-handlers
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
103 '(desktop-buffer-dired
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 desktop-buffer-rmail
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 desktop-buffer-info
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 desktop-buffer-file)
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
107 "*List of functions to call in order to create a buffer. The functions are
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
108 called without explicit parameters but may access the the major mode as `mam',
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
109 the file name as `fn', the buffer name as `bn', the default directory as
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
110 `dd'. If some function returns non-nil no further functions are called.
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 If the function returns t then the buffer is considered created.")
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
112 ;; ----------------------------------------------------------------------------
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
113 (defvar desktop-dirname nil
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 "The directory in which the current desktop file resides.")
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 (defconst desktop-header
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
117 ";; --------------------------------------------------------------------------
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
118 ;; Desktop File for Emacs
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
119 ;; --------------------------------------------------------------------------
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 " "*Header to place in Desktop file.")
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
121 ;; ----------------------------------------------------------------------------
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
122 (defconst postv18
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 (string-lessp "19" emacs-version)
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
124 "t if Emacs version 19 or later.")
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 (defun desktop-clear () "Empty the Desktop."
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 (interactive)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 (setq kill-ring nil)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129 (setq kill-ring-yank-pointer nil)
5314
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
130 (mapcar (function kill-buffer) (buffer-list))
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
131 (delete-other-windows))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
132 ;; ----------------------------------------------------------------------------
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
133 ;; This is a bit dirty for version 18 because that version of Emacs was not
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
134 ;; toilet-trained considering hooks.
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135 (if (not (boundp 'desktop-kill))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 (if postv18
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 (add-hook 'kill-emacs-hook 'desktop-kill)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 (setq old-kill-emacs kill-emacs-hook)
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
139 (setq kill-emacs-hook
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
140 (function (lambda ()
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
141 (progn (desktop-kill)
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
142 (if (or (null old-kill-emacs)
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
143 (symbolp old-kill-emacs))
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
144 (run-hooks old-kill-emacs)
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
145 (funcall old-kill-emacs))))))))
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
146 ;; ----------------------------------------------------------------------------
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 (defun desktop-kill ()
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
148 (if desktop-dirname
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 (progn
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 (desktop-save desktop-dirname))))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
151 ;; ----------------------------------------------------------------------------
5314
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
152 (defun desktop-outvar (var)
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153 "Output a setq statement for VAR to the desktop file."
5314
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
154 (if (boundp var)
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
155 (let ((print-escape-newlines t)
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
156 (val (symbol-value var)))
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 (insert "(setq ")
5314
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
158 (prin1 var (current-buffer))
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
159 ;; symbols are needed for cons cells and for symbols except
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
160 ;; `t' and `nil'.
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
161 (if (or (consp val)
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
162 (and (symbolp val) val (not (eq t val))))
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
163 (insert " '")
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
164 (insert " "))
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
165 (prin1 val (current-buffer))
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166 (insert ")\n"))))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
167 ;; ----------------------------------------------------------------------------
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168 (defun desktop-save-buffer-p (filename bufname mode)
5314
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
169 "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
170 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
171 MODE is the major mode."
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
172 (or (and filename
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173 (not (string-match desktop-buffers-not-to-save bufname)))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174 (and (null filename)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175 (memq mode '(Info-mode dired-mode rmail-mode)))))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
176 ;; ----------------------------------------------------------------------------
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177 (defun desktop-save (dirname)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 "Save the Desktop file. Parameter DIRNAME specifies where to save desktop."
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179 (interactive "DDirectory to save desktop file in: ")
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180 (save-excursion
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
181 (let ((filename (expand-file-name
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 (concat dirname desktop-basefilename)))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
183 (info (nreverse
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
184 (mapcar
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 (function (lambda (b)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186 (set-buffer b)
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
187 (list
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188 (buffer-file-name)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 (buffer-name)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190 (list 'quote major-mode)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191 (list 'quote
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
192 (list overwrite-mode
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
193 (not (null
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194 (if postv18
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195 auto-fill-function
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196 auto-fill-hook)))))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197 (point)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198 (if postv18
5314
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
199 (list 'quote (list (mark t) mark-active))
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200 (mark))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201 buffer-read-only
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202 truncate-lines
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203 fill-column
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204 case-fold-search
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205 case-replace
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
206 (list
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207 'quote
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208 (cond ((equal major-mode 'Info-mode)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209 (list Info-current-file
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210 Info-current-node))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
211 ((equal major-mode 'dired-mode)
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
212 (if postv18
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
213 (nreverse
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
214 (mapcar
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
215 (function car)
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
216 dired-subdir-alist))
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
217 (list default-directory)))
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218 ))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219 )))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220 (buffer-list))))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221 (buf (get-buffer-create "*desktop*")))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222 (set-buffer buf)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
223 (erase-buffer)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
225 (insert desktop-header
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
226 ";; Created " (current-time-string) "\n"
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
227 ";; Emacs version " emacs-version "\n\n"
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
228 ";; Global section:\n")
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
229 (mapcar (function desktop-outvar) desktop-globals-to-save)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230 (if (memq 'kill-ring desktop-globals-to-save)
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
231 (insert "(setq kill-ring-yank-pointer (nthcdr "
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
232 (int-to-string
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
233 (- (length kill-ring) (length kill-ring-yank-pointer)))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
234 " kill-ring))\n"))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
235
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
236 (insert "\n;; Buffer section:\n")
5314
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
237 (let ((print-escape-newlines t))
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
238 (mapcar
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
239 (function (lambda (l)
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
240 (if (desktop-save-buffer-p
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
241 (car l)
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
242 (nth 1 l)
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
243 (nth 1 (nth 2 l)))
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
244 (progn
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
245 (insert "(desktop-buffer")
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
246 (mapcar
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
247 (function (lambda (e)
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
248 (insert "\n ")
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
249 (prin1 e (current-buffer))))
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
250 l)
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
251 (insert ")\n\n")))))
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
252 info))
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253 (setq default-directory dirname)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
254 (if (file-exists-p filename) (delete-file filename))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
255 (write-region (point-min) (point-max) filename nil 'nomessage)))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
256 (setq desktop-dirname dirname))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
257 ;; ----------------------------------------------------------------------------
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
258 (defun desktop-remove ()
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259 "Delete the Desktop file and inactivate the desktop system."
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
260 (interactive)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
261 (if desktop-dirname
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262 (let ((filename (concat desktop-dirname desktop-basefilename)))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
263 (if (file-exists-p filename) (delete-file filename))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
264 (setq desktop-dirname nil))))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
265 ;; ----------------------------------------------------------------------------
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
266 (defun desktop-read ()
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
267 "Read the Desktop file and the files it specifies."
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
268 (interactive)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
269 (let ((filename))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
270 (if (file-exists-p (concat "./" desktop-basefilename))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
271 (setq desktop-dirname (expand-file-name "./"))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
272 (if (file-exists-p (concat "~/" desktop-basefilename))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
273 (setq desktop-dirname (expand-file-name "~/"))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
274 (setq desktop-dirname nil)))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
275 (if desktop-dirname
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
276 (progn
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
277 (load (concat desktop-dirname desktop-basefilename) t t t)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
278 (message "Desktop loaded."))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
279 (desktop-clear))))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
280 ;; ----------------------------------------------------------------------------
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
281 (defun desktop-load-default ()
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
282 "Load the `default' start-up library manually. Also inhibit further loading
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
283 of it. Call this from your `.emacs' file to provide correct modes for
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
284 autoloaded files."
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
285 (if (not inhibit-default-init) ; safety check
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
286 (progn
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
287 (load "default" t t)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
288 (setq inhibit-default-init t))))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
289 ;; ----------------------------------------------------------------------------
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
290 ;; 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
291 ;; The byte compiler may therefore complain of undeclared variables.
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
292 ;;
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
293 (defun desktop-buffer-info () "Load an info file."
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
294 (if (equal 'Info-mode mam)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
295 (progn
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
296 (require 'info)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
297 (Info-find-node (nth 0 misc) (nth 1 misc))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
298 t)))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
299 ;; ----------------------------------------------------------------------------
5314
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
300 (defun desktop-buffer-rmail () "Load an RMAIL file."
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
301 (if (eq 'rmail-mode mam)
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
302 (progn (rmail-input fn) t)))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
303 ;; ----------------------------------------------------------------------------
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
304 (defun desktop-buffer-dired () "Load a directory using dired."
5314
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
305 (if (eq 'dired-mode mam)
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
306 (progn
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
307 (dired (car misc))
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
308 (mapcar (function dired-maybe-insert-subdir) (cdr misc))
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
309 t)))
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
310 ;; ----------------------------------------------------------------------------
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
311 (defun desktop-buffer-file () "Load a file."
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
312 (if fn
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
313 (if (or (file-exists-p fn)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
314 (and desktop-missing-file-warning
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
315 (y-or-n-p (format
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
316 "File \"%s\" no longer exists. Re-create? "
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
317 fn))))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
318 (progn (find-file fn) t)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
319 'ignored)))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
320 ;; ----------------------------------------------------------------------------
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
321 ;; 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
322 ;; only.
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
323 (defun desktop-buffer (fn bn mam mim pt mk ro tl fc cfs cr misc)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
324 (let ((hlist desktop-buffer-handlers)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
325 (result)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
326 (handler))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
327 (while (and (not result) hlist)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
328 (setq handler (car hlist))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
329 (setq result (funcall handler))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
330 (setq hlist (cdr hlist)))
5314
e65e125e5334 Add keywords.
Richard M. Stallman <rms@gnu.org>
parents: 4830
diff changeset
331 (if (eq result t)
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
332 (progn
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
333 (if (not (equal (buffer-name) bn))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
334 (rename-buffer bn))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
335 (if (nth 0 mim)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
336 (overwrite-mode 1)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
337 (overwrite-mode 0))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
338 (if (nth 1 mim)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
339 (auto-fill-mode 1)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
340 (overwrite-mode 0))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
341 (goto-char pt)
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
342 (if (consp mk)
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
343 (progn
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
344 (set-mark (car mk))
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
345 (setq mark-active (car (cdr mk))))
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
346 (set-mark mk))
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
347 ;; Never override file system if the file really is read-only marked.
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
348 (if ro (setq buffer-read-only ro))
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
349 (setq truncate-lines tl)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
350 (setq fill-column fc)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
351 (setq case-fold-search cfs)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
352 (setq case-replace cr)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
353 ))))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
354 ;; ----------------------------------------------------------------------------
3405
b48f023e8e29 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 3404
diff changeset
355 (provide 'desktop)
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
356
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
357 ;; desktop.el ends here.