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

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

[elpa] externals/inspector 7574ca3ff9 51/93: Slice sequences


From: ELPA Syncer
Subject: [elpa] externals/inspector 7574ca3ff9 51/93: Slice sequences
Date: Tue, 24 May 2022 18:57:59 -0400 (EDT)

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

    Slice sequences
---
 inspector.el | 40 ++++++++++++++++++++++++++++++++++------
 1 file changed, 34 insertions(+), 6 deletions(-)

diff --git a/inspector.el b/inspector.el
index 0e0ebef2c3..37e32d7d68 100644
--- a/inspector.el
+++ b/inspector.el
@@ -119,6 +119,11 @@
   :type 'boolean
   :group 'inspector)
 
+(defcustom inspector-slice-size 100
+  "Size of sequence slices in inspector."
+  :type 'integer
+  :group 'inspector)
+
 ;;-------- Inspector code -------------------
 
 (defvar-local inspector-history nil
@@ -162,6 +167,11 @@ If LABEL has a value, then it is used as button label.  
Otherwise, button label
                            (inspector-inspect object t))
                  'follow-link t))
 
+(defun inspector--do-with-slicer (slicer function)
+  (let ((slice (funcall slicer)))
+    (when slice
+      (funcall function slice (lambda () (inspector--do-with-slicer slicer 
function))))))
+
 (cl-defgeneric inspect-object (object)
   "Main generic interface for filling inspector buffers for the different 
types of OBJECT.")
 
@@ -282,12 +292,30 @@ If LABEL has a value, then it is used as button label.  
Otherwise, button label
       (newline)))
    ((inspector--proper-list-p cons)
     (inspector--insert-title "Proper list")
-    (let ((i 0))
-      (dolist (elem cons)
-        (insert (format "%d: " i))
-        (inspector--insert-inspect-button elem)
-        (newline)
-        (cl-incf i))))
+    (let ((i 0)
+         (j 0))
+      (inspector--do-with-slicer
+       (lambda ()
+        (when (< i (length cons))
+          (subseq cons i (min (incf i inspector-slice-size)
+                              (length cons)))))
+       (lambda (slice cont)
+        (dolist (elem slice)
+           (insert (format "%d: " j))
+          (incf j)
+           (inspector--insert-inspect-button elem)
+           (newline))
+        (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))))) 
    (t ;; It is a cons cell
     (inspector--insert-title "Cons cell")
     (insert "CAR: ")



reply via email to

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