annotate lisp/loadhist.el @ 23792:ec06ad058029

(vc-dired-window-configuration, vc-ediff-windows, vc-ediff-result, vc-dired-switches, vc-dired-terse-mode): Added defvars to suppress compilation warnings.
author André Spiegel <spiegel@gnu.org>
date Wed, 02 Dec 1998 13:34:59 +0000
parents 49a68c55c3ac
children dc812cd8bd1b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2543
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1 ;;; loadhist.el --- lisp functions for working with feature groups
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 12751
diff changeset
2
22459
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
3 ;; Copyright (C) 1995, 1998 Free Software Foundation, Inc.
2543
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5 ;; Author: Eric S. Raymond <esr@snark.thyrsus.com>
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 ;; Version: 1.0
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 ;; Keywords: internal
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8
11289
b8ba33ac2f22 Comment changes.
Karl Heuer <kwzh@gnu.org>
parents: 10498
diff changeset
9 ;; This file is part of GNU Emacs.
b8ba33ac2f22 Comment changes.
Karl Heuer <kwzh@gnu.org>
parents: 10498
diff changeset
10
b8ba33ac2f22 Comment changes.
Karl Heuer <kwzh@gnu.org>
parents: 10498
diff changeset
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
b8ba33ac2f22 Comment changes.
Karl Heuer <kwzh@gnu.org>
parents: 10498
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
b8ba33ac2f22 Comment changes.
Karl Heuer <kwzh@gnu.org>
parents: 10498
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
b8ba33ac2f22 Comment changes.
Karl Heuer <kwzh@gnu.org>
parents: 10498
diff changeset
14 ;; any later version.
b8ba33ac2f22 Comment changes.
Karl Heuer <kwzh@gnu.org>
parents: 10498
diff changeset
15
b8ba33ac2f22 Comment changes.
Karl Heuer <kwzh@gnu.org>
parents: 10498
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
b8ba33ac2f22 Comment changes.
Karl Heuer <kwzh@gnu.org>
parents: 10498
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
b8ba33ac2f22 Comment changes.
Karl Heuer <kwzh@gnu.org>
parents: 10498
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b8ba33ac2f22 Comment changes.
Karl Heuer <kwzh@gnu.org>
parents: 10498
diff changeset
19 ;; GNU General Public License for more details.
b8ba33ac2f22 Comment changes.
Karl Heuer <kwzh@gnu.org>
parents: 10498
diff changeset
20
b8ba33ac2f22 Comment changes.
Karl Heuer <kwzh@gnu.org>
parents: 10498
diff changeset
21 ;; You should have received a copy of the GNU General Public License
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 12751
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 12751
diff changeset
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 12751
diff changeset
24 ;; Boston, MA 02111-1307, USA.
11289
b8ba33ac2f22 Comment changes.
Karl Heuer <kwzh@gnu.org>
parents: 10498
diff changeset
25
2543
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26 ;;; Commentary:
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28 ;; These functions exploit the load-history system variable.
22459
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
29 ;; Entry points include `unload-feature', `symbol-file', and
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
30 ;; `feature-file', documented in the Emacs Lisp manual.
2543
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32 ;;; Code:
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33
23285
76798d29cb2b (load-history-loaded): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 22459
diff changeset
34 (defvar load-history-loaded nil
23574
c8ba21ef69c4 (symbol-file): Load fns-*.el from exec-directory
Andreas Schwab <schwab@suse.de>
parents: 23285
diff changeset
35 "Non-nil means we have loaded the file `fns-VERSION.el' in `exec-directory'.
23285
76798d29cb2b (load-history-loaded): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 22459
diff changeset
36 That file records the part of `load-history' for preloaded files,
76798d29cb2b (load-history-loaded): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 22459
diff changeset
37 which is cleared out before dumping to make Emacs smaller.")
76798d29cb2b (load-history-loaded): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 22459
diff changeset
38
2543
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 (defun symbol-file (sym)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 "Return the input source from which SYM was loaded.
23780
49a68c55c3ac (symbol-file): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 23704
diff changeset
41 The value is normally a string that was passed to `load':
49a68c55c3ac (symbol-file): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 23704
diff changeset
42 either an absolute file name, or a library name
49a68c55c3ac (symbol-file): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 23704
diff changeset
43 \(with no directory name and no `.el' or `.elc' at the end).
49a68c55c3ac (symbol-file): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 23704
diff changeset
44 It can also be nil, if the definition is not associated with any file."
23285
76798d29cb2b (load-history-loaded): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 22459
diff changeset
45 (unless load-history-loaded
23664
bf72d6351f29 (symbol-file): Run fns-VERSION.el through
Eli Zaretskii <eliz@gnu.org>
parents: 23574
diff changeset
46 (load (expand-file-name
bf72d6351f29 (symbol-file): Run fns-VERSION.el through
Eli Zaretskii <eliz@gnu.org>
parents: 23574
diff changeset
47 ;; fns-XX.YY.ZZ.el does not work on DOS filesystem.
23704
2069e879bec5 (symbol-file): For ms-dos, use fns.el without the
Eli Zaretskii <eliz@gnu.org>
parents: 23664
diff changeset
48 (if (eq system-type 'ms-dos)
2069e879bec5 (symbol-file): For ms-dos, use fns.el without the
Eli Zaretskii <eliz@gnu.org>
parents: 23664
diff changeset
49 "fns.el"
2069e879bec5 (symbol-file): For ms-dos, use fns.el without the
Eli Zaretskii <eliz@gnu.org>
parents: 23664
diff changeset
50 (format "fns-%s.el" emacs-version))
23664
bf72d6351f29 (symbol-file): Run fns-VERSION.el through
Eli Zaretskii <eliz@gnu.org>
parents: 23574
diff changeset
51 exec-directory)
bf72d6351f29 (symbol-file): Run fns-VERSION.el through
Eli Zaretskii <eliz@gnu.org>
parents: 23574
diff changeset
52 ;; The file name fns-%s.el already has a .el extension.
bf72d6351f29 (symbol-file): Run fns-VERSION.el through
Eli Zaretskii <eliz@gnu.org>
parents: 23574
diff changeset
53 nil nil t)
23285
76798d29cb2b (load-history-loaded): New variable.
Karl Heuer <kwzh@gnu.org>
parents: 22459
diff changeset
54 (setq load-history-loaded t))
2543
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 (catch 'foundit
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 (mapcar
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 (function (lambda (x) (if (memq sym (cdr x)) (throw 'foundit (car x)))))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 load-history)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 nil))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 (defun feature-symbols (feature)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 "Return the file and list of symbols associated with a given FEATURE."
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 (catch 'foundit
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 (mapcar
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 (function (lambda (x)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 (if (member (cons 'provide feature) (cdr x))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 (throw 'foundit x))))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 load-history)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 nil))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 (defun feature-file (feature)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 "Return the file name from which a given FEATURE was loaded.
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 Actually, return the load argument, if any; this is sometimes the name of a
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 Lisp file without an extension. If the feature came from an eval-buffer on
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 a buffer with no associated file, or an eval-region, return nil."
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 (if (not (featurep feature))
12751
f442c14a79c4 (unload-feature): Delete the file's load-history element.
Richard M. Stallman <rms@gnu.org>
parents: 11844
diff changeset
77 (error "%s is not a currently loaded feature" (symbol-name feature))
2543
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 (car (feature-symbols feature))))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 (defun file-provides (file)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 "Return the list of features provided by FILE."
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 (let ((symbols (cdr (assoc file load-history))) (provides nil))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 (mapcar
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 (function (lambda (x)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 (if (and (consp x) (eq (car x) 'provide))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 (setq provides (cons (cdr x) provides)))))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 symbols)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 provides
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 ))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 (defun file-requires (file)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 "Return the list of features required by FILE."
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 (let ((symbols (cdr (assoc file load-history))) (requires nil))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 (mapcar
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95 (function (lambda (x)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 (if (and (consp x) (eq (car x) 'require))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 (setq requires (cons (cdr x) requires)))))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 symbols)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 requires
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 ))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101
12751
f442c14a79c4 (unload-feature): Delete the file's load-history element.
Richard M. Stallman <rms@gnu.org>
parents: 11844
diff changeset
102 (defun file-set-intersect (p q)
2543
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 ;; Return the set intersection of two lists
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 (let ((ret nil))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 (mapcar
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 (function (lambda (x) (if (memq x q) (setq ret (cons x ret)))))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 p)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 ret
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 ))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 (defun file-dependents (file)
10498
8fb25f247533 (unload-feature): Don't care if FILE is a dependency of itself.
Richard M. Stallman <rms@gnu.org>
parents: 8108
diff changeset
112 "Return the list of loaded libraries that depend on FILE.
8fb25f247533 (unload-feature): Don't care if FILE is a dependency of itself.
Richard M. Stallman <rms@gnu.org>
parents: 8108
diff changeset
113 This can include FILE itself."
2543
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 (let ((provides (file-provides file)) (dependents nil))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 (mapcar
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 (function (lambda (x)
12751
f442c14a79c4 (unload-feature): Delete the file's load-history element.
Richard M. Stallman <rms@gnu.org>
parents: 11844
diff changeset
117 (if (file-set-intersect provides (file-requires (car x)))
2543
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 (setq dependents (cons (car x) dependents)))))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 load-history)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 dependents
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 ))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122
16173
9ba176963a26 (read-feature): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
123 (defun read-feature (prompt)
22459
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
124 "Read a feature name \(string\) from the minibuffer.
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
125 Prompt with PROMPT and completing from `features', and
16173
9ba176963a26 (read-feature): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
126 return the feature \(symbol\)."
9ba176963a26 (read-feature): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
127 (intern (completing-read prompt
9ba176963a26 (read-feature): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
128 (mapcar (function (lambda (feature)
9ba176963a26 (read-feature): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
129 (list (symbol-name feature))))
9ba176963a26 (read-feature): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
130 features)
9ba176963a26 (read-feature): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
131 nil t)))
9ba176963a26 (read-feature): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
132
22459
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
133 (defvar loadhist-hook-functions
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
134 '(after-change-function after-change-functions
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
135 after-insert-file-functions auto-fill-function before-change-function
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
136 before-change-functions blink-paren-function
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
137 buffer-access-fontify-functions command-line-functions
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
138 comment-indent-function kill-buffer-query-functions
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
139 kill-emacs-query-functions lisp-indent-function
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
140 redisplay-end-trigger-functions temp-buffer-show-function
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
141 window-scroll-functions window-size-change-functions
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
142 write-region-annotate-functions)
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
143 "A list of special hooks from the `Standard Hooks' node of the Lisp manual.
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
144
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
145 These are symbols with hook-type values whose names don't end in
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
146 `-hook' or `-hooks', from which `unload-feature' tries to remove
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
147 pertinent symbols.")
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
148
2543
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 ;;;###autoload
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 (defun unload-feature (feature &optional force)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 "Unload the library that provided FEATURE, restoring all its autoloads.
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152 If the feature is required by any other loaded code, and optional FORCE
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153 is nil, raise an error."
16173
9ba176963a26 (read-feature): New function.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
154 (interactive (list (read-feature "Feature: ")))
2543
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155 (if (not (featurep feature))
12751
f442c14a79c4 (unload-feature): Delete the file's load-history element.
Richard M. Stallman <rms@gnu.org>
parents: 11844
diff changeset
156 (error "%s is not a currently loaded feature" (symbol-name feature)))
2543
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 (if (not force)
10498
8fb25f247533 (unload-feature): Don't care if FILE is a dependency of itself.
Richard M. Stallman <rms@gnu.org>
parents: 8108
diff changeset
158 (let* ((file (feature-file feature))
8fb25f247533 (unload-feature): Don't care if FILE is a dependency of itself.
Richard M. Stallman <rms@gnu.org>
parents: 8108
diff changeset
159 (dependents (delete file (copy-sequence (file-dependents file)))))
2543
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160 (if dependents
12751
f442c14a79c4 (unload-feature): Delete the file's load-history element.
Richard M. Stallman <rms@gnu.org>
parents: 11844
diff changeset
161 (error "Loaded libraries %s depend on %s"
22459
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
162 (prin1-to-string dependents) file))))
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
163 (let* ((flist (feature-symbols feature))
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
164 (file (car flist))
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
165 (unload-hook (intern-soft (concat (symbol-name feature)
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
166 "-unload-hook"))))
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
167 ;; Try to avoid losing badly when hooks installed in critical
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
168 ;; places go away. (Some packages install things on
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
169 ;; `kill-buffer-hook', `activate-menubar-hook' and the like.)
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
170 ;; First off, provide a clean way for package `foo' to arrange
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
171 ;; this by defining `foo-unload-hook'.
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
172 (if unload-hook
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
173 (run-hooks unload-hook)
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
174 ;; Otherwise, do our best. Look through the obarray for symbols
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
175 ;; which seem to be hook variables or special hook functions and
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
176 ;; remove anything from them which matches the feature-symbols
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
177 ;; about to get zapped. Obviously this won't get anonymous
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
178 ;; functions which the package might just have installed, and
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
179 ;; there might be other important state, but this tactic
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
180 ;; normally works.
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
181 (mapatoms
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
182 (lambda (x)
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
183 (if (or (and (boundp x) ; Random hooks.
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
184 (consp (symbol-value x))
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
185 (string-match "-hooks?\\'" (symbol-name x)))
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
186 (and (fboundp x) ; Known abnormal hooks etc.
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
187 (memq x loadhist-hook-functions)))
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
188 (mapcar (lambda (y) (remove-hook x y))
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
189 (cdr flist))))))
2543
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190 (mapcar
22459
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
191 (lambda (x)
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
192 (cond ((stringp x) nil)
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
193 ((consp x)
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
194 ;; Remove any feature names that this file provided.
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
195 (if (eq (car x) 'provide)
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
196 (setq features (delq (cdr x) features))))
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
197 ((boundp x) (makunbound x))
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
198 ((fboundp x)
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
199 (fmakunbound x)
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
200 (let ((aload (get x 'autoload)))
bc88a299d2fc (read-feature): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 16173
diff changeset
201 (if aload (fset x (cons 'autoload aload)))))))
12751
f442c14a79c4 (unload-feature): Delete the file's load-history element.
Richard M. Stallman <rms@gnu.org>
parents: 11844
diff changeset
202 (cdr flist))
f442c14a79c4 (unload-feature): Delete the file's load-history element.
Richard M. Stallman <rms@gnu.org>
parents: 11844
diff changeset
203 ;; Delete the load-history element for this file.
f442c14a79c4 (unload-feature): Delete the file's load-history element.
Richard M. Stallman <rms@gnu.org>
parents: 11844
diff changeset
204 (let ((elt (assoc file load-history)))
f442c14a79c4 (unload-feature): Delete the file's load-history element.
Richard M. Stallman <rms@gnu.org>
parents: 11844
diff changeset
205 (setq load-history (delq elt load-history)))))
2543
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
206
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207 (provide 'loadhist)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209 ;;; loadhist.el ends here