428
+ − 1 ;;; callers-of-rpt.el --- generate call graph of lisp in XEmacs
+ − 2
+ − 3 ;; Copyright (C) 1997 Karl Hegbloom
+ − 4 ;; Copyright (C) 1997 Free Software Foundation, Inc.
+ − 5
+ − 6 ;; Author: Karl Hegbloom <karlheg@inetarena.com>
+ − 7 ;; Maintainer: XEmacs Development Team
+ − 8 ;; Keywords: internal
+ − 9
+ − 10 ;; This file is part of XEmacs.
+ − 11
+ − 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)
+ − 15 ;; any later version.
+ − 16
+ − 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.
+ − 21
+ − 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.
+ − 26
+ − 27 ;;; Synched up with: not in FSF
+ − 28
+ − 29 ;;; Commentary:
+ − 30
+ − 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.
+ − 34
+ − 35 ;;; Code:
+ − 36
+ − 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.")
+ − 41
+ − 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.")
+ − 46
+ − 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)
+ − 51
+ − 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."
+ − 55 (interactive)
+ − 56 (let ((cmd-out (get-buffer-create "*caller-report find-grep output*"))
+ − 57 (rpt (get-buffer-create "* caller report *"))
+ − 58 file-name)
+ − 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...")
+ − 64 (sit-for 0)
+ − 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
+ − 72 ;; Then the packages
+ − 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
+ − 77 )
+ − 78 cmd-out)
+ − 79 (message "Running the find | grep... Done.")
+ − 80 (goto-char (point-min))
+ − 81 (sit-for 0)
+ − 82 (while (not (eobp))
+ − 83 (setq file-name (buffer-substring (+ (point) 2) ; skip the leading "./"
+ − 84 (progn
+ − 85 (skip-chars-forward "^:")
+ − 86 (point))
+ − 87 cmd-out))
+ − 88 (re-search-forward "(require '" nil t)
+ − 89 (let* ((key (buffer-substring (point) (progn
+ − 90 (skip-chars-forward "^) ")
+ − 91 (point))
+ − 92 cmd-out))
+ − 93 (lst (gethash key caller-table)))
+ − 94 (unless (member file-name lst)
+ − 95 (puthash key (cons file-name lst) caller-table)))
+ − 96 (forward-line 1)
+ − 97 (sit-for 0))
+ − 98 (switch-to-buffer rpt)
+ − 99 (buffer-disable-undo rpt)
+ − 100 (erase-buffer rpt)
+ − 101 (sit-for 0)
+ − 102 (let (keys)
+ − 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)))
+ − 108 (while lst
+ − 109 (insert (format "%S" (car lst)))
+ − 110 (setq lst (cdr lst))
+ − 111 (when lst (insert " "))))
+ − 112 (insert "))\n")
+ − 113 (sit-for 0))
+ − 114 keys))))
+ − 115
+ − 116 (byte-compile 'make-caller-report)
+ − 117 (delete-other-windows)
+ − 118 (make-caller-report)
+ − 119
+ − 120 ;;; callers-of-rpt.el ends here