[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/inspector 143668d367 01/93: First commit
From: |
ELPA Syncer |
Subject: |
[elpa] externals/inspector 143668d367 01/93: First commit |
Date: |
Tue, 24 May 2022 18:57:54 -0400 (EDT) |
branch: externals/inspector
commit 143668d367b7c068982dc52ee21dafeb7df3d21f
Author: Mariano Montone <marianomontone@gmail.com>
Commit: Mariano Montone <marianomontone@gmail.com>
First commit
---
.github | 1 +
emacs-inspector.el | 126 +++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 127 insertions(+)
diff --git a/.github b/.github
new file mode 100644
index 0000000000..4977bc62c0
--- /dev/null
+++ b/.github
@@ -0,0 +1 @@
+~
\ No newline at end of file
diff --git a/emacs-inspector.el b/emacs-inspector.el
new file mode 100644
index 0000000000..fb11df8ec7
--- /dev/null
+++ b/emacs-inspector.el
@@ -0,0 +1,126 @@
+;;; emacs-inspector.el --- Inspector for Emacs Lisp objects -*-
lexical-binding: t -*-
+
+(require 'cl)
+
+(cl-defgeneric inspect-object (object))
+
+(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"))
+
+(cl-defmethod inspect-object ((object (eql nil)))
+ (debug "Null"))
+
+(cl-defmethod inspect-object ((object symbol))
+ (debug "Symbol"))
+
+(cl-defmethod inspect-object ((object t))
+ (cond
+ ((eieio-object-p object)
+ (insert "Instance of"))
+ (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))))
+
+(plistp '(as 2 asdf 2))
+(plistp '(as 2 asdf 2 bb))
+(plistp '(as 2 asdf 2 33))
+
+(defun alistp (list)
+ (every (lambda (x)
+ (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))
+
+(cl-defmethod inspect-object ((cons cons))
+ (cond
+ ((and (listp cons) (plistp cons))
+ (insert "Property list: ")
+ (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))))
+ ((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))))))
+
+(cl-defmethod inspect-object ((string string))
+ (insert "String: ")
+ (prin1 string (current-buffer)))
+
+(cl-defmethod inspect-object ((array array))
+ (debug "Inspect array"))
+
+(cl-defmethod inspect-object ((sequence sequence))
+ (debug "Inspect sequence"))
+
+(cl-defmethod inspect-object ((list list))
+ (debug "Inspect list"))
+
+(cl-defmethod inspect-object ((buffer buffer))
+ (debug "Inspect buffer"))
+
+(cl-defmethod inspect-object ((number number))
+ (debug "Inspect number"))
+
+(cl-defmethod inspect-object ((integer integer))
+ (insert "Integer: ")
+ (prin1 integer (current-buffer))
+ (newline)
+ (insert "Char: ")
+ (prin1 (char-to-string integer) (current-buffer)))
+
+(cl-defmethod inspect-object ((hash-table hash-table))
+ (debug "Inspect hash-table"))
+
+(defun emacs-inspector-make-inspector-buffer ()
+ (let ((buffer (get-buffer-create "*emacs-inspector*")))
+ (with-current-buffer buffer
+ (setq buffer-read-only nil)
+ (erase-buffer))
+ buffer))
+
+(defun inspect-expression (exp)
+ (interactive (list (read--expression "Inspect: ")))
+
+ (emacs-inspector-inspect (eval exp)))
+
+(defun emacs-inspector-inspect (object)
+ (let ((buffer (emacs-inspector-make-inspector-buffer)))
+ (with-current-buffer buffer
+ (inspect-object object)
+ (setq buffer-read-only t)
+ (display-buffer buffer))))
+
+(provide 'emacs-inspector)
- [elpa] externals/inspector 5b808173cc 52/93: Slice with [more] button, (continued)
- [elpa] externals/inspector 5b808173cc 52/93: Slice with [more] button, ELPA Syncer, 2022/05/24
- [elpa] externals/inspector bc118aa31a 65/93: Show length of lists, ELPA Syncer, 2022/05/24
- [elpa] externals/inspector 094cd26780 78/93: More tests, ELPA Syncer, 2022/05/24
- [elpa] externals/inspector 902ffcfdfc 79/93: .gitignore, ELPA Syncer, 2022/05/24
- [elpa] externals/inspector e9b4f2e276 85/93: tests: adjustment, ELPA Syncer, 2022/05/24
- [elpa] externals/inspector 8a3d1b8627 88/93: Display some more buffer properties, ELPA Syncer, 2022/05/24
- [elpa] externals/inspector 20260fc077 15/93: Clean inspector history on exit, ELPA Syncer, 2022/05/24
- [elpa] externals/inspector 3e2e8d3476 31/93: Faces, ELPA Syncer, 2022/05/24
- [elpa] externals/inspector b3833deecb 33/93: Better symbol inspector, ELPA Syncer, 2022/05/24
- [elpa] externals/inspector 0fa89e3177 41/93: Make customization group for faces, ELPA Syncer, 2022/05/24
- [elpa] externals/inspector 143668d367 01/93: First commit,
ELPA Syncer <=
- [elpa] externals/inspector 8c083d0ae2 45/93: Update README.md, ELPA Syncer, 2022/05/24
- [elpa] externals/inspector 182c1de703 46/93: Inspect record types, ELPA Syncer, 2022/05/24
- [elpa] externals/inspector c8b15291cc 57/93: Tweeks for inspector buffer display, ELPA Syncer, 2022/05/24
- [elpa] externals/inspector 584ea2b3e3 62/93: README: demo video, ELPA Syncer, 2022/05/24
- [elpa] externals/inspector b4ff75dda1 61/93: Paginate hash-table inspection, ELPA Syncer, 2022/05/24
- [elpa] externals/inspector 0304d42ed1 63/93: Bind 'n' and 'p' to forward and backward button for faster navigation, ELPA Syncer, 2022/05/24
- [elpa] externals/inspector 0f444b2b72 64/93: README: navigate buttons with 'n' and 'p', ELPA Syncer, 2022/05/24
- [elpa] externals/inspector 84b0f72a5c 74/93: inspector-tests, ELPA Syncer, 2022/05/24