annotate lisp/loadhist.el @ 4130:e5aee6a3bb75

* hippie-exp.el: Renamed from hippie.el. Changes from Anders Holst, to bring hippie-expand up to version 1.2: * hippie-exp.el (hippie-expand-max-buffers): New variable. (try-expand-line-all-buffers, try-expand-list-all-buffers, try-expand-dabbrev-all-buffers): Use it. (try-expand-list, try-expand-list-all-buffers): New functions. (he-string-beg, he-string-end, he-search-loc): These values are now markers, not integers. Uses changed. (he-reset-string, he-substitute-string): Use a marker to preserve the old position of point. (try-expand-all-abbrevs): handle case the same way as the usual expand-abbrev (which is not a very good way, but for consistency...). (he-dabbrev-beg): Use `skip-syntax' instead of `skip-chars', to adjust its behavior to different modes. (hippie-expand): Don't messages which try function it is using, when the expansion itself is done in the minibuffer (it was very annoying to have the message obscuring the expansion). (try-complete-file-name, try-complete-file-name-partially, try-complete-lisp-symbol, try-complete-lisp-symbol-partially, try-expand-line, try-expand-line-all-buffers, try-expand-all-abbrevs, try-expand-dabbrev, try-expand-dabbrev-all-buffers): No unnecessary "resetting" of the epansion, when no expansion is done (caused the buffer to be marked as changed, although nothing was done, among other things). (he-reset-string): Undoing of last expansion at a later occasion, now undoes correctly (before, it garbled things up). (make-hippie-expand-function): now uses "(function ...)" instead of "'" (matters for compilation). (try-expand-line, try-expand-line-all-buffers, he-line-search-regexp): uses `comint-prompt-regexp' instead of `shell-prompt-pattern', to strip off prompt in process buffers.
author Jim Blandy <jimb@redhat.com>
date Sun, 18 Jul 1993 06:20:15 +0000
parents 9a1b00513968
children 4521917cdd6e
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)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 ((boundp x) (makunbound x))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 ((fboundp x)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 (fmakunbound x)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 (let ((aload (get x 'autoload)))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 (if aload (fset x aload))))))
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 )
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 (cdr flist))))
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 (provide 'loadhist)
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111
9a1b00513968 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 ;;; loadhist.el ends here