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

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

[elpa] externals/inspector 30d739e108 53/93: Slice arrays


From: ELPA Syncer
Subject: [elpa] externals/inspector 30d739e108 53/93: Slice arrays
Date: Tue, 24 May 2022 18:57:59 -0400 (EDT)

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

    Slice arrays
---
 inspector.el | 70 +++++++++++++++++++++++++++++++++++++-----------------------
 1 file changed, 43 insertions(+), 27 deletions(-)

diff --git a/inspector.el b/inspector.el
index ac65e192d7..4ebba96db3 100644
--- a/inspector.el
+++ b/inspector.el
@@ -178,15 +178,15 @@ If LABEL has a value, then it is used as button label.  
Otherwise, button label
    (lambda (slice cont)
      (funcall function slice cont)
      (insert-button "[More]"
-                   'action (let ((pos (point)))
-                             (lambda (btn)
-                               (ignore btn)
-                               (setq buffer-read-only nil)
-                               (goto-char pos)
-                               (delete-char (length "[More]"))
-                               (funcall cont)
-                               (setq buffer-read-only nil)))
-                       'follow-link t))))
+                    'action (let ((pos (point)))
+                              (lambda (btn)
+                                (ignore btn)
+                                (setq buffer-read-only nil)
+                                (goto-char pos)
+                                (delete-char (length "[More]"))
+                                (funcall cont)
+                                (setq buffer-read-only nil)))
+                    'follow-link t))))
 
 (cl-defgeneric inspect-object (object)
   "Main generic interface for filling inspector buffers for the different 
types of OBJECT.")
@@ -299,26 +299,33 @@ If LABEL has a value, then it is used as button label.  
Otherwise, button label
    ((and inspector-use-specialized-inspectors-for-lists
          (inspector--alistp cons))
     (inspector--insert-title "Association list")
-    (dolist (cons cons)
-      (insert "(")
-      (inspector--insert-inspect-button (car cons))
-      (insert " . ")
-      (inspector--insert-inspect-button (cdr cons))
-      (insert ")")
-      (newline)))
+    (let ((i 0))
+      (inspector--do-with-slicer-and-more-button
+       (lambda ()
+         (when (< i (length cons))
+           (subseq cons i (min (incf i inspector-slice-size)
+                               (length cons)))))
+       (lambda (slice cont)
+         (dolist (cons slice)
+           (insert "(")
+           (inspector--insert-inspect-button (car cons))
+           (insert " . ")
+           (inspector--insert-inspect-button (cdr cons))
+           (insert ")")
+           (newline))))))
    ((inspector--proper-list-p cons)
     (inspector--insert-title "Proper list")
     (let ((i 0)
-         (j 0))
+          (j 0))
       (inspector--do-with-slicer-and-more-button
        (lambda ()
-        (when (< i (length cons))
-          (subseq cons i (min (incf i inspector-slice-size)
-                              (length cons)))))
+         (when (< i (length cons))
+           (subseq cons i (min (incf i inspector-slice-size)
+                               (length cons)))))
        (lambda (slice cont)
-        (dolist (elem slice)
+         (dolist (elem slice)
            (insert (format "%d: " j))
-          (incf j)
+           (incf j)
            (inspector--insert-inspect-button elem)
            (newline))))))
    (t ;; It is a cons cell
@@ -335,13 +342,22 @@ If LABEL has a value, then it is used as button label.  
Otherwise, button label
 
 (cl-defmethod inspect-object ((array array))
   (inspector--insert-title (inspector--princ-to-string (type-of array)))
-  (let ((length (length array)))
+  (let ((length (length array))
+        (i 0))
     (insert (format "Length: %s" length))
     (newline 2)
-    (dotimes (i length)
-      (insert (format "%d: " i))
-      (inspector--insert-inspect-button (aref array i))
-      (newline))))
+    (let ((i 0))
+      (inspector--do-with-slicer-and-more-button
+       (lambda ()
+         (when (< i length)
+           (cons i (1- (min (incf i inspector-slice-size)
+                            length)))))
+       (lambda (slice cont)
+         (cl-loop for k from (car slice) to (cdr slice)
+                  do
+                  (insert (format "%d: " k))
+                  (inspector--insert-inspect-button (aref array k))
+                  (newline)))))))
 
 (cl-defmethod inspect-object ((buffer buffer))
   (inspector--insert-title (prin1-to-string buffer))



reply via email to

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