aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Love2000-05-22 19:35:34 +0000
committerDave Love2000-05-22 19:35:34 +0000
commit53c1fa0f50c9468f4696fe1dc27b510a8d0a704c (patch)
tree95c0d4738f8f74651d4bffc1a0ac14720d5c5d09
parent74654c6507a28f2eb1523423c9fe87d13acf04f2 (diff)
downloademacs-53c1fa0f50c9468f4696fe1dc27b510a8d0a704c.tar.gz
emacs-53c1fa0f50c9468f4696fe1dc27b510a8d0a704c.zip
(feature-symbols, file-provides, file-requires): Use mapc.
(feature-file): Avoid calling symbol-name. Doc fix. (file-set-intersect, file-dependents): Use dolist, not mapcar. (loadhist-hook-functions): Add mouse-position-function. (unload-feature): Change uses of mapcar.
-rw-r--r--lisp/loadhist.el90
1 files changed, 42 insertions, 48 deletions
diff --git a/lisp/loadhist.el b/lisp/loadhist.el
index 47863f06d0a..b6721caf074 100644
--- a/lisp/loadhist.el
+++ b/lisp/loadhist.el
@@ -1,9 +1,9 @@
1;;; loadhist.el --- lisp functions for working with feature groups 1;;; loadhist.el --- lisp functions for working with feature groups
2 2
3;; Copyright (C) 1995, 1998 Free Software Foundation, Inc. 3;; Copyright (C) 1995, 1998, 2000 Free Software Foundation, Inc.
4 4
5;; Author: Eric S. Raymond <esr@snark.thyrsus.com> 5;; Author: Eric S. Raymond <esr@snark.thyrsus.com>
6;; Version: 1.0 6;; Maintainer: FSF
7;; Keywords: internal 7;; Keywords: internal
8 8
9;; This file is part of GNU Emacs. 9;; This file is part of GNU Emacs.
@@ -34,72 +34,65 @@
34(defun feature-symbols (feature) 34(defun feature-symbols (feature)
35 "Return the file and list of symbols associated with a given FEATURE." 35 "Return the file and list of symbols associated with a given FEATURE."
36 (catch 'foundit 36 (catch 'foundit
37 (mapcar 37 (mapc (lambda (x)
38 (function (lambda (x) 38 (if (member (cons 'provide feature) (cdr x))
39 (if (member (cons 'provide feature) (cdr x)) 39 (throw 'foundit x)))
40 (throw 'foundit x)))) 40 load-history)
41 load-history)
42 nil)) 41 nil))
43 42
44(defun feature-file (feature) 43(defun feature-file (feature)
45 "Return the file name from which a given FEATURE was loaded. 44 "Return the file name from which a given FEATURE was loaded.
46Actually, return the load argument, if any; this is sometimes the name of a 45Actually, return the load argument, if any; this is sometimes the name of a
47Lisp file without an extension. If the feature came from an eval-buffer on 46Lisp file without an extension. If the feature came from an `eval-buffer' on
48a buffer with no associated file, or an eval-region, return nil." 47a buffer with no associated file, or an `eval-region', return nil."
49 (if (not (featurep feature)) 48 (if (not (featurep feature))
50 (error "%s is not a currently loaded feature" (symbol-name feature)) 49 (error "%S is not a currently loaded feature" feature)
51 (car (feature-symbols feature)))) 50 (car (feature-symbols feature))))
52 51
53(defun file-provides (file) 52(defun file-provides (file)
54 "Return the list of features provided by FILE." 53 "Return the list of features provided by FILE."
55 (let ((symbols (cdr (assoc file load-history))) (provides nil)) 54 (let ((symbols (cdr (assoc file load-history)))
56 (mapcar 55 provides)
57 (function (lambda (x) 56 (mapc (lambda (x)
58 (if (and (consp x) (eq (car x) 'provide)) 57 (if (and (consp x) (eq (car x) 'provide))
59 (setq provides (cons (cdr x) provides))))) 58 (setq provides (cons (cdr x) provides))))
60 symbols) 59 symbols)
61 provides 60 provides))
62 ))
63 61
64(defun file-requires (file) 62(defun file-requires (file)
65 "Return the list of features required by FILE." 63 "Return the list of features required by FILE."
66 (let ((symbols (cdr (assoc file load-history))) (requires nil)) 64 (let ((symbols (cdr (assoc file load-history)))
67 (mapcar 65 requires)
68 (function (lambda (x) 66 (mapc (lambda (x)
69 (if (and (consp x) (eq (car x) 'require)) 67 (if (and (consp x) (eq (car x) 'require))
70 (setq requires (cons (cdr x) requires))))) 68 (setq requires (cons (cdr x) requires))))
71 symbols) 69 symbols)
72 requires 70 requires))
73 )) 71
74 72(defsubst file-set-intersect (p q)
75(defun file-set-intersect (p q) 73 "Return the set intersection of two lists."
76 ;; Return the set intersection of two lists
77 (let ((ret nil)) 74 (let ((ret nil))
78 (mapcar 75 (dolist (x p ret)
79 (function (lambda (x) (if (memq x q) (setq ret (cons x ret))))) 76 (if (memq x q) (setq ret (cons x ret))))
80 p) 77 ret))
81 ret
82 ))
83 78
84(defun file-dependents (file) 79(defun file-dependents (file)
85 "Return the list of loaded libraries that depend on FILE. 80 "Return the list of loaded libraries that depend on FILE.
86This can include FILE itself." 81This can include FILE itself."
87 (let ((provides (file-provides file)) (dependents nil)) 82 (let ((provides (file-provides file))
88 (mapcar 83 (dependents nil))
89 (function (lambda (x) 84 (dolist (x load-history dependents)
90 (if (file-set-intersect provides (file-requires (car x))) 85 (if (file-set-intersect provides (file-requires (car x)))
91 (setq dependents (cons (car x) dependents))))) 86 (setq dependents (cons (car x) dependents))))
92 load-history) 87 dependents))
93 dependents
94 ))
95 88
96(defun read-feature (prompt) 89(defun read-feature (prompt)
97 "Read a feature name \(string\) from the minibuffer. 90 "Read a feature name \(string\) from the minibuffer.
98Prompt with PROMPT and completing from `features', and 91Prompt with PROMPT and completing from `features', and
99return the feature \(symbol\)." 92return the feature \(symbol\)."
100 (intern (completing-read prompt 93 (intern (completing-read prompt
101 (mapcar (function (lambda (feature) 94 (mapcar (lambda (feature)
102 (list (symbol-name feature)))) 95 (list (symbol-name feature)))
103 features) 96 features)
104 nil t))) 97 nil t)))
105 98
@@ -110,6 +103,7 @@ before-change-functions blink-paren-function
110buffer-access-fontify-functions command-line-functions 103buffer-access-fontify-functions command-line-functions
111comment-indent-function kill-buffer-query-functions 104comment-indent-function kill-buffer-query-functions
112kill-emacs-query-functions lisp-indent-function 105kill-emacs-query-functions lisp-indent-function
106mouse-position-function
113redisplay-end-trigger-functions temp-buffer-show-function 107redisplay-end-trigger-functions temp-buffer-show-function
114window-scroll-functions window-size-change-functions 108window-scroll-functions window-size-change-functions
115write-region-annotate-functions) 109write-region-annotate-functions)
@@ -158,10 +152,10 @@ is nil, raise an error."
158 (string-match "-hooks?\\'" (symbol-name x))) 152 (string-match "-hooks?\\'" (symbol-name x)))
159 (and (fboundp x) ; Known abnormal hooks etc. 153 (and (fboundp x) ; Known abnormal hooks etc.
160 (memq x loadhist-hook-functions))) 154 (memq x loadhist-hook-functions)))
161 (mapcar (lambda (y) (remove-hook x y)) 155 (dolist (y (cdr flist))
162 (cdr flist)))))) 156 (remove-hook x y))))))
163 (mapcar 157 (mapc
164 (lambda (x) 158 (lambda (x)
165 (cond ((stringp x) nil) 159 (cond ((stringp x) nil)
166 ((consp x) 160 ((consp x)
167 ;; Remove any feature names that this file provided. 161 ;; Remove any feature names that this file provided.