[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/inspector 4a8d46f01e 02/93: Class instance inspector
From: |
ELPA Syncer |
Subject: |
[elpa] externals/inspector 4a8d46f01e 02/93: Class instance inspector |
Date: |
Tue, 24 May 2022 18:57:54 -0400 (EDT) |
branch: externals/inspector
commit 4a8d46f01e2e4c2bd7acb44b3eb2b60558f21d70
Author: Mariano Montone <marianomontone@gmail.com>
Commit: Mariano Montone <marianomontone@gmail.com>
Class instance inspector
---
emacs-inspector.el | 64 ++++++++++++++++++++++++++++++------------------------
1 file changed, 36 insertions(+), 28 deletions(-)
diff --git a/emacs-inspector.el b/emacs-inspector.el
index fb11df8ec7..a2da8f380f 100644
--- a/emacs-inspector.el
+++ b/emacs-inspector.el
@@ -7,9 +7,6 @@
(cl-defmethod inspect-object ((class (subclass eieio-default-superclass)))
(debug "Inspect class %s" class))
-(cl-defmethod inspect-object ((object eieio-default-superclass))
- (debug "Class insntace"))
-
(cl-defmethod inspect-object ((object (eql t)))
(debug "True"))
@@ -22,16 +19,27 @@
(cl-defmethod inspect-object ((object t))
(cond
((eieio-object-p object)
- (insert "Instance of"))
+ (insert "Instance of ")
+ (emacs-inspector--insert-inspect-button
+ (class-of object)
+ (prin1-to-string (eieio-class-name (eieio-object-class object))))
+ (newline 2)
+ (insert "Slots:")
+ (newline)
+ (dolist (slot (eieio-class-slots (eieio-object-class object)))
+ (insert (format "%s: " (cl--slot-descriptor-name slot)))
+ (emacs-inspector--insert-inspect-button
+ (slot-value object (cl--slot-descriptor-name slot)))
+ (newline)))
(t (error "Cannot inspect object"))))
(defun plistp (list)
(let ((expected t))
(and (evenp (length list))
- (every (lambda (x)
- (setq expected (if (eql expected t) 'symbol t))
- (typep x expected))
- list))))
+ (every (lambda (x)
+ (setq expected (if (eql expected t) 'symbol t))
+ (typep x expected))
+ list))))
(plistp '(as 2 asdf 2))
(plistp '(as 2 asdf 2 bb))
@@ -39,18 +47,18 @@
(defun alistp (list)
(every (lambda (x)
- (and (consp x)
- (symbolp (car x))))
- list))
+ (and (consp x)
+ (symbolp (car x))))
+ list))
(alistp '(a b c))
(alistp '((a . 22) (b . "foo")))
-(defun emacs-inspector--insert-inspect-button (object)
- (insert-button (prin1-to-string object)
- 'action (lambda (btn)
- (emacs-inspector-inspect object))
- 'follow-link t))
+(defun emacs-inspector--insert-inspect-button (object &optional label)
+ (insert-button (or label (prin1-to-string object))
+ 'action (lambda (btn)
+ (emacs-inspector-inspect object))
+ 'follow-link t))
(cl-defmethod inspect-object ((cons cons))
(cond
@@ -59,21 +67,21 @@
(newline)
(let ((plist (copy-list cons)))
(while plist
- (let ((key (pop plist)))
- (emacs-inspector--insert-inspect-button key))
- (insert ": ")
- (let ((value (pop plist)))
- (emacs-inspector--insert-inspect-button value))
- (newline))))
+ (let ((key (pop plist)))
+ (emacs-inspector--insert-inspect-button key))
+ (insert ": ")
+ (let ((value (pop plist)))
+ (emacs-inspector--insert-inspect-button value))
+ (newline))))
((listp cons)
(insert "Proper list:")
(newline)
(let ((i 0))
(dolist (elem cons)
- (insert (format "%d: " i))
- (emacs-inspector--insert-inspect-button elem)
- (newline)
- (incf i))))))
+ (insert (format "%d: " i))
+ (emacs-inspector--insert-inspect-button elem)
+ (newline)
+ (incf i))))))
(cl-defmethod inspect-object ((string string))
(insert "String: ")
@@ -113,7 +121,7 @@
(defun inspect-expression (exp)
(interactive (list (read--expression "Inspect: ")))
-
+
(emacs-inspector-inspect (eval exp)))
(defun emacs-inspector-inspect (object)
@@ -122,5 +130,5 @@
(inspect-object object)
(setq buffer-read-only t)
(display-buffer buffer))))
-
+
(provide 'emacs-inspector)
- [elpa] branch externals/inspector created (now 6fadd6df9f), ELPA Syncer, 2022/05/24
- [elpa] externals/inspector 4a8d46f01e 02/93: Class instance inspector,
ELPA Syncer <=
- [elpa] externals/inspector 16f833d3bb 05/93: Housekeeping, ELPA Syncer, 2022/05/24
- [elpa] externals/inspector 8791b90885 07/93: Housekeeping, ELPA Syncer, 2022/05/24
- [elpa] externals/inspector b609289074 20/93: Housekeeping, ELPA Syncer, 2022/05/24
- [elpa] externals/inspector f8d2e8edef 23/93: Update README.md, ELPA Syncer, 2022/05/24
- [elpa] externals/inspector e504625e80 26/93: Inspect structures, ELPA Syncer, 2022/05/24
- [elpa] externals/inspector 440bd7a530 17/93: Housekeeping, ELPA Syncer, 2022/05/24
- [elpa] externals/inspector d7f85a9c25 16/93: Inspect array, ELPA Syncer, 2022/05/24
- [elpa] externals/inspector cfa57e310b 18/93: Better presentation functions, ELPA Syncer, 2022/05/24
- [elpa] externals/inspector 4d409a6715 32/93: Evaluate in menu, ELPA Syncer, 2022/05/24
- [elpa] externals/inspector edbd5c1318 37/93: Association list inspector and custom var to toggle specialized, ELPA Syncer, 2022/05/24