Merge from emacs-23
[bpt/emacs.git] / lisp / emacs-lisp / trace.el
index 1ebf118..77b8e1e 100644 (file)
@@ -1,7 +1,7 @@
 ;;; trace.el --- tracing facility for Emacs Lisp functions
 
-;; Copyright (C) 1993, 1998, 2000, 2002, 2003, 2004,
-;;   2005, 2006 Free Software Foundation, Inc.
+;; Copyright (C) 1993, 1998, 2000, 2001, 2002, 2003, 2004,
+;;   2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
 
 ;; Author: Hans Chalupsky <hans@cs.buffalo.edu>
 ;; Maintainer: FSF
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -21,9 +21,7 @@
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;; LCD Archive Entry:
 ;; trace|Hans Chalupsky|hans@cs.buffalo.edu|
   :group 'lisp)
 
 ;;;###autoload
-(defcustom trace-buffer "*trace-output*"
-  "*Trace output will by default go to that buffer."
+(defcustom trace-buffer (purecopy "*trace-output*")
+  "Trace output will by default go to that buffer."
   :type 'string
   :group 'trace)
 
          (if (> level 1) " " "")
          level
          function
-         (mapconcat (lambda (binding)
-                      (concat
-                       (symbol-name (ad-arg-binding-field binding 'name))
-                       "="
-                       ;; do this so we'll see strings:
-                       (prin1-to-string
-                        (ad-arg-binding-field binding 'value))))
-                    argument-bindings
-                    " ")))
+          (let ((print-circle t))
+            (mapconcat (lambda (binding)
+                         (concat
+                          (symbol-name (ad-arg-binding-field binding 'name))
+                          "="
+                          ;; do this so we'll see strings:
+                          (prin1-to-string
+                           (ad-arg-binding-field binding 'value))))
+                       argument-bindings
+                       " "))))
 
 (defun trace-exit-message (function level value)
   ;; Generates a string that describes that FUNCTION has been exited at
          level
          function
          ;; do this so we'll see strings:
-         (prin1-to-string value)))
+         (let ((print-circle t)) (prin1-to-string value))))
 
 (defun trace-make-advice (function buffer background)
   ;; Builds the piece of advice to be added to FUNCTION's advice info
           (trace-buffer (get-buffer-create ,buffer)))
        (unless inhibit-trace
         (with-current-buffer trace-buffer
-          ,(unless background '(pop-to-buffer trace-buffer))
+          (set (make-local-variable 'window-point-insertion-type) t)
+           ,(unless background '(display-buffer trace-buffer))
           (goto-char (point-max))
           ;; Insert a separator from previous trace output:
           (if (= trace-level 1) (insert trace-separator))
        ad-do-it
        (unless inhibit-trace
         (with-current-buffer trace-buffer
-          ,(unless background '(pop-to-buffer trace-buffer))
+          ,(unless background '(display-buffer trace-buffer))
           (goto-char (point-max))
           (insert
            (trace-exit-message
 For every call of FUNCTION Lisp-style trace messages that display argument
 and return values will be inserted into BUFFER.  This function generates the
 trace advice for FUNCTION and activates it together with any other advice
-there might be!! The trace BUFFER will popup whenever FUNCTION is called.
+there might be!!  The trace BUFFER will popup whenever FUNCTION is called.
 Do not use this to trace functions that switch buffers or do any other
 display oriented stuff, use `trace-function-background' instead."
   (interactive
@@ -265,11 +265,14 @@ display oriented stuff, use `trace-function-background' instead."
 ;;;###autoload
 (defun trace-function-background (function &optional buffer)
   "Traces FUNCTION with trace output going quietly to BUFFER.
-For every call of FUNCTION Lisp-style trace messages that display argument
-and return values will be inserted into BUFFER.  This function generates the
-trace advice for FUNCTION and activates it together with any other advice
-there might be!! Trace output will quietly go to BUFFER without changing
-the window or buffer configuration at all."
+When this tracing is enabled, every call to FUNCTION writes
+a Lisp-style trace message (showing the arguments and return value)
+into BUFFER.  This function generates advice to trace FUNCTION
+and activates it together with any other advice there might be.
+The trace output goes to BUFFER quietly, without changing
+the window or buffer configuration.
+
+BUFFER defaults to `trace-buffer'."
   (interactive
    (list
     (intern