mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-10 16:20:17 -08:00
* lisp/emacs-lisp/eieio.el: Prettier object pretty-printing.
(eieio-override-prin1): Don't quote kewords and booleans. (object-write) <eieio-default-superclass>: Don't put closing parens on new line, avoid needless empty lines, align values that are objects with the slot keyword (instead of beginning on the same line). (eieio-list-prin1): Align value with slot keyword; increase eieio-print-depth before printing members of the list. Fixes: debbugs:13115
This commit is contained in:
parent
030f4af55b
commit
69e1c203e9
2 changed files with 35 additions and 17 deletions
|
|
@ -1,3 +1,13 @@
|
||||||
|
2012-12-12 Jonas Bernoulli <jonas@bernoul.li>
|
||||||
|
|
||||||
|
* lisp/emacs-lisp/eieio.el: Prettier object pretty-printing (bug#13115).
|
||||||
|
(eieio-override-prin1): Don't quote kewords and booleans.
|
||||||
|
(object-write) <eieio-default-superclass>: Don't put closing parens
|
||||||
|
on new line, avoid needless empty lines, align values that are objects
|
||||||
|
with the slot keyword (instead of beginning on the same line).
|
||||||
|
(eieio-list-prin1): Align value with slot keyword; increase
|
||||||
|
eieio-print-depth before printing members of the list.
|
||||||
|
|
||||||
2012-12-11 Stefan Monnier <monnier@iro.umontreal.ca>
|
2012-12-11 Stefan Monnier <monnier@iro.umontreal.ca>
|
||||||
|
|
||||||
* mail/emacsbug.el (report-emacs-bug): Move the intangible text to
|
* mail/emacsbug.el (report-emacs-bug): Move the intangible text to
|
||||||
|
|
|
||||||
|
|
@ -2850,28 +2850,36 @@ this object."
|
||||||
(v (eieio-oref this (car publa)))
|
(v (eieio-oref this (car publa)))
|
||||||
)
|
)
|
||||||
(unless (or (not i) (equal v (car publd)))
|
(unless (or (not i) (equal v (car publd)))
|
||||||
|
(unless (bolp)
|
||||||
|
(princ "\n"))
|
||||||
(princ (make-string (* eieio-print-depth 2) ? ))
|
(princ (make-string (* eieio-print-depth 2) ? ))
|
||||||
(princ (symbol-name i))
|
(princ (symbol-name i))
|
||||||
(princ " ")
|
|
||||||
(if (car publp)
|
(if (car publp)
|
||||||
;; Use our public printer
|
;; Use our public printer
|
||||||
(funcall (car publp) v)
|
(progn
|
||||||
|
(princ " ")
|
||||||
|
(funcall (car publp) v))
|
||||||
;; Use our generic override prin1 function.
|
;; Use our generic override prin1 function.
|
||||||
(eieio-override-prin1 v))
|
(princ (if (or (eieio-object-p v)
|
||||||
(princ "\n"))))
|
(eieio-object-p (car-safe v)))
|
||||||
|
"\n" " "))
|
||||||
|
(eieio-override-prin1 v)))))
|
||||||
(setq publa (cdr publa) publd (cdr publd)
|
(setq publa (cdr publa) publd (cdr publd)
|
||||||
publp (cdr publp)))
|
publp (cdr publp))))
|
||||||
(princ (make-string (* eieio-print-depth 2) ? )))
|
(princ ")")
|
||||||
(princ ")\n")))
|
(when (= eieio-print-depth 0)
|
||||||
|
(princ "\n"))))
|
||||||
|
|
||||||
(defun eieio-override-prin1 (thing)
|
(defun eieio-override-prin1 (thing)
|
||||||
"Perform a `prin1' on THING taking advantage of object knowledge."
|
"Perform a `prin1' on THING taking advantage of object knowledge."
|
||||||
(cond ((eieio-object-p thing)
|
(cond ((eieio-object-p thing)
|
||||||
(object-write thing))
|
(object-write thing))
|
||||||
((listp thing)
|
((consp thing)
|
||||||
(eieio-list-prin1 thing))
|
(eieio-list-prin1 thing))
|
||||||
((class-p thing)
|
((class-p thing)
|
||||||
(princ (class-name thing)))
|
(princ (class-name thing)))
|
||||||
|
((or (keywordp thing) (booleanp thing))
|
||||||
|
(prin1 thing))
|
||||||
((symbolp thing)
|
((symbolp thing)
|
||||||
(princ (concat "'" (symbol-name thing))))
|
(princ (concat "'" (symbol-name thing))))
|
||||||
(t (prin1 thing))))
|
(t (prin1 thing))))
|
||||||
|
|
@ -2882,16 +2890,16 @@ this object."
|
||||||
(progn
|
(progn
|
||||||
(princ "'")
|
(princ "'")
|
||||||
(prin1 list))
|
(prin1 list))
|
||||||
(princ "(list ")
|
|
||||||
(if (eieio-object-p (car list)) (princ "\n "))
|
|
||||||
(while list
|
|
||||||
(if (eieio-object-p (car list))
|
|
||||||
(object-write (car list))
|
|
||||||
(princ "'")
|
|
||||||
(prin1 (car list)))
|
|
||||||
(princ " ")
|
|
||||||
(setq list (cdr list)))
|
|
||||||
(princ (make-string (* eieio-print-depth 2) ? ))
|
(princ (make-string (* eieio-print-depth 2) ? ))
|
||||||
|
(princ "(list")
|
||||||
|
(let ((eieio-print-depth (1+ eieio-print-depth)))
|
||||||
|
(while list
|
||||||
|
(princ "\n")
|
||||||
|
(if (eieio-object-p (car list))
|
||||||
|
(object-write (car list))
|
||||||
|
(princ (make-string (* eieio-print-depth 2) ? ))
|
||||||
|
(eieio-override-prin1 (car list)))
|
||||||
|
(setq list (cdr list))))
|
||||||
(princ ")")))
|
(princ ")")))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue