diff options
| author | Stefan Monnier | 2013-05-06 18:33:24 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2013-05-06 18:33:24 -0400 |
| commit | ee6cff992302d80b9cbb0889725066c485dbf265 (patch) | |
| tree | e47dad72e379c4e27f3bb6b15dae371113cc12d9 | |
| parent | 32985194f2370621bc2178f94d6cae0cf01d1702 (diff) | |
| download | emacs-ee6cff992302d80b9cbb0889725066c485dbf265.tar.gz emacs-ee6cff992302d80b9cbb0889725066c485dbf265.zip | |
* lisp/emacs-lisp/trace.el (trace--display-buffer): New function.
(trace-make-advice): Use it.
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/emacs-lisp/trace.el | 24 |
2 files changed, 19 insertions, 10 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index d700b53f3a2..b58d8b5e610 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2013-05-06 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * emacs-lisp/trace.el (trace--display-buffer): New function. | ||
| 4 | (trace-make-advice): Use it. | ||
| 5 | |||
| 1 | 2013-05-06 Juri Linkov <juri@jurta.org> | 6 | 2013-05-06 Juri Linkov <juri@jurta.org> |
| 2 | 7 | ||
| 3 | * emacs-lisp/lisp-mode.el (eval-defun-2): Doc fix. (Bug#14344) | 8 | * emacs-lisp/lisp-mode.el (eval-defun-2): Doc fix. (Bug#14344) |
diff --git a/lisp/emacs-lisp/trace.el b/lisp/emacs-lisp/trace.el index fce8643923f..42643bf2317 100644 --- a/lisp/emacs-lisp/trace.el +++ b/lisp/emacs-lisp/trace.el | |||
| @@ -200,6 +200,18 @@ some global variables)." | |||
| 200 | 200 | ||
| 201 | (defvar trace--timer nil) | 201 | (defvar trace--timer nil) |
| 202 | 202 | ||
| 203 | (defun trace--display-buffer (buf) | ||
| 204 | (unless (or trace--timer | ||
| 205 | (get-buffer-window buf 'visible)) | ||
| 206 | (setq trace--timer | ||
| 207 | ;; Postpone the display to some later time, in case we | ||
| 208 | ;; can't actually do it now. | ||
| 209 | (run-with-timer 0 nil | ||
| 210 | (lambda () | ||
| 211 | (setq trace--timer nil) | ||
| 212 | (display-buffer buf nil 0)))))) | ||
| 213 | |||
| 214 | |||
| 203 | (defun trace-make-advice (function buffer background context) | 215 | (defun trace-make-advice (function buffer background context) |
| 204 | "Build the piece of advice to be added to trace FUNCTION. | 216 | "Build the piece of advice to be added to trace FUNCTION. |
| 205 | FUNCTION is the name of the traced function. | 217 | FUNCTION is the name of the traced function. |
| @@ -214,15 +226,7 @@ be printed along with the arguments in the trace." | |||
| 214 | (unless inhibit-trace | 226 | (unless inhibit-trace |
| 215 | (with-current-buffer trace-buffer | 227 | (with-current-buffer trace-buffer |
| 216 | (set (make-local-variable 'window-point-insertion-type) t) | 228 | (set (make-local-variable 'window-point-insertion-type) t) |
| 217 | (unless (or background trace--timer | 229 | (unless background (trace--display-buffer trace-buffer)) |
| 218 | (get-buffer-window trace-buffer 'visible)) | ||
| 219 | (setq trace--timer | ||
| 220 | ;; Postpone the display to some later time, in case we | ||
| 221 | ;; can't actually do it now. | ||
| 222 | (run-with-timer 0 nil | ||
| 223 | (lambda () | ||
| 224 | (setq trace--timer nil) | ||
| 225 | (display-buffer trace-buffer))))) | ||
| 226 | (goto-char (point-max)) | 230 | (goto-char (point-max)) |
| 227 | ;; Insert a separator from previous trace output: | 231 | ;; Insert a separator from previous trace output: |
| 228 | (if (= trace-level 1) (insert trace-separator)) | 232 | (if (= trace-level 1) (insert trace-separator)) |
| @@ -235,7 +239,7 @@ be printed along with the arguments in the trace." | |||
| 235 | (unless inhibit-trace | 239 | (unless inhibit-trace |
| 236 | (let ((ctx (funcall context))) | 240 | (let ((ctx (funcall context))) |
| 237 | (with-current-buffer trace-buffer | 241 | (with-current-buffer trace-buffer |
| 238 | (unless background (display-buffer trace-buffer)) | 242 | (unless background (trace--display-buffer trace-buffer)) |
| 239 | (goto-char (point-max)) | 243 | (goto-char (point-max)) |
| 240 | (insert | 244 | (insert |
| 241 | (trace-exit-message | 245 | (trace-exit-message |