annotate lisp/desktop.el @ 5104:bcf4b8ed1c60

(inferior-lisp-proc): Clean up error message.
author Richard M. Stallman <rms@gnu.org>
date Mon, 22 Nov 1993 00:42:30 +0000
parents a61307ac474e
children e65e125e5334
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>
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
6 ;; Version: 2.02
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
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 ;; GNU Emacs is free software; you can redistribute it and/or modify
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 ;; 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
12 ;; the Free Software Foundation; either version 2, or (at your option)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; any later version.
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 ;;; Commentary:
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
26 ;; Save the Desktop, i.e.,
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
27 ;; - some global variables
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
28 ;; - 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
29 ;; - the major mode
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
30 ;; - the default directory
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
31 ;; - the point
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
32 ;; - the mark & mark-active
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
33 ;; - buffer-read-only
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
34 ;; - truncate-lines
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
35 ;; - case-fold-search
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
36 ;; - case-replace
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
37 ;; - fill-column
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
39 ;; 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
40 ;; file (the later the better):
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
41 ;;
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
42 ;; (load "desktop")
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
43 ;; (desktop-load-default)
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
44 ;; (desktop-read)
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
45 ;;
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
47 ;; 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
48 ;; 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
49 ;; 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
50 ;; 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
51 ;; 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
52 ;; left them.
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
53 ;;
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
54 ;; 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
55 ;; `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
56 ;; 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
57 ;;
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
58 ;; 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
59 ;; 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
60 ;; 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
61 ;; ---------------------------------------------------------------------------
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
62 ;; TODO:
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 ;; Save window configuration.
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
65 ;; Recognize more minor modes.
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
66 ;; Save mark rings.
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
67 ;; Start-up with buffer-menu???
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 ;;; Code:
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
71 ;; 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
72 ;; ----------------------------------------------------------------------------
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
73 (defconst desktop-basefilename
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 (if (equal system-type 'ms-dos)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 "emacs.dsk" ; Ms-Dos does not support multiple dots in file name
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 ".emacs.desktop")
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 "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
78
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
79 (defvar desktop-missing-file-warning t
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 "*If non-nil then issue warning if a file no longer exists.
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 Otherwise simply ignore the file.")
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
83 (defvar desktop-globals-to-save
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 (list 'desktop-missing-file-warning
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
85 ;; 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
86 ;; 'kill-ring
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
87 'tags-file-name
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
88 'tags-table-list
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
89 ;; 'desktop-globals-to-save ; Itself!
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
90 )
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 "List of global variables to save when killing Emacs.")
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
93 ;; 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
94 ;; (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
95 ;; TAGS files to save time (tags-file-name is saved instead).
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 (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
97 "\\(\\.log\\|(ftp)\\|^tags\\|^TAGS\\)$"
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 "Regexp identifying buffers that are to be excluded from saving.")
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 (defvar desktop-buffer-handlers
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
101 '(desktop-buffer-dired
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 desktop-buffer-rmail
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 desktop-buffer-info
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 desktop-buffer-file)
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
105 "*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
106 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
107 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
108 `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
109 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
110 ;; ----------------------------------------------------------------------------
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
111 (defvar desktop-dirname nil
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 "The directory in which the current desktop file resides.")
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 (defconst desktop-header
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
115 ";; --------------------------------------------------------------------------
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
116 ;; Desktop File for Emacs
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
117 ;; --------------------------------------------------------------------------
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 " "*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
119 ;; ----------------------------------------------------------------------------
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
120 (defconst postv18
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 (string-lessp "19" emacs-version)
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
122 "t if Emacs version 19 or later.")
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 (defun desktop-clear () "Empty the Desktop."
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 (interactive)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 (setq kill-ring nil)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 (setq kill-ring-yank-pointer nil)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 (mapcar (function kill-buffer) (buffer-list)))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
129 ;; ----------------------------------------------------------------------------
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
130 ;; 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
131 ;; toilet-trained considering hooks.
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 (if (not (boundp 'desktop-kill))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 (if postv18
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 (add-hook 'kill-emacs-hook 'desktop-kill)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135 (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
136 (setq kill-emacs-hook
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
137 (function (lambda ()
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
138 (progn (desktop-kill)
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
139 (if (or (null old-kill-emacs)
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
140 (symbolp old-kill-emacs))
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
141 (run-hooks old-kill-emacs)
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
142 (funcall old-kill-emacs))))))))
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
143 ;; ----------------------------------------------------------------------------
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 (defun desktop-kill ()
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
145 (if desktop-dirname
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 (progn
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 (desktop-save desktop-dirname))))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
148 ;; ----------------------------------------------------------------------------
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 (defun desktop-outvar (VAR)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 "Output a setq statement for VAR to the desktop file."
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 (if (boundp VAR)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152 (progn
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153 (insert "(setq ")
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154 (prin1 VAR (current-buffer))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155 (insert " '")
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156 (prin1 (symbol-value VAR) (current-buffer))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 (insert ")\n"))))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
158 ;; ----------------------------------------------------------------------------
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159 (defun desktop-save-buffer-p (filename bufname mode)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160 "Return t if 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
161 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
162 MODE is the major mode."
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
163
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164 (or (and filename
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 (not (string-match desktop-buffers-not-to-save bufname)))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166 (and (null filename)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
167 (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
168 ;; ----------------------------------------------------------------------------
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
169 (defun desktop-save (dirname)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170 "Save the Desktop file. Parameter DIRNAME specifies where to save desktop."
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171 (interactive "DDirectory to save desktop file in: ")
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
172 (save-excursion
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
173 (let ((filename (expand-file-name
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174 (concat dirname desktop-basefilename)))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
175 (info (nreverse
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
176 (mapcar
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177 (function (lambda (b)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 (set-buffer b)
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
179 (list
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180 (buffer-file-name)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181 (buffer-name)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 (list 'quote major-mode)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 (list 'quote
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
184 (list overwrite-mode
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
185 (not (null
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186 (if postv18
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187 auto-fill-function
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188 auto-fill-hook)))))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 (point)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190 (if postv18
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
191 (list 'quote (mark t) mark-active)
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192 (mark))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193 buffer-read-only
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194 truncate-lines
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195 fill-column
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196 case-fold-search
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197 case-replace
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
198 (list
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199 'quote
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200 (cond ((equal major-mode 'Info-mode)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201 (list Info-current-file
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202 Info-current-node))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203 ((equal major-mode 'dired-mode)
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
204 (if postv18
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
205 (nreverse
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
206 (mapcar
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
207 (function car)
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
208 dired-subdir-alist))
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
209 (list default-directory)))
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210 ))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
211 )))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212 (buffer-list))))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213 (buf (get-buffer-create "*desktop*")))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214 (set-buffer buf)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215 (erase-buffer)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
217 (insert desktop-header
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
218 ";; Created " (current-time-string) "\n"
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
219 ";; Emacs version " emacs-version "\n\n"
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
220 ";; Global section:\n")
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221 (mapcar (function desktop-outvar) desktop-globals-to-save)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222 (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
223 (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
224 (int-to-string
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225 (- (length kill-ring) (length kill-ring-yank-pointer)))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
226 " kill-ring))\n"))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
228 (insert "\n;; Buffer section:\n")
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
229 (mapcar
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230 (function (lambda (l)
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
231 (if (desktop-save-buffer-p
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
232 (car l)
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
233 (nth 1 l)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
234 (nth 1 (nth 2 l)))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
235 (progn
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236 (insert "(desktop-buffer")
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
237 (mapcar
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
238 (function (lambda (e)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
239 (insert "\n ")
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
240 (prin1 e (current-buffer))))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
241 l)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
242 (insert ")\n\n")))))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
243 info)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
244 (setq default-directory dirname)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
245 (if (file-exists-p filename) (delete-file filename))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
246 (write-region (point-min) (point-max) filename nil 'nomessage)))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
247 (setq desktop-dirname dirname))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
248 ;; ----------------------------------------------------------------------------
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
249 (defun desktop-remove ()
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
250 "Delete the Desktop file and inactivate the desktop system."
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
251 (interactive)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
252 (if desktop-dirname
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253 (let ((filename (concat desktop-dirname desktop-basefilename)))
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 (setq desktop-dirname nil))))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
256 ;; ----------------------------------------------------------------------------
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
257 (defun desktop-read ()
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
258 "Read the Desktop file and the files it specifies."
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259 (interactive)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
260 (let ((filename))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
261 (if (file-exists-p (concat "./" desktop-basefilename))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262 (setq desktop-dirname (expand-file-name "./"))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
263 (if (file-exists-p (concat "~/" desktop-basefilename))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
264 (setq desktop-dirname (expand-file-name "~/"))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
265 (setq desktop-dirname nil)))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
266 (if desktop-dirname
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
267 (progn
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
268 (load (concat desktop-dirname desktop-basefilename) t t t)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
269 (message "Desktop loaded."))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
270 (desktop-clear))))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
271 ;; ----------------------------------------------------------------------------
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
272 (defun desktop-load-default ()
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
273 "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
274 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
275 autoloaded files."
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
276 (if (not inhibit-default-init) ; safety check
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
277 (progn
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
278 (load "default" t t)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
279 (setq inhibit-default-init t))))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
280 ;; ----------------------------------------------------------------------------
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
281 ;; 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
282 ;; 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
283 ;;
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
284 (defun desktop-buffer-info () "Load an info file."
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
285 (if (equal 'Info-mode mam)
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 (require 'info)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
288 (Info-find-node (nth 0 misc) (nth 1 misc))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
289 t)))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
290 ;; ----------------------------------------------------------------------------
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
291 (defun desktop-buffer-rmail () "Load a RMAIL file."
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
292 (if (equal 'rmail-mode mam)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
293 (progn (rmail-input fn) t)))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
294 ;; ----------------------------------------------------------------------------
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
295 (defun desktop-buffer-dired () "Load a directory using dired."
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
296 (if (equal 'dired-mode mam)
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
297 (progn
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
298 (dired (car misc))
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
299 (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
300 t)))
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
301 ;; ----------------------------------------------------------------------------
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
302 (defun desktop-buffer-file () "Load a file."
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
303 (if fn
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
304 (if (or (file-exists-p fn)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
305 (and desktop-missing-file-warning
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
306 (y-or-n-p (format
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
307 "File \"%s\" no longer exists. Re-create? "
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
308 fn))))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
309 (progn (find-file fn) t)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
310 'ignored)))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
311 ;; ----------------------------------------------------------------------------
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
312 ;; 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
313 ;; only.
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
314 (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
315 (let ((hlist desktop-buffer-handlers)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
316 (result)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
317 (handler))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
318 (while (and (not result) hlist)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
319 (setq handler (car hlist))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
320 (setq result (funcall handler))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
321 (setq hlist (cdr hlist)))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
322 (if (equal result t)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
323 (progn
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
324 (if (not (equal (buffer-name) bn))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
325 (rename-buffer bn))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
326 (if (nth 0 mim)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
327 (overwrite-mode 1)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
328 (overwrite-mode 0))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
329 (if (nth 1 mim)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
330 (auto-fill-mode 1)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
331 (overwrite-mode 0))
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
332 (goto-char pt)
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
333 (if (consp mk)
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
334 (progn
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
335 (set-mark (car mk))
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
336 (setq mark-active (car (cdr mk))))
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
337 (set-mark mk))
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
338 ;; 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
339 (if ro (setq buffer-read-only ro))
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
340 (setq truncate-lines tl)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
341 (setq fill-column fc)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
342 (setq case-fold-search cfs)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
343 (setq case-replace cr)
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
344 ))))
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
345 ;; ----------------------------------------------------------------------------
3405
b48f023e8e29 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 3404
diff changeset
346 (provide 'desktop)
3404
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
347
777e0d4f775a Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
348 ;; desktop.el ends here.
4830
a61307ac474e Internal clean-up. Save information about current
Richard M. Stallman <rms@gnu.org>
parents: 3405
diff changeset
349