1 ;;; callers-of-rpt.el --- generate call graph of lisp in XEmacs
3 ;; Copyright (C) 1997 Karl Hegbloom
4 ;; Copyright (C) 1997 Free Software Foundation, Inc.
6 ;; Author: Karl Hegbloom <karlheg@inetarena.com>
7 ;; Maintainer: XEmacs Development Team
10 ;; This file is part of SXEmacs.
12 ;; SXEmacs is free software: you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation, either version 3 of the License, or
15 ;; (at your option) any later version.
17 ;; SXEmacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
25 ;;; Synched up with: not in FSF
29 ;; Grep-2.1 is required.
30 ;; Modify the `xemacs-src-lisp-dir' and `xemacs-pkg-lisp-dir' to reflect
31 ;; where these directories live on your local system.
35 (defvar xemacs-src-lisp-dir "/usr/src/xemacs-20.0/lisp/"
36 "Where the XEmacs 20 lisp sources live.")
37 (defvar xemacs-pkg-lisp-dir "/home/xemacs/packages/"
38 "Where the package lisp sources live.")
40 ;; (makunbound 'caller-table)
41 (defconst caller-table (make-hash-table :test 'equal)
42 "Hash table keyed on the symbols being required. Each element will
43 be a list of file-names of programs that depend on them.")
45 ;;./apel/atype.el:(require 'emu)
46 ;;./apel/atype.el:(require 'alist)
47 ;;./apel/emu-e19.el: (require 'emu-xemacs))
48 ;;./apel/emu-e19.el: (require 'emu-19)
50 (defun make-caller-report ()
51 "Generate a simple report showing .el files that are `require'd by
52 other .el files, and the list of programs that depend on them."
54 (let ((cmd-out (get-buffer-create "*caller-report find-grep output*"))
55 (rpt (get-buffer-create "* caller report *"))
57 (switch-to-buffer cmd-out)
58 (buffer-disable-undo cmd-out)
59 (set-syntax-table emacs-lisp-mode-syntax-table cmd-out)
60 (erase-buffer cmd-out)
61 (message "Running the find | grep...")
63 ;; Note: Edit this part as needed for your installation.
64 (shell-command (concat
65 ;; First the installed lisp
66 "cd " xemacs-src-lisp-dir " ;"
67 "grep -H '(require ' $(find -name '*.el' -print) |"
68 #r" grep -v 'auto-autoloads\.el\|callers-of-rpt\.el' |"
69 " grep -v 'el:[ \t]*;\\|require load' ;" ; ones commented off, and cus-edit.el
71 "cd " xemacs-pkg-lisp-dir " ;"
72 "grep -H '(require ' $(find -name '*.el' -print) |"
73 #r" grep -v 'auto-autoloads\.el\|callers-of-rpt\.el' |"
74 " grep -v 'el:[ \t]*;' ;" ; ones commented off
77 (message "Running the find | grep... Done.")
78 (goto-char (point-min))
81 (setq file-name (buffer-substring (+ (point) 2) ; skip the leading "./"
83 (skip-chars-forward "^:")
86 (re-search-forward "(require '" nil t)
87 (let* ((key (buffer-substring (point) (progn
88 (skip-chars-forward "^) ")
91 (lst (gethash key caller-table)))
92 (unless (member file-name lst)
93 (puthash key (cons file-name lst) caller-table)))
96 (switch-to-buffer rpt)
97 (buffer-disable-undo rpt)
101 (maphash #'(lambda (key val) (push key keys)) caller-table)
102 (setq keys (sort keys #'string<))
103 (mapc #'(lambda (key)
104 (insert (format "(%s '(" key))
105 (let ((lst (gethash key caller-table)))
107 (insert (format "%S" (car lst)))
109 (when lst (insert " "))))
114 (byte-compile 'make-caller-report)
115 (delete-other-windows)
118 ;;; callers-of-rpt.el ends here