aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Wiegley2000-10-13 09:11:16 +0000
committerJohn Wiegley2000-10-13 09:11:16 +0000
commitb6b70cda7c8e69edfc1beac33df8de892b9753b1 (patch)
tree05e2a7798623dbf699da4e0d774ee1bb295b3817
parent8c6b1d83116d00e27f22e501e5ac4fea9a7ba182 (diff)
downloademacs-b6b70cda7c8e69edfc1beac33df8de892b9753b1.tar.gz
emacs-b6b70cda7c8e69edfc1beac33df8de892b9753b1.zip
Added extensible special buffer support to desktop.el. See the
ChangeLog.
-rw-r--r--lisp/ChangeLog20
-rw-r--r--lisp/desktop.el70
2 files changed, 73 insertions, 17 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 7077ad7b588..641f727c45d 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,25 @@
12000-10-13 John Wiegley <johnw@gnu.org> 12000-10-13 John Wiegley <johnw@gnu.org>
2 2
3 * desktop.el (desktop-buffer-modes-to-save): Added a global for
4 specifying what "other" kinds of buffers should be saved. This
5 used to be hard-coded.
6 (desktop-buffer-misc-functions): A global for specifying how
7 auxiliary data should be determined for special buffer types.
8 (desktop-save-buffer-p): Use `desktop-buffer-modes-to-save',
9 instead of hard-coding the special buffer types.
10 (desktop-save): Run `desktop-buffer-misc-functions' to gather
11 auxiliary data, instead of hard-coding for Info buffers and dired.
12 (desktop-buffer-info-misc-data): Aux function for determining Info
13 buffer auxiliary info.
14 (desktop-buffer-dired-misc-data): Likewise, but for dired buffers.
15 (desktop-buffer-info): Changed this function to use the info
16 gathered above.
17 (desktop-create-buffer): Be a little more careful about what
18 `minor-mode' means before calling it. This is important for some
19 buffer types.
20
212000-10-13 John Wiegley <johnw@gnu.org>
22
3 * eshell/esh-util.el: Added a global form which declares an 23 * eshell/esh-util.el: Added a global form which declares an
4 autoload for `parse-time-string', if that function is not already 24 autoload for `parse-time-string', if that function is not already
5 defined, and if parse-time.el is available on the user's system. 25 defined, and if parse-time.el is available on the user's system.
diff --git a/lisp/desktop.el b/lisp/desktop.el
index 8c55edb3bd7..95ae3c91040 100644
--- a/lisp/desktop.el
+++ b/lisp/desktop.el
@@ -1,6 +1,6 @@
1;;; desktop.el --- save partial status of Emacs when killed 1;;; desktop.el --- save partial status of Emacs when killed
2 2
3;; Copyright (C) 1993, 1994, 1995, 1997 Free Software Foundation, Inc. 3;; Copyright (C) 1993, 1994, 1995, 1997, 2000 Free Software Foundation, Inc.
4 4
5;; Author: Morten Welinder <terra@diku.dk> 5;; Author: Morten Welinder <terra@diku.dk>
6;; Keywords: convenience 6;; Keywords: convenience
@@ -182,6 +182,14 @@ The variables are saved only when they really are local.")
182 :type 'regexp 182 :type 'regexp
183 :group 'desktop) 183 :group 'desktop)
184 184
185(defcustom desktop-buffer-modes-to-save
186 '(Info-mode rmail-mode)
187 "If a buffer is of one of these major modes, save the buffer name.
188It is up to the functions in `desktop-buffer-handlers' to decide
189whether the buffer should be recreated or not, and how."
190 :type '(repeat symbol)
191 :group 'desktop)
192
185(defcustom desktop-modes-not-to-save nil 193(defcustom desktop-modes-not-to-save nil
186 "List of major modes whose buffers should not be saved." 194 "List of major modes whose buffers should not be saved."
187 :type '(repeat symbol) 195 :type '(repeat symbol)
@@ -206,6 +214,21 @@ The variables are saved only when they really are local.")
206 "When desktop creates a buffer, this holds a list of misc info. 214 "When desktop creates a buffer, this holds a list of misc info.
207It is used by the `desktop-buffer-handlers' functions.") 215It is used by the `desktop-buffer-handlers' functions.")
208 216
217(defcustom desktop-buffer-misc-functions
218 '(desktop-buffer-info-misc-data
219 desktop-buffer-dired-misc-data)
220 "*Functions used to determine auxiliary information for a buffer.
221These functions are called in order, with no arguments. If a function
222returns non-nil, its value is saved along with the desktop buffer for
223which it was called; no further functions will be called.
224
225Later, when desktop.el restores the buffers it has saved, each of the
226`desktop-buffer-handlers' functions will have access to a buffer local
227variable, named `desktop-buffer-misc', whose value is what the
228\"misc\" function returned previously."
229 :type '(repeat function)
230 :group 'desktop)
231
209(defcustom desktop-buffer-handlers 232(defcustom desktop-buffer-handlers
210 '(desktop-buffer-dired 233 '(desktop-buffer-dired
211 desktop-buffer-rmail 234 desktop-buffer-rmail
@@ -221,6 +244,8 @@ If the function returns t then the buffer is considered created."
221 :type '(repeat function) 244 :type '(repeat function)
222 :group 'desktop) 245 :group 'desktop)
223 246
247(put 'desktop-buffer-handlers 'risky-local-variable t)
248
224(defvar desktop-create-buffer-form "(desktop-create-buffer 205" 249(defvar desktop-create-buffer-form "(desktop-create-buffer 205"
225 "Opening of form for creation of new buffers.") 250 "Opening of form for creation of new buffers.")
226 251
@@ -442,7 +467,7 @@ MODE is the major mode."
442 (not (string-match desktop-files-not-to-save 467 (not (string-match desktop-files-not-to-save
443 default-directory)))) 468 default-directory))))
444 (and (null filename) 469 (and (null filename)
445 (memq mode '(Info-mode rmail-mode))))))) 470 (memq mode desktop-buffer-modes-to-save))))))
446;; ---------------------------------------------------------------------------- 471;; ----------------------------------------------------------------------------
447(defun desktop-save (dirname) 472(defun desktop-save (dirname)
448 "Save the Desktop file. Parameter DIRNAME specifies where to save desktop." 473 "Save the Desktop file. Parameter DIRNAME specifies where to save desktop."
@@ -477,17 +502,8 @@ MODE is the major mode."
477 (point) 502 (point)
478 (list (mark t) mark-active) 503 (list (mark t) mark-active)
479 buffer-read-only 504 buffer-read-only
480 (cond ((eq major-mode 'Info-mode) 505 (run-hook-with-args-until-success
481 (list Info-current-file 506 'desktop-buffer-misc-functions)
482 Info-current-node))
483 ((eq major-mode 'dired-mode)
484 (cons
485 (expand-file-name dired-directory)
486 (cdr
487 (nreverse
488 (mapcar
489 (function car)
490 dired-subdir-alist))))))
491 (let ((locals desktop-locals-to-save) 507 (let ((locals desktop-locals-to-save)
492 (loclist (buffer-local-variables)) 508 (loclist (buffer-local-variables))
493 (ll)) 509 (ll))
@@ -578,12 +594,30 @@ to provide correct modes for autoloaded files."
578;; ---------------------------------------------------------------------------- 594;; ----------------------------------------------------------------------------
579;; Note: the following functions use the dynamic variable binding in Lisp. 595;; Note: the following functions use the dynamic variable binding in Lisp.
580;; 596;;
597(defun desktop-buffer-info-misc-data ()
598 (if (eq major-mode 'Info-mode)
599 (list Info-current-file
600 Info-current-node)))
601
602(defun desktop-buffer-dired-misc-data ()
603 (if (eq major-mode 'dired-mode)
604 (cons
605 (expand-file-name dired-directory)
606 (cdr
607 (nreverse
608 (mapcar
609 (function car)
610 dired-subdir-alist))))))
611
581(defun desktop-buffer-info () "Load an info file." 612(defun desktop-buffer-info () "Load an info file."
582 (if (eq 'Info-mode desktop-buffer-major-mode) 613 (if (eq 'Info-mode desktop-buffer-major-mode)
583 (progn 614 (progn
584 (require 'info) 615 (let ((first (nth 0 desktop-buffer-misc))
585 (Info-find-node (nth 0 desktop-buffer-misc) (nth 1 desktop-buffer-misc)) 616 (second (nth 1 desktop-buffer-misc)))
586 (current-buffer)))) 617 (when (and first second)
618 (require 'info)
619 (Info-find-node first second)
620 (current-buffer))))))
587;; ---------------------------------------------------------------------------- 621;; ----------------------------------------------------------------------------
588(defun desktop-buffer-rmail () "Load an RMAIL file." 622(defun desktop-buffer-rmail () "Load an RMAIL file."
589 (if (eq 'rmail-mode desktop-buffer-major-mode) 623 (if (eq 'rmail-mode desktop-buffer-major-mode)
@@ -649,7 +683,9 @@ to provide correct modes for autoloaded files."
649 (cond ((equal '(t) mim) (auto-fill-mode 1)) ; backwards compatible 683 (cond ((equal '(t) mim) (auto-fill-mode 1)) ; backwards compatible
650 ((equal '(nil) mim) (auto-fill-mode 0)) 684 ((equal '(nil) mim) (auto-fill-mode 0))
651 (t (mapcar #'(lambda (minor-mode) 685 (t (mapcar #'(lambda (minor-mode)
652 (when minor-mode (funcall minor-mode 1))) 686 (unless (or (eq minor-mode t) (eq minor-mode nil))
687 (if (and minor-mode (fboundp minor-mode))
688 (funcall minor-mode 1))))
653 mim))) 689 mim)))
654 (goto-char pt) 690 (goto-char pt)
655 (if (consp mk) 691 (if (consp mk)