comparison lisp/emacs-lisp/trace.el @ 28574:23e11bfcfc21

Change maintainer. Use new backquote syntax.
author Dave Love <fx@gnu.org>
date Thu, 13 Apr 2000 19:12:13 +0000
parents db005054f15d
children 9c74f4f1d1c0
comparison
equal deleted inserted replaced
28573:cdc89dbad540 28574:23e11bfcfc21
1 ;;; trace.el --- tracing facility for Emacs Lisp functions 1 ;;; trace.el --- tracing facility for Emacs Lisp functions
2 2
3 ;; Copyright (C) 1993 Free Software Foundation, Inc. 3 ;; Copyright (C) 1993 Free Software Foundation, Inc.
4 4
5 ;; Author: Hans Chalupsky <hans@cs.buffalo.edu> 5 ;; Author: Hans Chalupsky <hans@cs.buffalo.edu>
6 ;; Maintainer: FSF
6 ;; Created: 15 Dec 1992 7 ;; Created: 15 Dec 1992
7 ;; Keywords: tools, lisp 8 ;; Keywords: tools, lisp
8 9
9 ;; This file is part of GNU Emacs. 10 ;; This file is part of GNU Emacs.
10 11
36 ;; A simple trace package that utilizes advice.el. It generates trace 37 ;; A simple trace package that utilizes advice.el. It generates trace
37 ;; information in a Lisp-style fashion and inserts it into a trace output 38 ;; information in a Lisp-style fashion and inserts it into a trace output
38 ;; buffer. Tracing can be done in the background (or silently) so that 39 ;; buffer. Tracing can be done in the background (or silently) so that
39 ;; generation of trace output won't interfere with what you are currently 40 ;; generation of trace output won't interfere with what you are currently
40 ;; doing. 41 ;; doing.
41
42 ;; How to get the latest trace.el:
43 ;; ===============================
44 ;; You can get the latest version of this file either via anonymous ftp from
45 ;; ftp.cs.buffalo.edu (128.205.32.9) with pathname /pub/Emacs/trace.el,
46 ;; or send email to hans@cs.buffalo.edu and I'll mail it to you.
47 42
48 ;; Requirement: 43 ;; Requirement:
49 ;; ============ 44 ;; ============
50 ;; trace.el needs advice.el version 2.0 or later which you can get from the 45 ;; trace.el needs advice.el version 2.0 or later which you can get from the
51 ;; same place from where you got trace.el. 46 ;; same place from where you got trace.el.
70 ;; 65 ;;
71 ;; (autoload 'trace-function "trace" "Trace a function" t) 66 ;; (autoload 'trace-function "trace" "Trace a function" t)
72 ;; (autoload 'trace-function-background "trace" "Trace a function" t) 67 ;; (autoload 'trace-function-background "trace" "Trace a function" t)
73 ;; 68 ;;
74 ;; or explicitly load it with (require 'trace) or (load "trace"). 69 ;; or explicitly load it with (require 'trace) or (load "trace").
75
76 ;; Comments, suggestions, bug reports
77 ;; ==================================
78 ;; are strongly appreciated, please email them to hans@cs.buffalo.edu.
79 70
80 ;; Usage: 71 ;; Usage:
81 ;; ====== 72 ;; ======
82 ;; - To trace a function say `M-x trace-function' which will ask you for the 73 ;; - To trace a function say `M-x trace-function' which will ask you for the
83 ;; name of the function/subr/macro to trace, as well as for the buffer 74 ;; name of the function/subr/macro to trace, as well as for the buffer
219 ;; so that it will generate the proper trace output in BUFFER 210 ;; so that it will generate the proper trace output in BUFFER
220 ;; (quietly if BACKGROUND is t). 211 ;; (quietly if BACKGROUND is t).
221 (ad-make-advice 212 (ad-make-advice
222 trace-advice-name nil t 213 trace-advice-name nil t
223 (cond (background 214 (cond (background
224 (` (advice 215 `(advice
225 lambda () 216 lambda ()
226 (let ((trace-level (1+ trace-level)) 217 (let ((trace-level (1+ trace-level))
227 (trace-buffer (get-buffer-create (, buffer)))) 218 (trace-buffer (get-buffer-create ,buffer)))
228 (save-excursion 219 (save-excursion
229 (set-buffer trace-buffer) 220 (set-buffer trace-buffer)
230 (goto-char (point-max)) 221 (goto-char (point-max))
231 ;; Insert a separator from previous trace output: 222 ;; Insert a separator from previous trace output:
232 (if (= trace-level 1) (insert trace-separator)) 223 (if (= trace-level 1) (insert trace-separator))
233 (insert 224 (insert
234 (trace-entry-message 225 (trace-entry-message
235 '(, function) trace-level ad-arg-bindings))) 226 ',function trace-level ad-arg-bindings)))
236 ad-do-it 227 ad-do-it
237 (save-excursion 228 (save-excursion
238 (set-buffer trace-buffer) 229 (set-buffer trace-buffer)
239 (goto-char (point-max)) 230 (goto-char (point-max))
240 (insert 231 (insert
241 (trace-exit-message 232 (trace-exit-message
242 '(, function) trace-level ad-return-value))))))) 233 ',function trace-level ad-return-value))))))
243 (t (` (advice 234 (t `(advice
244 lambda () 235 lambda ()
245 (let ((trace-level (1+ trace-level)) 236 (let ((trace-level (1+ trace-level))
246 (trace-buffer (get-buffer-create (, buffer)))) 237 (trace-buffer (get-buffer-create ,buffer)))
247 (pop-to-buffer trace-buffer) 238 (pop-to-buffer trace-buffer)
248 (goto-char (point-max)) 239 (goto-char (point-max))
249 ;; Insert a separator from previous trace output: 240 ;; Insert a separator from previous trace output:
250 (if (= trace-level 1) (insert trace-separator)) 241 (if (= trace-level 1) (insert trace-separator))
251 (insert 242 (insert
252 (trace-entry-message 243 (trace-entry-message
253 '(, function) trace-level ad-arg-bindings)) 244 ',function trace-level ad-arg-bindings))
254 ad-do-it 245 ad-do-it
255 (pop-to-buffer trace-buffer) 246 (pop-to-buffer trace-buffer)
256 (goto-char (point-max)) 247 (goto-char (point-max))
257 (insert 248 (insert
258 (trace-exit-message 249 (trace-exit-message
259 '(, function) trace-level ad-return-value))))))))) 250 ',function trace-level ad-return-value))))))))
260 251
261 (defun trace-function-internal (function buffer background) 252 (defun trace-function-internal (function buffer background)
262 ;; Adds trace advice for FUNCTION and activates it. 253 ;; Adds trace advice for FUNCTION and activates it.
263 (ad-add-advice 254 (ad-add-advice
264 function 255 function