diff -u -w "pp-CVS-2008-04-18.el" "pp-patched-2008-04-18.el"
--- pp-CVS-2008-04-18.el	2008-04-18 13:48:24.000000000 -0700
+++ pp-patched-2008-04-18.el	2008-04-18 13:54:40.000000000 -0700
@@ -39,6 +39,30 @@
   :type 'boolean
   :group 'pp)
 
+(defcustom pp-eval-expression-print-length nil
+  "Value for `print-length' while printing value in `pp-eval-expression'.
+A value of nil means no limit."
+  :group 'pp :type '(choice (const :tag "No Limit" nil) integer))
+
+(defcustom pp-eval-expression-print-level nil
+  "Value for `print-level' while printing value in `pp-eval-expression'.
+A value of nil means no limit."
+  :group 'pp :type '(choice (const :tag "No Limit" nil) integer))
+
+(defvar pp-read-expression-map nil
+  "`read-expression-map' with some Emacs-Lisp key bindings.")
+(unless pp-read-expression-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map "\M-\t" 'lisp-complete-symbol)
+    (define-key map "\t" 'lisp-indent-line)
+    (define-key map "\e\C-q" 'indent-sexp)
+    (define-key map "\e\t" 'lisp-complete-symbol)
+    (define-key map "\e\C-x" 'eval-defun)
+    (define-key map "\e\C-q" 'indent-pp-sexp)
+    ;;(define-key map "\177" 'backward-delete-char-untabify)
+    (set-keymap-parent map minibuffer-local-map)
+    (setq pp-read-expression-map map)))
+
 ;;;###autoload
 (defun pp-to-string (object)
   "Return a string containing the pretty-printed representation of OBJECT.
@@ -97,14 +121,47 @@
   (princ (pp-to-string object) (or stream standard-output)))
 
 ;;;###autoload
-(defun pp-eval-expression (expression)
-  "Evaluate EXPRESSION and pretty-print its value.
-Also add the value to the front of the list in the variable `values'."
+(defun pp-eval-expression (expression &optional insert-value)
+  "Evaluate an Emacs-Lisp expression and pretty-print its value.
+Add the value to the front of the variable `values'.
+With a prefix arg, insert the value into the current buffer at point.
+With no prefix arg:
+ If the value fits on one line (frame width) show it in the echo area.
+ Otherwise, show the value in buffer *Pp Eval Output*.
+
+With a negative prefix arg, if the value is a string, then insert it
+into the buffer without double-quotes (`\"').
+
+This command respects options `pp-eval-expression-print-length',
+`pp-eval-expression-print-level', and
+`eval-expression-debug-on-error'.
+
+Emacs-Lisp mode completion and indentation bindings are in effect."
   (interactive
-   (list (read-from-minibuffer "Eval: " nil read-expression-map t
-			       'read-expression-history)))
+   (list (read-from-minibuffer "Eval: " nil pp-read-expression-map t
+                               'read-expression-history)
+         current-prefix-arg))
   (message "Evaluating...")
+  (if (null eval-expression-debug-on-error)
+      (setq values (cons (eval expression) values))
+    (let ((old-value (make-symbol "t")) new-value)
+      ;; Bind `debug-on-error' to something unique so that we can
+      ;; detect when evaled code changes it.
+      (let ((debug-on-error old-value))
   (setq values (cons (eval expression) values))
+	(setq new-value debug-on-error))
+      ;; If evaled code has changed the value of `debug-on-error',
+      ;; propagate that change to the global binding.
+      (unless (eq old-value new-value) (setq debug-on-error new-value))))
+  (let ((print-length pp-eval-expression-print-length)
+	(print-level pp-eval-expression-print-level))
+    (cond (insert-value
+           (message "Evaluating...done. Value inserted.")
+           (setq insert-value (prefix-numeric-value insert-value))
+           (if (or (not (stringp (car values))) (wholenump insert-value))
+               (pp (car values) (current-buffer))
+             (princ (car values) (current-buffer))))
+          (t
   (let* ((old-show-function temp-buffer-show-function)
 	 ;; Use this function to display the buffer.
 	 ;; This function either decides not to display it at all
@@ -130,14 +187,16 @@
 		       (select-window old-selected)
 		       (message "Evaluating...done.  \
 See buffer *Pp Eval Output*.")))
-		 (message "%s" (buffer-substring (point-min) (point)))
-		 ))))))
+                         (message "%s" (buffer-substring (point-min) (point)))))))))
     (with-output-to-temp-buffer "*Pp Eval Output*"
       (pp (car values))
       (with-current-buffer standard-output
-	(emacs-lisp-mode)
 	(setq buffer-read-only nil)
-	(set (make-local-variable 'font-lock-verbose) nil)))))
+                 (let ((emacs-lisp-mode-hook nil)
+                       (change-major-mode-hook nil))
+                   (emacs-lisp-mode))
+                 (set (make-local-variable 'font-lock-verbose) nil)
+                 (font-lock-fontify-buffer))))))))
 
 ;;;###autoload
 (defun pp-eval-last-sexp (arg)

Diff finished at Fri Apr 18 13:56:06
