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

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

[nongnu] elpa/slime 0c6bc6bd26 33/43: Inspector: differentiate inactive


From: ELPA Syncer
Subject: [nongnu] elpa/slime 0c6bc6bd26 33/43: Inspector: differentiate inactive array elements
Date: Thu, 28 Dec 2023 22:00:30 -0500 (EST)

branch: elpa/slime
commit 0c6bc6bd26bdb4921faf7fec08cd9db4bbe29438
Author: MichaƂ "phoe" Herda <phoe@disroot.org>
Commit: Stas Boukarev <stassats@gmail.com>

    Inspector: differentiate inactive array elements
---
 swank.lisp | 44 ++++++++++++++++++++++++++++++++++++++------
 1 file changed, 38 insertions(+), 6 deletions(-)

diff --git a/swank.lisp b/swank.lisp
index ff23ea0afb..f2f14c6e66 100644
--- a/swank.lisp
+++ b/swank.lisp
@@ -3405,12 +3405,44 @@ Return NIL if LIST is circular."
    (iline "Adjustable" (adjustable-array-p array))
    (iline "Fill pointer" (if (array-has-fill-pointer-p array)
                              (fill-pointer array)))
-   "Contents:" '(:newline)
-   (labels ((k (i max)
-              (cond ((= i max) '())
-                    (t (lcons (iline i (row-major-aref array i))
-                              (k (1+ i) max))))))
-     (k 0 (array-total-size array)))))
+   (if (array-has-fill-pointer-p array)
+       (emacs-inspect-vector-with-fill-pointer-aux array)
+       (emacs-inspect-array-aux array))))
+
+(defun emacs-inspect-array-aux (array)
+  (unless (= 0 (array-total-size array))
+    (lcons*
+     "Contents:" '(:newline)
+     (labels ((k (i max)
+                (cond ((= i max) '())
+                      (t (lcons (iline i (row-major-aref array i))
+                                (k (1+ i) max))))))
+       (k 0 (array-total-size array))))))
+
+(defun emacs-inspect-vector-with-fill-pointer-aux (array)
+  (let ((active-elements? (< 0 (fill-pointer array)))
+        (inactive-elements? (< (fill-pointer array)
+                               (array-total-size array))))
+    (labels ((k (i max cont)
+               (cond ((= i max) (funcall cont))
+                     (t (lcons (iline i (row-major-aref array i))
+                               (k (1+ i) max cont)))))
+             (collect-active ()
+               (if active-elements?
+                   (lcons*
+                    "Active elements:" '(:newline)
+                    (k 0 (fill-pointer array)
+                       (lambda () (collect-inactive))))
+                   (collect-inactive)))
+             (collect-inactive ()
+               (if inactive-elements?
+                   (lcons*
+                    "Inactive elements:" '(:newline)
+                    (k (fill-pointer array)
+                       (array-total-size array)
+                       (constantly '())))
+                   '())))
+      (collect-active))))
 
 ;;;;; Chars
 



reply via email to

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