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 XEmacs.
12 ;; XEmacs is free software; you can redistribute it and/or modify it
13 ;; under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; XEmacs is distributed in the hope that it will be useful, but
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 ;; General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with XEmacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
27 ;;; Synched up with: not in FSF
31 ;; Grep-2.1 is required.
32 ;; Modify the `xemacs-src-lisp-dir' and `xemacs-pkg-lisp-dir' to reflect
33 ;; where these directories live on your local system.
37 (defvar xemacs-src-lisp-dir "/usr/src/xemacs-20.0/lisp/"
38 "Where the XEmacs 20 lisp sources live.")
39 (defvar xemacs-pkg-lisp-dir "/home/xemacs/packages/"
40 "Where the package lisp sources live.")
42 ;; (makunbound 'caller-table)
43 (defconst caller-table (make-hash-table :test 'equal)
44 "Hash table keyed on the symbols being required. Each element will
45 be a list of file-names of programs that depend on them.")
47 ;;./apel/atype.el:(require 'emu)
48 ;;./apel/atype.el:(require 'alist)
49 ;;./apel/emu-e19.el: (require 'emu-xemacs))
50 ;;./apel/emu-e19.el: (require 'emu-19)
52 (defun make-caller-report ()
53 "Generate a simple report showing .el files that are `require'd by
54 other .el files, and the list of programs that depend on them."
56 (let ((cmd-out (get-buffer-create "*caller-report find-grep output*"))
57 (rpt (get-buffer-create "* caller report *"))
59 (switch-to-buffer cmd-out)
60 (buffer-disable-undo cmd-out)
61 (set-syntax-table emacs-lisp-mode-syntax-table cmd-out)
62 (erase-buffer cmd-out)
63 (message "Running the find | grep...")
65 ;; Note: Edit this part as needed for your installation.
66 (shell-command (concat
67 ;; First the installed lisp
68 "cd " xemacs-src-lisp-dir " ;"
69 "grep -H '(require ' $(find -name '*.el' -print) |"
70 " grep -v 'auto-autoloads\\.el\\|callers-of-rpt\\.el' |"
71 " grep -v 'el:[ \t]*;\\|require load' ;" ; ones commented off, and cus-edit.el
73 "cd " xemacs-pkg-lisp-dir " ;"
74 "grep -H '(require ' $(find -name '*.el' -print) |"
75 " grep -v 'auto-autoloads\\.el\\|callers-of-rpt\\.el' |"
76 " grep -v 'el:[ \t]*;' ;" ; ones commented off
79 (message "Running the find | grep... Done.")
80 (goto-char (point-min))
83 (setq file-name (buffer-substring (+ (point) 2) ; skip the leading "./"
85 (skip-chars-forward "^:")
88 (re-search-forward "(require '" nil t)
89 (let* ((key (buffer-substring (point) (progn
90 (skip-chars-forward "^) ")
93 (lst (gethash key caller-table)))
94 (unless (member file-name lst)
95 (puthash key (cons file-name lst) caller-table)))
98 (switch-to-buffer rpt)
99 (buffer-disable-undo rpt)
103 (maphash #'(lambda (key val) (push key keys)) caller-table)
104 (setq keys (sort keys #'string<))
105 (mapc #'(lambda (key)
106 (insert (format "(%s '(" key))
107 (let ((lst (gethash key caller-table)))
109 (insert (format "%S" (car lst)))
111 (when lst (insert " "))))
116 (byte-compile 'make-caller-report)
117 (delete-other-windows)
120 ;;; callers-of-rpt.el ends here