[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/inspector 130c43c6b6 19/39: tree-inspector: records
From: |
ELPA Syncer |
Subject: |
[elpa] externals/inspector 130c43c6b6 19/39: tree-inspector: records |
Date: |
Sat, 10 Sep 2022 17:57:47 -0400 (EDT) |
branch: externals/inspector
commit 130c43c6b6655d4488b1ab61e40a653e6459ce1f
Author: Mariano Montone <marianomontone@gmail.com>
Commit: Mariano Montone <marianomontone@gmail.com>
tree-inspector: records
---
tree-inspector-tests.el | 48 +++++++++++++++++++++++-------------------------
tree-inspector.el | 22 +++++++++++++++++++---
2 files changed, 42 insertions(+), 28 deletions(-)
diff --git a/tree-inspector-tests.el b/tree-inspector-tests.el
index 6f9bf8595d..2479f395a0 100644
--- a/tree-inspector-tests.el
+++ b/tree-inspector-tests.el
@@ -160,38 +160,36 @@
(should (cl-search "44" buffer-string))))
(ert-deftest inspector-tests--inspect-hash-table-test ()
- (inspector-inspect (let ((table (make-hash-table)))
- (puthash :a 22 table)
- (puthash :b "foo" table)
- table))
- (let ((buffer-string (buffer-string)))
- (should (cl-search "hash-table" buffer-string))
- (should (cl-search "a" buffer-string))
- (should (cl-search "22" buffer-string))
- (should (cl-search "b" buffer-string))
- (should (cl-search "foo" buffer-string)))
- (inspector-quit))
+ (let ((table (make-hash-table)))
+ (puthash :a 22 table)
+ (puthash :b "foo" table)
+
+ (tree-inspector-tests--with-tree-inspector-contents
+ (buffer-string table)
+ (should (cl-search "hash-table" buffer-string))
+ (should (cl-search "a" buffer-string))
+ (should (cl-search "22" buffer-string))
+ (should (cl-search "b" buffer-string))
+ (should (cl-search "foo" buffer-string)))))
(ert-deftest inspector-tests--inspect-function-test ()
- (inspector-inspect (symbol-function 'car))
- (let ((buffer-string (buffer-string)))
- (should (cl-search "function" buffer-string))
- (should (cl-search "car" buffer-string)))
- (inspector-quit))
+ (tree-inspector-tests--with-tree-inspector-contents
+ (buffer-string (symbol-function 'print))
+ (should (cl-search "subr" buffer-string))
+ (should (cl-search "print" buffer-string))))
-(defun inspector-tests--factorial (integer)
+(defun tree-inspector-tests--factorial (integer)
"Compute factorial of INTEGER."
(if (= 1 integer) 1
- (* integer (inspector-tests--factorial (1- integer)))))
+ (* integer (tree-inspector-tests--factorial (1- integer)))))
-(ert-deftest inspector-tests--inspect-compiled-function-test ()
- (inspector-inspect (byte-compile 'inspector-tests--factorial))
- (let ((buffer-string (buffer-string)))
- (should (cl-search "function" buffer-string)))
- (inspector-quit))
+(ert-deftest tree-inspector-tests--inspect-compiled-function-test ()
+ (tree-inspector-tests--with-tree-inspector-contents
+ (buffer-string (byte-compile 'inspector-tests--factorial))
+ (should (cl-search "factorial" buffer-string))))
-(ert-deftest inspector-tests--inspect-record-test ()
- (inspector-inspect (record 'foo 23 [bar baz] "rats"))
+(ert-deftest tree-inspector-tests--inspect-record-test ()
+ (tree-inspector-inspect (record 'foo 23 [bar baz] "rats"))
(let ((buffer-string (buffer-string)))
(should (cl-search "record" buffer-string))
(should (cl-search "foo" buffer-string))
diff --git a/tree-inspector.el b/tree-inspector.el
index 62e1002d63..f8ae574ee5 100644
--- a/tree-inspector.el
+++ b/tree-inspector.el
@@ -71,12 +71,12 @@ in a format understood by `kbd'. Commands a names of Lisp
functions."
:type 'boolean
:group 'inspector)
-(defcustom tree-inspector-indent-unit " | "
+(defcustom tree-inspector-indent-unit " | "
"Symbol to indent directories when the parent is not the last child."
:group 'tree-inspector
:type 'string)
-(defcustom tree-inspector-indent-last-unit " "
+(defcustom tree-inspector-indent-last-unit " "
"Symbol to indent directories when the parent is the last child of its
parent."
:group 'tree-inspector
:type 'string)
@@ -221,7 +221,23 @@ in a format understood by `kbd'. Commands a names of Lisp
functions."
(:documentation "Create treeview node for Emacs Lisp OBJECT."))
(cl-defmethod tree-inspector--make-node ((object t))
- (error "Implement tree-inspector--make-node for %s" (type-of object)))
+ (cond
+ ((recordp object)
+ (let ((node (treeview-new-node)))
+ (treeview-set-node-name node (tree-inspector--print-object object))
+ (let (children)
+ (cl-do ((i 1 (cl-incf i)))
+ ((= i (length object)))
+ (push (tree-inspector--make-node (aref object i)) children))
+ (tree-inspector--set-node-children node children)
+ node)))
+ (t
+ (error "Implement tree-inspector--make-node for %s" (type-of object)))))
+
+(cl-defmethod tree-inspector--make-node ((object subr))
+ (let ((node (treeview-new-node)))
+ (treeview-set-node-name node (prin1-to-string object))
+ node))
(cl-defmethod tree-inspector--make-node ((object (eql t)))
(let ((node (treeview-new-node)))
- [elpa] externals/inspector updated (f04c60a5d3 -> 0b213e931c), ELPA Syncer, 2022/09/10
- [elpa] externals/inspector e2e56201a0 01/39: Starting a tree-inspector with treeview, ELPA Syncer, 2022/09/10
- [elpa] externals/inspector 06eb60bcff 03/39: tree-inspector: indentation, ELPA Syncer, 2022/09/10
- [elpa] externals/inspector 56579dae8a 05/39: tree-inspector: hash-table inspector, ELPA Syncer, 2022/09/10
- [elpa] externals/inspector 838b08706a 02/39: tree-inspector work, ELPA Syncer, 2022/09/10
- [elpa] externals/inspector faf590dded 06/39: tree-inspector: alist inspector, ELPA Syncer, 2022/09/10
- [elpa] externals/inspector 068b754a0a 07/39: tree-inspector: vectors, ELPA Syncer, 2022/09/10
- [elpa] externals/inspector d43bb09ae9 11/39: tree-inspector: housekeeping, ELPA Syncer, 2022/09/10
- [elpa] externals/inspector 4066d7b441 13/39: Starting some tree-inspector tests, ELPA Syncer, 2022/09/10
- [elpa] externals/inspector 8b000e4e4e 15/39: tree-inspector: tests, ELPA Syncer, 2022/09/10
- [elpa] externals/inspector 130c43c6b6 19/39: tree-inspector: records,
ELPA Syncer <=
- [elpa] externals/inspector 394fb22811 09/39: ..., ELPA Syncer, 2022/09/10
- [elpa] externals/inspector 98d3d56723 10/39: tree-inspector: provide, ELPA Syncer, 2022/09/10
- [elpa] externals/inspector 236ef196a0 24/39: tree-inspector: fixes, ELPA Syncer, 2022/09/10
- [elpa] externals/inspector fc9712651c 36/39: More complete package commentary, ELPA Syncer, 2022/09/10
- [elpa] externals/inspector 5828d49207 21/39: tree-inspector: inspect-last-sexp, ELPA Syncer, 2022/09/10
- [elpa] externals/inspector 1f1469ec9d 22/39: tree-inspector: buffers, windows, frames, ELPA Syncer, 2022/09/10
- [elpa] externals/inspector 49586fc18b 23/39: tree-inspector: buffers, windows, overlays, frames, ELPA Syncer, 2022/09/10
- [elpa] externals/inspector 1ea746c8e0 27/39: tree-inspector: better window inspector, ELPA Syncer, 2022/09/10
- [elpa] externals/inspector 019019c3b5 30/39: tree-inspector: housekeeping, ELPA Syncer, 2022/09/10
- [elpa] externals/inspector 7f6530dc2d 14/39: inspector-tests: command for running tests, ELPA Syncer, 2022/09/10