* Tool for ELISP code analysis @ 2007-03-05 12:21 Marc Tfardy 2007-03-06 0:37 ` Johan Bockgård 0 siblings, 1 reply; 3+ messages in thread From: Marc Tfardy @ 2007-03-05 12:21 UTC (permalink / raw) To: help-gnu-emacs Hi! I try to understand some (complicated) ELISP code with many lines of code and many functions. It is not easy to keep overview of the function calls and dependecies between functions/variables. Is there maybe a Emacs tool for ELISP code analysis? It should idicate all disired functions and variables (specified with regexp, like e.g. "bla-*") with list of all function/variables called/referenced from this function. Some example - assume we have following code: -file: bla.el----------------------------------------------------------- (defvar bla-max-iter 100) (defun bla-foo () (let ((i 0)) (while (< i bla-max-iter) (bla-big-job i) (incf i))) (defun bla-goo (text) (message "[BLA] %s" text)) (defun bla-big-job (num) (unimportant-code) (more-unimportant-code) (bla-do-nothing) (bla-do-something)) (defun bla-do-nothing () (long-unimportant-code) (setq bla-min 0) (setq bla-max 10)) (defun bla-do-something () (strange-code) (bla-antoher-fun 1 2 3 4) (bla-secret-fun 0)) (defun bla-another-fun (v1 v2 v3 v4) (+ v1 v2 v3 v4)) (defun bla-secret-fun (n) (message "MAGIC!")) -file: bla.el ends here------------------------------------------------- Now we start analyse tool for whole code in buffer bla.el. We look only for bla-stuff: M-x elisp-analyse RET bla-* and we should get something like this: VAR: bla-max-iter FUN: bla-foo: --> bla-max-iter (VAR) --> bla-big-job (FUN) FUN: bla-goo: FUN: bla-big-job: --> bla-do-nothing (FUN) --> bla-do-something (FUN) FUN: bla-do-nothing: --> bla-min (VAR) --> bla-max (VAR) FUN: bla-do-something: --> bla-antoher-fun (FUN) --> bla-secret-fun (FUN) FUN: bla-another-fun: FUN: bla-secret-fun: Note: we get *ONLY* functions and variables with "bla-"-Prefix, due to elisp-analyse call with bla-*. The function and variable names in this list could be linked to definitions in bla.el, so a click with mouse or RET on such a name jumps directly to properly line (in other window with bla.el). Does exists already such a tool? regards Marc ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Tool for ELISP code analysis 2007-03-05 12:21 Tool for ELISP code analysis Marc Tfardy @ 2007-03-06 0:37 ` Johan Bockgård 2007-03-06 22:30 ` Marc Tfardy 0 siblings, 1 reply; 3+ messages in thread From: Johan Bockgård @ 2007-03-06 0:37 UTC (permalink / raw) To: help-gnu-emacs Marc Tfardy <m-t-o___CUT__IT___@web.de> writes: > I try to understand some (complicated) ELISP code with many lines of > code and many functions. It is not easy to keep overview of the > function calls and dependecies between functions/variables. Is there > maybe a Emacs tool for ELISP code analysis? ,----[ C-h v byte-compile-generate-call-tree RET ] | byte-compile-generate-call-tree is a variable defined in `bytecomp.el'. | Its value is nil | | | Documentation: | *Non-nil means collect call-graph information when compiling. | This records which functions were called and from where. | If the value is t, compilation displays the call graph when it finishes. | If the value is neither t nor nil, compilation asks you whether to display | the graph. | | The call tree only lists functions called, not macros used. Those functions | which the byte-code interpreter knows about directly (eq, cons, etc.) are | not reported. | | The call tree also lists those functions which are not known to be called | (that is, to which no calls have been compiled). Functions which can be | invoked interactively are excluded from this list. | | You can customize this variable. | | [back] `---- ,----[ C-h v byte-compile-call-tree-sort RET ] | byte-compile-call-tree-sort is a variable defined in `bytecomp.el'. | Its value is name | | | Documentation: | *If non-nil, sort the call tree. | The values `name', `callers', `calls', `calls+callers' | specify different fields to sort on. | | You can customize this variable. | | [back] `---- ,----[ C-h f display-call-tree RET ] | display-call-tree is an interactive compiled Lisp function in `bytecomp.el'. | (display-call-tree &optional FILENAME) | | Display a call graph of a specified file. | This lists which functions have been called, what functions called | them, and what functions they call. The list includes all functions | whose definitions have been compiled in this Emacs session, as well as | all functions called by those functions. | | The call graph does not include macros, inline functions, or | primitives that the byte-code interpreter knows about directly (eq, | cons, etc.). | | The call tree also lists those functions which are not known to be called | (that is, to which no calls have been compiled), and which cannot be | invoked interactively. | | [back] `---- Also http://whome.phys.au.dk/~harder/who-calls.el ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Tool for ELISP code analysis 2007-03-06 0:37 ` Johan Bockgård @ 2007-03-06 22:30 ` Marc Tfardy 0 siblings, 0 replies; 3+ messages in thread From: Marc Tfardy @ 2007-03-06 22:30 UTC (permalink / raw) To: help-gnu-emacs Johan Bockgård wrote: > Marc Tfardy <m-t-o___CUT__IT___@web.de> writes: > >> I try to understand some (complicated) ELISP code with many lines of >> code and many functions. It is not easy to keep overview of the >> function calls and dependecies between functions/variables. Is there >> maybe a Emacs tool for ELISP code analysis? > > > ,----[ C-h v byte-compile-generate-call-tree RET ] > | byte-compile-generate-call-tree is a variable defined in `bytecomp.el'. > | Its value is nil > [...] > > Also http://whome.phys.au.dk/~harder/who-calls.el Thanks a lot! It's incredible, that so many things exists ready to use out of the box. It is nearly exactly what I need! regards Marc ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-03-06 22:30 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2007-03-05 12:21 Tool for ELISP code analysis Marc Tfardy 2007-03-06 0:37 ` Johan Bockgård 2007-03-06 22:30 ` Marc Tfardy
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).