[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/inspector 4b193ba6d0 69/93: Don't add [more] button whe
From: |
ELPA Syncer |
Subject: |
[elpa] externals/inspector 4b193ba6d0 69/93: Don't add [more] button when not needed |
Date: |
Tue, 24 May 2022 18:58:00 -0400 (EDT) |
branch: externals/inspector
commit 4b193ba6d02d5c3d3a7992dcd7aa4e67d564aea9
Author: Mariano Montone <marianomontone@gmail.com>
Commit: Mariano Montone <marianomontone@gmail.com>
Don't add [more] button when not needed
Fixes https://github.com/mmontone/emacs-inspector/issues/4
---
inspector.el | 50 ++++++++++++++++++++++++++++++++++----------------
1 file changed, 34 insertions(+), 16 deletions(-)
diff --git a/inspector.el b/inspector.el
index b497ee59fc..c9f8e88a20 100644
--- a/inspector.el
+++ b/inspector.el
@@ -168,25 +168,32 @@ If LABEL has a value, then it is used as button label.
Otherwise, button label
'follow-link t))
(defun inspector--do-with-slicer (slicer function)
+ "Use SLICER and call FUNCTION on the resulting slice.
+SLICE should be a function that returns a slice of some data.
+FUNCTION is passed the resulting slice and a continuation function that when
called continues the consumption of slices of data, until there are no more
slices (the returned slice is NIL)."
(let ((slice (funcall slicer)))
(when slice
- (funcall function slice (lambda () (inspector--do-with-slicer slicer
function))))))
+ (funcall function slice
+ (lambda () (inspector--do-with-slicer slicer function))))))
(defun inspector--do-with-slicer-and-more-button (slicer function)
+ "Apply the SLICER function and apply FUNCTION to the resulting slice.
+When FUNCTION returns not NIL, adds a [More] button that inserts the next
slice in buffer."
(inspector--do-with-slicer
slicer
(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))))
+ (let ((more-p (funcall function slice cont)))
+ (when more-p
+ (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))))))
(cl-defgeneric inspect-object (object)
"Render inspector buffer for OBJECT.")
@@ -326,7 +333,9 @@ If LABEL has a value, then it is used as button label.
Otherwise, button label
(insert " . ")
(inspector--insert-inspect-button (cdr cons))
(insert ")")
- (newline))))))
+ (newline))
+ ;; A [more] button is inserted or not depending on the boolean
returned here:
+ (< i (length cons))))))
((inspector--proper-list-p cons)
(inspector--insert-title "Proper list")
(inspector--insert-label "Length")
@@ -345,7 +354,10 @@ If LABEL has a value, then it is used as button label.
Otherwise, button label
(insert (format "%d: " j))
(cl-incf j)
(inspector--insert-inspect-button elem)
- (newline))))))
+ (newline))
+ ;; A [more] button is inserted or not depending on the boolean
returned here:
+ (< i (length cons))
+ ))))
(t ;; It is a cons cell
(inspector--insert-title "Cons cell")
(insert "CAR: ")
@@ -377,7 +389,10 @@ If LABEL has a value, then it is used as button label.
Otherwise, button label
do
(insert (format "%d: " k))
(inspector--insert-inspect-button (aref array k))
- (newline)))))))
+ (newline))
+ ;; Insert [more] button?:
+ (< i length)
+ )))))
(cl-defmethod inspect-object ((buffer buffer))
"Render inspector buffer for Emacs BUFFER."
@@ -481,7 +496,10 @@ If LABEL has a value, then it is used as button label.
Otherwise, button label
(inspector--insert-inspect-button key)
(insert ": ")
(inspector--insert-inspect-button (gethash key hash-table))
- (newline))))))))
+ (newline))
+ ;; Insert [more] button?
+ (< i (length keys))
+ ))))))
;;--- Buffers ------------------------------
- [elpa] externals/inspector 6c071c67b3 60/93: Housekeeping, (continued)
- [elpa] externals/inspector 6c071c67b3 60/93: Housekeeping, ELPA Syncer, 2022/05/24
- [elpa] externals/inspector e7f2f13ff4 75/93: Start writing ert tests, ELPA Syncer, 2022/05/24
- [elpa] externals/inspector b1d60310da 73/93: Patch by Stefan Monnier, ELPA Syncer, 2022/05/24
- [elpa] externals/inspector 739890b5d6 70/93: Autoloads?, ELPA Syncer, 2022/05/24
- [elpa] externals/inspector 477e363962 82/93: tests: no more side-effects, ELPA Syncer, 2022/05/24
- [elpa] externals/inspector b10f60c20d 89/93: Fontification for each type of object, ELPA Syncer, 2022/05/24
- [elpa] externals/inspector 6fadd6df9f 93/93: Create LICENSE, ELPA Syncer, 2022/05/24
- [elpa] externals/inspector d5d286c5de 10/93: inspect-last-sexp command, ELPA Syncer, 2022/05/24
- [elpa] externals/inspector 30d739e108 53/93: Slice arrays, ELPA Syncer, 2022/05/24
- [elpa] externals/inspector a9e41424fa 66/93: Update README.md, ELPA Syncer, 2022/05/24
- [elpa] externals/inspector 4b193ba6d0 69/93: Don't add [more] button when not needed,
ELPA Syncer <=
- [elpa] externals/inspector 2af90a4c82 83/93: tests: fixes, ELPA Syncer, 2022/05/24
- [elpa] externals/inspector 57105aef34 72/93: Update README.md, ELPA Syncer, 2022/05/24
- [elpa] externals/inspector 023ae9ca51 92/93: Use value face instead of button face, ELPA Syncer, 2022/05/24
- [elpa] externals/inspector d88d248eef 19/93: Presentation improvements, ELPA Syncer, 2022/05/24
- [elpa] externals/inspector 57b46a3079 38/93: Bug fix, ELPA Syncer, 2022/05/24
- [elpa] externals/inspector 22869bffb4 47/93: Indentation, ELPA Syncer, 2022/05/24
- [elpa] externals/inspector f534e87d1d 54/93: Slice tests, ELPA Syncer, 2022/05/24
- [elpa] externals/inspector 5f7ab9bfb7 06/93: Housekeeping, ELPA Syncer, 2022/05/24
- [elpa] externals/inspector 7574ca3ff9 51/93: Slice sequences, ELPA Syncer, 2022/05/24
- [elpa] externals/inspector 610d67b358 59/93: Test on property lists, ELPA Syncer, 2022/05/24