aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2005-02-27 02:30:58 +0000
committerStefan Monnier2005-02-27 02:30:58 +0000
commit5f8a82e1ac7e32ae842aed52e0f81c4334625f46 (patch)
treee8560edc212d0cc3c5858eccf6d8a1b7751497b9
parent3f4468ab4e79050bb1e40b675e1c6f1564cbe6f4 (diff)
downloademacs-5f8a82e1ac7e32ae842aed52e0f81c4334625f46.tar.gz
emacs-5f8a82e1ac7e32ae842aed52e0f81c4334625f46.zip
(inhibit-trace): New var.
(trace-make-advice): Use it.
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/emacs-lisp/trace.el86
2 files changed, 43 insertions, 50 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 51e13988a81..be90765ae36 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,10 @@
12005-02-26 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * emacs-lisp/trace.el (inhibit-trace): New var.
4 (trace-make-advice): Use it.
5
6 * emacs-lisp/debug.el (debug): Put back the inhibit-trace.
7
12005-02-26 Kim F. Storm <storm@cua.dk> 82005-02-26 Kim F. Storm <storm@cua.dk>
2 9
3 * mouse.el (mouse-1-click-in-non-selected-windows): New defcustom. 10 * mouse.el (mouse-1-click-in-non-selected-windows): New defcustom.
diff --git a/lisp/emacs-lisp/trace.el b/lisp/emacs-lisp/trace.el
index a6ff9b15286..e3d3e9e645e 100644
--- a/lisp/emacs-lisp/trace.el
+++ b/lisp/emacs-lisp/trace.el
@@ -1,6 +1,6 @@
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, 1998, 2000, 2005 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;; Maintainer: FSF
@@ -175,6 +175,9 @@
175;; Used to separate new trace output from previous traced runs: 175;; Used to separate new trace output from previous traced runs:
176(defvar trace-separator (format "%s\n" (make-string 70 ?=))) 176(defvar trace-separator (format "%s\n" (make-string 70 ?=)))
177 177
178(defvar inhibit-trace nil
179 "If non-nil, all tracing is temporarily inhibited.")
180
178(defun trace-entry-message (function level argument-bindings) 181(defun trace-entry-message (function level argument-bindings)
179 ;; Generates a string that describes that FUNCTION has been entered at 182 ;; Generates a string that describes that FUNCTION has been entered at
180 ;; trace LEVEL with ARGUMENT-BINDINGS. 183 ;; trace LEVEL with ARGUMENT-BINDINGS.
@@ -183,14 +186,13 @@
183 (if (> level 1) " " "") 186 (if (> level 1) " " "")
184 level 187 level
185 function 188 function
186 (mapconcat (function 189 (mapconcat (lambda (binding)
187 (lambda (binding) 190 (concat
188 (concat 191 (symbol-name (ad-arg-binding-field binding 'name))
189 (symbol-name (ad-arg-binding-field binding 'name)) 192 "="
190 "=" 193 ;; do this so we'll see strings:
191 ;; do this so we'll see strings: 194 (prin1-to-string
192 (prin1-to-string 195 (ad-arg-binding-field binding 'value))))
193 (ad-arg-binding-field binding 'value)))))
194 argument-bindings 196 argument-bindings
195 " "))) 197 " ")))
196 198
@@ -211,43 +213,27 @@
211 ;; (quietly if BACKGROUND is t). 213 ;; (quietly if BACKGROUND is t).
212 (ad-make-advice 214 (ad-make-advice
213 trace-advice-name nil t 215 trace-advice-name nil t
214 (cond (background 216 `(advice
215 `(advice 217 lambda ()
216 lambda () 218 (let ((trace-level (1+ trace-level))
217 (let ((trace-level (1+ trace-level)) 219 (trace-buffer (get-buffer-create ,buffer)))
218 (trace-buffer (get-buffer-create ,buffer))) 220 (unless inhibit-trace
219 (save-excursion 221 (with-current-buffer trace-buffer
220 (set-buffer trace-buffer) 222 ,(unless background '(pop-to-buffer trace-buffer))
221 (goto-char (point-max)) 223 (goto-char (point-max))
222 ;; Insert a separator from previous trace output: 224 ;; Insert a separator from previous trace output:
223 (if (= trace-level 1) (insert trace-separator)) 225 (if (= trace-level 1) (insert trace-separator))
224 (insert 226 (insert
225 (trace-entry-message 227 (trace-entry-message
226 ',function trace-level ad-arg-bindings))) 228 ',function trace-level ad-arg-bindings))))
227 ad-do-it 229 ad-do-it
228 (save-excursion 230 (unless inhibit-trace
229 (set-buffer trace-buffer) 231 (with-current-buffer trace-buffer
230 (goto-char (point-max)) 232 ,(unless background '(pop-to-buffer trace-buffer))
231 (insert 233 (goto-char (point-max))
232 (trace-exit-message 234 (insert
233 ',function trace-level ad-return-value)))))) 235 (trace-exit-message
234 (t `(advice 236 ',function trace-level ad-return-value))))))))
235 lambda ()
236 (let ((trace-level (1+ trace-level))
237 (trace-buffer (get-buffer-create ,buffer)))
238 (pop-to-buffer trace-buffer)
239 (goto-char (point-max))
240 ;; Insert a separator from previous trace output:
241 (if (= trace-level 1) (insert trace-separator))
242 (insert
243 (trace-entry-message
244 ',function trace-level ad-arg-bindings))
245 ad-do-it
246 (pop-to-buffer trace-buffer)
247 (goto-char (point-max))
248 (insert
249 (trace-exit-message
250 ',function trace-level ad-return-value))))))))
251 237
252(defun trace-function-internal (function buffer background) 238(defun trace-function-internal (function buffer background)
253 ;; Adds trace advice for FUNCTION and activates it. 239 ;; Adds trace advice for FUNCTION and activates it.
@@ -297,9 +283,9 @@ activated only if the advice of FUNCTION is currently active. If FUNCTION
297was not traced this is a noop." 283was not traced this is a noop."
298 (interactive 284 (interactive
299 (list (ad-read-advised-function "Untrace function: " 'trace-is-traced))) 285 (list (ad-read-advised-function "Untrace function: " 'trace-is-traced)))
300 (cond ((trace-is-traced function) 286 (when (trace-is-traced function)
301 (ad-remove-advice function 'around trace-advice-name) 287 (ad-remove-advice function 'around trace-advice-name)
302 (ad-update function)))) 288 (ad-update function)))
303 289
304(defun untrace-all () 290(defun untrace-all ()
305 "Untraces all currently traced functions." 291 "Untraces all currently traced functions."
@@ -309,5 +295,5 @@ was not traced this is a noop."
309 295
310(provide 'trace) 296(provide 'trace)
311 297
312;;; arch-tag: cfd170a7-4932-4331-8c8b-b7151942e5a1 298;; arch-tag: cfd170a7-4932-4331-8c8b-b7151942e5a1
313;;; trace.el ends here 299;;; trace.el ends here