emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lisp/emacs-lisp/pp.el [lexbind]


From: Miles Bader
Subject: [Emacs-diffs] Changes to emacs/lisp/emacs-lisp/pp.el [lexbind]
Date: Tue, 06 Jul 2004 06:02:52 -0400

Index: emacs/lisp/emacs-lisp/pp.el
diff -c emacs/lisp/emacs-lisp/pp.el:1.18.4.3 
emacs/lisp/emacs-lisp/pp.el:1.18.4.4
*** emacs/lisp/emacs-lisp/pp.el:1.18.4.3        Thu Apr  1 04:29:04 2004
--- emacs/lisp/emacs-lisp/pp.el Tue Jul  6 09:31:51 2004
***************
*** 50,83 ****
          (let ((print-escape-newlines pp-escape-newlines)
                (print-quoted t))
            (prin1 object (current-buffer)))
!         (goto-char (point-min))
!         (while (not (eobp))
!           ;; (message "%06d" (- (point-max) (point)))
!           (cond
!            ((condition-case err-var
!                 (prog1 t (down-list 1))
!               (error nil))
!             (save-excursion
!               (backward-char 1)
!               (skip-chars-backward "'`#^")
!               (when (and (not (bobp)) (= ?\ (char-before)))
!                 (delete-char -1)
!                 (insert "\n"))))
!            ((condition-case err-var
!                 (prog1 t (up-list 1))
!               (error nil))
!             (while (looking-at "\\s)")
!               (forward-char 1))
!             (delete-region
!              (point)
!              (progn (skip-chars-forward " \t") (point)))
!             (insert ?\n))
!            (t (goto-char (point-max)))))
!         (goto-char (point-min))
!         (indent-sexp)
          (buffer-string))
        (kill-buffer (current-buffer)))))
  
  ;;;###autoload
  (defun pp (object &optional stream)
    "Output the pretty-printed representation of OBJECT, any Lisp object.
--- 50,89 ----
          (let ((print-escape-newlines pp-escape-newlines)
                (print-quoted t))
            (prin1 object (current-buffer)))
!           (pp-buffer)
          (buffer-string))
        (kill-buffer (current-buffer)))))
  
+ (defun pp-buffer ()
+   "Prettify the current buffer with printed representation of a Lisp object."
+   (goto-char (point-min))
+   (while (not (eobp))
+     ;; (message "%06d" (- (point-max) (point)))
+     (cond
+      ((condition-case err-var
+           (prog1 t (down-list 1))
+         (error nil))
+       (save-excursion
+         (backward-char 1)
+         (skip-chars-backward "'`#^")
+         (when (and (not (bobp)) (memq (char-before) '(?\ ?\t ?\n)))
+           (delete-region
+            (point)
+            (progn (skip-chars-backward " \t\n") (point)))
+           (insert "\n"))))
+      ((condition-case err-var
+           (prog1 t (up-list 1))
+         (error nil))
+       (while (looking-at "\\s)")
+         (forward-char 1))
+       (delete-region
+        (point)
+        (progn (skip-chars-forward " \t\n") (point)))
+       (insert ?\n))
+      (t (goto-char (point-max)))))
+   (goto-char (point-min))
+   (indent-sexp))
+ 
  ;;;###autoload
  (defun pp (object &optional stream)
    "Output the pretty-printed representation of OBJECT, any Lisp object.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]