annotate lisp/loadhist.el @ 11436:9829d3c035f2

(x_term_init): Call XtSetLanguageProc only if HAVE_X11XTR6. (XTread_socket): Pass dpyinfo to popup_get_selection. (XTread_socket): For ConfigureNotify, combine the USE_X_TOOLKIT and non-toolkit cases, which provides some things that were missing in the former.
author Richard M. Stallman <rms@gnu.org>
date Fri, 14 Apr 1995 03:58:51 +0000
parents b8ba33ac2f22
children cacb7820d1c7
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
11289
b8ba33ac2f22 Comment changes.
Karl Heuer <kwzh@gnu.org>
parents: 10498
diff changeset
2 ;;; Copyright (C) 1995 Free Software Foundation, Inc.
2543
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4 ;; Author: Eric S. Raymond <esr@snark.thyrsus.com>
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5 ;; Version: 1.0
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 ;; Keywords: internal
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7
11289
b8ba33ac2f22 Comment changes.
Karl Heuer <kwzh@gnu.org>
parents: 10498
diff changeset
8 ;; This file is part of GNU Emacs.
b8ba33ac2f22 Comment changes.
Karl Heuer <kwzh@gnu.org>
parents: 10498
diff changeset
9
b8ba33ac2f22 Comment changes.
Karl Heuer <kwzh@gnu.org>
parents: 10498
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
b8ba33ac2f22 Comment changes.
Karl Heuer <kwzh@gnu.org>
parents: 10498
diff changeset
11 ;; 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
12 ;; the Free Software Foundation; either version 2, or (at your option)
b8ba33ac2f22 Comment changes.
Karl Heuer <kwzh@gnu.org>
parents: 10498
diff changeset
13 ;; any later version.
b8ba33ac2f22 Comment changes.
Karl Heuer <kwzh@gnu.org>
parents: 10498
diff changeset
14
b8ba33ac2f22 Comment changes.
Karl Heuer <kwzh@gnu.org>
parents: 10498
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
b8ba33ac2f22 Comment changes.
Karl Heuer <kwzh@gnu.org>
parents: 10498
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
b8ba33ac2f22 Comment changes.
Karl Heuer <kwzh@gnu.org>
parents: 10498
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b8ba33ac2f22 Comment changes.
Karl Heuer <kwzh@gnu.org>
parents: 10498
diff changeset
18 ;; GNU General Public License for more details.
b8ba33ac2f22 Comment changes.
Karl Heuer <kwzh@gnu.org>
parents: 10498
diff changeset
19
b8ba33ac2f22 Comment changes.
Karl Heuer <kwzh@gnu.org>
parents: 10498
diff changeset
20 ;; You should have received a copy of the GNU General Public License
b8ba33ac2f22 Comment changes.
Karl Heuer <kwzh@gnu.org>
parents: 10498
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to
b8ba33ac2f22 Comment changes.
Karl Heuer <kwzh@gnu.org>
parents: 10498
diff changeset
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
b8ba33ac2f22 Comment changes.
Karl Heuer <kwzh@gnu.org>
parents: 10498
diff changeset
23
2543
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 ;;; Commentary:
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26 ;; These functions exploit the load-history system variable.
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 ;; Entry points include `unload-feature', `symbol-file', and `feature-file'.
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 ;;; Code:
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 (defun symbol-file (sym)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32 "Return the input source from which SYM was loaded.
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 This is a file name, or nil if the source was a buffer with no associated file."
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 (catch 'foundit
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 (mapcar
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 (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
37 load-history)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 nil))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 (defun feature-symbols (feature)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 "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
42 (catch 'foundit
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 (mapcar
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 (function (lambda (x)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 (if (member (cons 'provide feature) (cdr x))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 (throw 'foundit x))))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 load-history)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 nil))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 (defun feature-file (feature)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 "Return the file name from which a given FEATURE was loaded.
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 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
53 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
54 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
55 (if (not (featurep feature))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 (error "%s is not a currently loaded feature." (symbol-name feature))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 (car (feature-symbols feature))))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 (defun file-provides (file)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 "Return the list of features provided by FILE."
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 (let ((symbols (cdr (assoc file load-history))) (provides nil))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 (mapcar
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 (function (lambda (x)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 (if (and (consp x) (eq (car x) 'provide))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 (setq provides (cons (cdr x) provides)))))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 symbols)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 provides
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 ))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 (defun file-requires (file)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 "Return the list of features required by FILE."
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 (let ((symbols (cdr (assoc file load-history))) (requires nil))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 (mapcar
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 (function (lambda (x)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 (if (and (consp x) (eq (car x) 'require))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 (setq requires (cons (cdr x) requires)))))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 symbols)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 requires
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
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 (defun set-intersect (p q)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 ;; Return the set intersection of two lists
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 (let ((ret nil))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 (mapcar
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 (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
86 p)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 ret
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 ))
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 (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
91 "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
92 This can include FILE itself."
2543
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 (let ((provides (file-provides file)) (dependents 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 (set-intersect provides (file-requires (car x)))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 (setq dependents (cons (car x) dependents)))))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 load-history)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 dependents
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
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 ;;;###autoload
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 (defun unload-feature (feature &optional force)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 "Unload the library that provided FEATURE, restoring all its autoloads.
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 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
106 is nil, raise an error."
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 (interactive "SFeature: ")
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 (if (not (featurep feature))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 (error "%s is not a currently loaded feature." (symbol-name feature)))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 (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
111 (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
112 (dependents (delete file (copy-sequence (file-dependents file)))))
2543
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 (if dependents
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 (error "Loaded libraries %s depend on %s."
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 (prin1-to-string dependents) file)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 )))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 (let* ((flist (feature-symbols feature)) (file (car flist)))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 (mapcar
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 (function (lambda (x)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 (cond ((stringp x) nil)
5336
4521917cdd6e (unload-feature): Ignore conses in the feature-symbols.
Richard M. Stallman <rms@gnu.org>
parents: 2543
diff changeset
121 ((consp x) nil)
2543
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 ((boundp x) (makunbound x))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 ((fboundp x)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 (fmakunbound x)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 (let ((aload (get x 'autoload)))
8108
7b9d245c5978 (unload-feature): The autoload property does not
Richard M. Stallman <rms@gnu.org>
parents: 5336
diff changeset
126 (if aload (fset x (cons 'autoload aload)))))))
2543
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 )
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 (cdr flist))))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 (provide 'loadhist)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 ;;; loadhist.el ends here