emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/inspector f005f979f2 28/93: hash-table inspector


From: ELPA Syncer
Subject: [elpa] externals/inspector f005f979f2 28/93: hash-table inspector
Date: Tue, 24 May 2022 18:57:56 -0400 (EDT)

branch: externals/inspector
commit f005f979f23f3b5597a1e935e72817bbc8e85e33
Author: Mariano Montone <marianomontone@gmail.com>
Commit: Mariano Montone <marianomontone@gmail.com>

    hash-table inspector
---
 inspector.el | 34 +++++++++++++++++++++++++++++-----
 1 file changed, 29 insertions(+), 5 deletions(-)

diff --git a/inspector.el b/inspector.el
index c28899478d..a2c1573e33 100644
--- a/inspector.el
+++ b/inspector.el
@@ -3,8 +3,8 @@
 ;; Copyright (C) 2021 Mariano Montone
 
 ;; Author: Mariano Montone <marianomontone@gmail.com>
-;; URL: https://github.com/mmontone/slime-doc-contribs
-;; Keywords: help, lisp, slime, common-lisp
+;; URL: https://github.com/mmontone/emacs-inspector
+;; Keywords: debugging, tool, emacs-lisp, development
 ;; Version: 0.1
 ;; Package-Requires: ((emacs "25"))
 
@@ -152,12 +152,22 @@
       (newline)))
    (t (error "Cannot inspect object: %s" object))))
 
+(defcustom inspector-end-column 80
+  "Control print truncation size in inspector."
+  :type 'integer
+  :group 'inspector)
+
+(defun inspector--print-truncated (object &optional end-column)
+  "Print OBJECT truncated.  END-COLUMN controls the truncation."
+  (truncate-string-to-width (prin1-to-string object)
+                           (or end-column inspector-end-column)
+                           nil nil t))
+
 (defun inspector--insert-inspect-button (object &optional label)
   "Insert button for inspecting OBJECT.
 If LABEL has a value, then it is used as button label.  Otherwise, button 
label is the printed representation of OBJECT."
   (insert-button (or (and label (princ-to-string label))
-                     (truncate-string-to-width
-                     (prin1-to-string object) 80 nil nil t))
+                     (inspector--print-truncated object))
                  'action (lambda (btn)
                           (ignore btn)
                            (inspector-inspect object t))
@@ -224,7 +234,21 @@ If LABEL has a value, then it is used as button label.  
Otherwise, button label
   (princ (char-to-string integer) (current-buffer)))
 
 (cl-defmethod inspect-object ((hash-table hash-table))
-  (debug "Inspect hash-table"))
+  "Render inspector buffer for HASH-TABLEs."
+  (inspector--insert-title "Hash table")
+  (insert (inspector--print-truncated hash-table))
+  (newline)
+  (inspector--insert-property "Size")
+  (insert (princ-to-string (hash-table-size hash-table)))
+  (newline 2)
+  (inspector--insert-property "Values")
+  (newline)
+  (maphash (lambda (key value)
+            (inspector--insert-inspect-button key)
+            (insert ": ")
+            (inspector--insert-inspect-button value)
+            (newline))
+          hash-table))
 
 (defun inspector-make-inspector-buffer ()
   "Create an inspector buffer."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]