[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] trace package
From: |
Vitaly Mayatskikh |
Subject: |
[PATCH] trace package |
Date: |
Tue, 11 Nov 2008 21:24:02 +0100 |
User-agent: |
Wanderlust/2.15.6 (Almost Unreal) Emacs/22.2 Mule/5.0 (SAKAKI) |
trace.el has functions trace-function and trace-function-background,
which allows to add function or macro for tracing. Sometimes it is
useful to trace a bunch of functions in one package, like it is done
in elp.el (Emacs Lisp Profiler), but trace.el lacks this
facility. This patch introduces 3 functions to help with package
tracing: trace-package, trace-package-background and untrace-package.
Index: lisp/emacs-lisp/trace.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/emacs-lisp/trace.el,v
retrieving revision 1.22
diff -p -u -w -r1.22 trace.el
--- lisp/emacs-lisp/trace.el 10 Jun 2008 16:08:46 -0000 1.22
+++ lisp/emacs-lisp/trace.el 10 Nov 2008 19:40:37 -0000
@@ -153,6 +153,7 @@
;;; Code:
(require 'advice)
+(require 'cl)
(defgroup trace nil
"Tracing facility for Emacs Lisp functions."
@@ -297,6 +298,37 @@ was not traced this is a noop."
(ad-do-advised-functions (function)
(untrace-function function)))
+(macrolet ((defun-trace-package (name background doc)
+ `(defun ,name (prefix &optional buffer)
+ ,doc
+ (interactive
+ (list
+ (completing-read "Prefix of package to trace: " obarray)
+ (read-buffer "Output to buffer: " trace-buffer)))
+ (if (zerop (length prefix))
+ (error "Tracing all Emacs functions would render Emacs
unusable"))
+ (dolist (fun (mapcar 'intern (all-completions prefix obarray
'fboundp t)))
+ (trace-function-internal fun buffer ,background)))))
+ (defun-trace-package trace-package nil
+ "Traces all functions which start with PREFIX. Trace output going to
BUFFER.
+For example, to trace all TRACE functions, do the following:
+
+ \\[trace-package] RET trace- RET")
+ (defun-trace-package trace-package-background t
+ "Traces all functions which start with PREFIX. Trace output going quietly
+to BUFFER. For example, to trace all TRACE functions, do the following:
+
+ \\[trace-package] RET trace- RET"))
+
+(defun untrace-package (prefix)
+ "Untraces all functions which start with PREFIX, and possibly activates
+all remaining advice."
+ (interactive
+ (list
+ (completing-read "Prefix of package to untrace: " obarray)))
+ (dolist (fun (mapcar 'intern (all-completions prefix obarray
'trace-is-traced t)))
+ (untrace-function fun)))
+
(provide 'trace)
;; arch-tag: cfd170a7-4932-4331-8c8b-b7151942e5a1
--
wbr, Vitaly
- [PATCH] trace package,
Vitaly Mayatskikh <=