annotate lisp/loadhist.el @ 9653:cfc5e15e0baf

(x_sync): Take frame ptr as arg. (check_x_display_info): New function. (Fx_create_frame): Use it. (x_screen_planes): New function. (EMACS_CLASS): Macro moved to xterm.h. (Qdisplay): New variable. (syms_of_xfns): Set it up. (Fx_create_frame): Handle display parameter which says where to get the FRAME_X_DISPLAY_INFO. (x_display_info_for_name): New function. (select_visual): New arg dpy. (Fx_open_connection): Get dpyinfo from x_term_init. Don't set up atoms, xrdb here. Pass name as Lisp_Object. (the_x_screen): Variable moved to xterm.c. (syms_of_xfns): Don't staticpro it here. (xrdb): Variable deleted. (Fx_get_resource): Use selected_frame's xrdb. (x_get_resource_string): Likewise. (Fx_open_connection): Store the atoms in x_display_info. (hack_wm_protocols): New arg f. Get atoms from x_display_info. (x_window): Get atoms from x_display_info. (Vmouse_depressed, mouse_buffer_offset): Variables deleted. (syms_of_xfns): Delete Lisp variables too. (Fx_synchronize): Take frame as arg. (Fx_close_current_connection): Take frame as arg. Error is not fatal. (mouse_timestamp): Variable deleted. (screen_visual, x_screen_planes): Variables deleted. (x_screen, x_screen_height, x_screen_width): Variables deleted. (Fx_open_connection): Don't set them here. Put that info in the x_display_info structure. (x_window): Get the visual from x_display_info structure. (x_decode_color): Use n_planes from x_display_info structure. Use FRAME_X_DISPLAY instead of x_current_display and XDISPLAY. (x_in_use): New variable, (check_x, using_x_p): Test x_in_use. (Fx_open_connection): Set x_in_use. (check_x_frame): New function. (defined_color): New arg f specifies frame. Callers changed. (x_decode_color): New arg f. All callers changed. (Fx_color_values, Fx_color_defined_p): New arg FRAME. Use check_x_frame. (Fx_list_fonts): Use check_x_frame.
author Richard M. Stallman <rms@gnu.org>
date Sat, 22 Oct 1994 04:27:25 +0000
parents 7b9d245c5978
children 8fb25f247533
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
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3 ;; Author: Eric S. Raymond <esr@snark.thyrsus.com>
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4 ;; Version: 1.0
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5 ;; Keywords: internal
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 ;;; Commentary:
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9 ;; These functions exploit the load-history system variable.
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10 ;; Entry points include `unload-feature', `symbol-file', and `feature-file'.
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 ;;; Code:
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 (defun symbol-file (sym)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 "Return the input source from which SYM was loaded.
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 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
17 (catch 'foundit
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 (mapcar
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 (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
20 load-history)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 nil))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 (defun feature-symbols (feature)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 "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
25 (catch 'foundit
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26 (mapcar
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 (function (lambda (x)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28 (if (member (cons 'provide feature) (cdr x))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 (throw 'foundit x))))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 load-history)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 nil))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 (defun feature-file (feature)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 "Return the file name from which a given FEATURE was loaded.
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 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
36 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
37 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
38 (if (not (featurep feature))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 (error "%s is not a currently loaded feature." (symbol-name feature))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 (car (feature-symbols feature))))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 (defun file-provides (file)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 "Return the list of features provided by FILE."
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 (let ((symbols (cdr (assoc file load-history))) (provides nil))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 (mapcar
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 (function (lambda (x)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 (if (and (consp x) (eq (car x) 'provide))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 (setq provides (cons (cdr x) provides)))))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49 symbols)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 provides
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 ))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 (defun file-requires (file)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 "Return the list of features required by FILE."
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 (let ((symbols (cdr (assoc file load-history))) (requires nil))
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)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 (if (and (consp x) (eq (car x) 'require))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 (setq requires (cons (cdr x) requires)))))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 symbols)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 requires
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 ))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 (defun set-intersect (p q)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 ;; Return the set intersection of two lists
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 (let ((ret nil))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 (mapcar
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 (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
69 p)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 ret
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 ))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 (defun file-dependents (file)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 ;; Return the list of loaded libraries that depend on FILE.
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 (let ((provides (file-provides file)) (dependents nil))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 (mapcar
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 (function (lambda (x)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 (if (set-intersect provides (file-requires (car x)))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 (setq dependents (cons (car x) dependents)))))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 load-history)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 dependents
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 ))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 ;;;###autoload
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 (defun unload-feature (feature &optional force)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 "Unload the library that provided FEATURE, restoring all its autoloads.
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 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
88 is nil, raise an error."
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 (interactive "SFeature: ")
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 (if (not (featurep feature))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 (error "%s is not a currently loaded feature." (symbol-name feature)))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 (if (not force)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 (let* ((file (feature-file feature)) (dependents (file-dependents file)))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 (if dependents
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95 (error "Loaded libraries %s depend on %s."
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 (prin1-to-string dependents) file)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 )))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 (let* ((flist (feature-symbols feature)) (file (car flist)))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 (mapcar
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 (function (lambda (x)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101 (cond ((stringp x) nil)
5336
4521917cdd6e (unload-feature): Ignore conses in the feature-symbols.
Richard M. Stallman <rms@gnu.org>
parents: 2543
diff changeset
102 ((consp x) nil)
2543
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 ((boundp x) (makunbound x))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 ((fboundp x)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 (fmakunbound x)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 (let ((aload (get x 'autoload)))
8108
7b9d245c5978 (unload-feature): The autoload property does not
Richard M. Stallman <rms@gnu.org>
parents: 5336
diff changeset
107 (if aload (fset x (cons 'autoload aload)))))))
2543
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 )
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 (cdr flist))))
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 (provide 'loadhist)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 ;;; loadhist.el ends here