emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r107105: lisp/emacs-lisp/pp.el: Do no


From: Juanma Barranquero
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r107105: lisp/emacs-lisp/pp.el: Do not reimplement common macros; use `looking-at-p'.
Date: Sun, 05 Feb 2012 03:09:35 +0100
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 107105
committer: Juanma Barranquero <address@hidden>
branch nick: trunk
timestamp: Sun 2012-02-05 03:09:35 +0100
message:
  lisp/emacs-lisp/pp.el: Do not reimplement common macros; use `looking-at-p'.
  
  (pp-to-string): Use `with-temp-buffer'.
  (pp-buffer): Use `ignore-errors', `looking-at-p'.
  (pp-last-sexp): Use `looking-at-p'.
modified:
  lisp/ChangeLog
  lisp/emacs-lisp/pp.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2012-02-04 22:04:12 +0000
+++ b/lisp/ChangeLog    2012-02-05 02:09:35 +0000
@@ -1,3 +1,9 @@
+2012-02-05  Juanma Barranquero  <address@hidden>
+
+       * emacs-lisp/pp.el (pp-to-string): Use `with-temp-buffer'.
+       (pp-buffer): Use `ignore-errors', `looking-at-p'.
+       (pp-last-sexp): Use `looking-at-p'.
+
 2012-02-04  Glenn Morris  <address@hidden>
 
        * files.el (revert-buffer):

=== modified file 'lisp/emacs-lisp/pp.el'
--- a/lisp/emacs-lisp/pp.el     2012-01-19 07:21:25 +0000
+++ b/lisp/emacs-lisp/pp.el     2012-02-05 02:09:35 +0000
@@ -41,17 +41,14 @@
   "Return a string containing the pretty-printed representation of OBJECT.
 OBJECT can be any Lisp object.  Quoting characters are used as needed
 to make output that `read' can handle, whenever this is possible."
-  (with-current-buffer (generate-new-buffer " pp-to-string")
-    (unwind-protect
-       (progn
-         (lisp-mode-variables nil)
-         (set-syntax-table emacs-lisp-mode-syntax-table)
-         (let ((print-escape-newlines pp-escape-newlines)
-               (print-quoted t))
-           (prin1 object (current-buffer)))
-          (pp-buffer)
-         (buffer-string))
-      (kill-buffer (current-buffer)))))
+  (with-temp-buffer
+    (lisp-mode-variables nil)
+    (set-syntax-table emacs-lisp-mode-syntax-table)
+    (let ((print-escape-newlines pp-escape-newlines)
+          (print-quoted t))
+      (prin1 object (current-buffer)))
+    (pp-buffer)
+    (buffer-string)))
 
 ;;;###autoload
 (defun pp-buffer ()
@@ -60,9 +57,7 @@
   (while (not (eobp))
     ;; (message "%06d" (- (point-max) (point)))
     (cond
-     ((condition-case err-var
-          (prog1 t (down-list 1))
-        (error nil))
+     ((ignore-errors (down-list 1) t)
       (save-excursion
         (backward-char 1)
         (skip-chars-backward "'`#^")
@@ -71,10 +66,8 @@
            (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)")
+     ((ignore-errors (up-list 1) t)
+      (while (looking-at-p "\\s)")
         (forward-char 1))
       (delete-region
        (point)
@@ -154,7 +147,7 @@
     (save-excursion
       (forward-sexp -1)
       ;; If first line is commented, ignore all leading comments:
-      (if (save-excursion (beginning-of-line) (looking-at "[ \t]*;"))
+      (if (save-excursion (beginning-of-line) (looking-at-p "[ \t]*;"))
          (progn
            (setq exp (buffer-substring (point) pt))
            (while (string-match "\n[ \t]*;+" exp start)


reply via email to

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