Mercurial > hg > xemacs-beta
comparison lisp/callers-of-rpt.el @ 227:0e522484dd2a r20-5b12
Import from CVS: tag r20-5b12
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:12:37 +0200 |
parents | |
children | 8626e4521993 |
comparison
equal
deleted
inserted
replaced
226:eea38c7ad7b4 | 227:0e522484dd2a |
---|---|
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-hashtable 256 #'equal) | |
44 "Hashtable 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 (puthash key (add-to-list 'lst file-name) caller-table)) | |
95 (forward-line 1) | |
96 (sit-for 0)) | |
97 (switch-to-buffer rpt) | |
98 (buffer-disable-undo rpt) | |
99 (erase-buffer rpt) | |
100 (sit-for 0) | |
101 (let (keys) | |
102 (maphash #'(lambda (key val) (push key keys)) caller-table) | |
103 (setq keys (sort keys #'string<)) | |
104 (mapc #'(lambda (key) | |
105 (insert (format "(%s '(" key)) | |
106 (let ((lst (gethash key caller-table))) | |
107 (while lst | |
108 (insert (format "%S" (car lst))) | |
109 (setq lst (cdr lst)) | |
110 (when lst (insert " ")))) | |
111 (insert "))\n") | |
112 (sit-for 0)) | |
113 keys)))) | |
114 | |
115 (byte-compile 'make-caller-report) | |
116 (delete-other-windows) | |
117 (make-caller-report) | |
118 | |
119 ;;; callers-of-rpt.el ends here |