aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuanma Barranquero2012-02-05 03:09:35 +0100
committerJuanma Barranquero2012-02-05 03:09:35 +0100
commit0696d25514565119ee268fa8d9c10b2b5a561b4f (patch)
treebf86432044bfb37d65fe469f003ab0626ae69c7b
parent7eb21b49ef9e58fdfd7635cf7e0a6d295785203c (diff)
downloademacs-0696d25514565119ee268fa8d9c10b2b5a561b4f.tar.gz
emacs-0696d25514565119ee268fa8d9c10b2b5a561b4f.zip
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'.
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/emacs-lisp/pp.el31
2 files changed, 18 insertions, 19 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 198b7c53322..8db7b4b1b89 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
12012-02-05 Juanma Barranquero <lekktu@gmail.com>
2
3 * emacs-lisp/pp.el (pp-to-string): Use `with-temp-buffer'.
4 (pp-buffer): Use `ignore-errors', `looking-at-p'.
5 (pp-last-sexp): Use `looking-at-p'.
6
12012-02-04 Glenn Morris <rgm@gnu.org> 72012-02-04 Glenn Morris <rgm@gnu.org>
2 8
3 * files.el (revert-buffer): 9 * files.el (revert-buffer):
diff --git a/lisp/emacs-lisp/pp.el b/lisp/emacs-lisp/pp.el
index c795d985b7e..48e0d6d6a21 100644
--- a/lisp/emacs-lisp/pp.el
+++ b/lisp/emacs-lisp/pp.el
@@ -41,17 +41,14 @@
41 "Return a string containing the pretty-printed representation of OBJECT. 41 "Return a string containing the pretty-printed representation of OBJECT.
42OBJECT can be any Lisp object. Quoting characters are used as needed 42OBJECT can be any Lisp object. Quoting characters are used as needed
43to make output that `read' can handle, whenever this is possible." 43to make output that `read' can handle, whenever this is possible."
44 (with-current-buffer (generate-new-buffer " pp-to-string") 44 (with-temp-buffer
45 (unwind-protect 45 (lisp-mode-variables nil)
46 (progn 46 (set-syntax-table emacs-lisp-mode-syntax-table)
47 (lisp-mode-variables nil) 47 (let ((print-escape-newlines pp-escape-newlines)
48 (set-syntax-table emacs-lisp-mode-syntax-table) 48 (print-quoted t))
49 (let ((print-escape-newlines pp-escape-newlines) 49 (prin1 object (current-buffer)))
50 (print-quoted t)) 50 (pp-buffer)
51 (prin1 object (current-buffer))) 51 (buffer-string)))
52 (pp-buffer)
53 (buffer-string))
54 (kill-buffer (current-buffer)))))
55 52
56;;;###autoload 53;;;###autoload
57(defun pp-buffer () 54(defun pp-buffer ()
@@ -60,9 +57,7 @@ to make output that `read' can handle, whenever this is possible."
60 (while (not (eobp)) 57 (while (not (eobp))
61 ;; (message "%06d" (- (point-max) (point))) 58 ;; (message "%06d" (- (point-max) (point)))
62 (cond 59 (cond
63 ((condition-case err-var 60 ((ignore-errors (down-list 1) t)
64 (prog1 t (down-list 1))
65 (error nil))
66 (save-excursion 61 (save-excursion
67 (backward-char 1) 62 (backward-char 1)
68 (skip-chars-backward "'`#^") 63 (skip-chars-backward "'`#^")
@@ -71,10 +66,8 @@ to make output that `read' can handle, whenever this is possible."
71 (point) 66 (point)
72 (progn (skip-chars-backward " \t\n") (point))) 67 (progn (skip-chars-backward " \t\n") (point)))
73 (insert "\n")))) 68 (insert "\n"))))
74 ((condition-case err-var 69 ((ignore-errors (up-list 1) t)
75 (prog1 t (up-list 1)) 70 (while (looking-at-p "\\s)")
76 (error nil))
77 (while (looking-at "\\s)")
78 (forward-char 1)) 71 (forward-char 1))
79 (delete-region 72 (delete-region
80 (point) 73 (point)
@@ -154,7 +147,7 @@ Also add the value to the front of the list in the variable `values'."
154 (save-excursion 147 (save-excursion
155 (forward-sexp -1) 148 (forward-sexp -1)
156 ;; If first line is commented, ignore all leading comments: 149 ;; If first line is commented, ignore all leading comments:
157 (if (save-excursion (beginning-of-line) (looking-at "[ \t]*;")) 150 (if (save-excursion (beginning-of-line) (looking-at-p "[ \t]*;"))
158 (progn 151 (progn
159 (setq exp (buffer-substring (point) pt)) 152 (setq exp (buffer-substring (point) pt))
160 (while (string-match "\n[ \t]*;+" exp start) 153 (while (string-match "\n[ \t]*;+" exp start)