[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/inspector 06eb60bcff 03/39: tree-inspector: indentation
From: |
ELPA Syncer |
Subject: |
[elpa] externals/inspector 06eb60bcff 03/39: tree-inspector: indentation |
Date: |
Sat, 10 Sep 2022 17:57:46 -0400 (EDT) |
branch: externals/inspector
commit 06eb60bcffbad99e280de8439c00cba3d08515ed
Author: Mariano Montone <marianomontone@gmail.com>
Commit: Mariano Montone <marianomontone@gmail.com>
tree-inspector: indentation
---
tree-inspector.el | 52 ++++++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 48 insertions(+), 4 deletions(-)
diff --git a/tree-inspector.el b/tree-inspector.el
index 5ce8a12df6..892430c483 100644
--- a/tree-inspector.el
+++ b/tree-inspector.el
@@ -49,6 +49,13 @@
(treeview-set-node-name node (prin1-to-string object))
node))
+(cl-defmethod tree-inspector--make-node ((object string))
+ (let ((node (treeview-new-node)))
+ (treeview-set-node-name node
+ (truncate-string-to-width object
+ 30 nil nil "..."))
+ node))
+
(cl-defmethod tree-inspector--make-node ((object cons))
(cond
((tree-inspector--proper-list-p object)
@@ -59,11 +66,23 @@
(treeview-set-node-children node
(mapcar (lambda (item)
(let ((child (tree-inspector--make-node item)))
- ;;(treeview-set-node-parent child node)
+ (treeview-set-node-parent child node)
child))
object))
node))))
+(defun tree-inspector--get-indent (node)
+ "Return the indentation of NODE."
+ (let ((indent ())
+ (parent nil))
+ (while (setq parent (treeview-get-node-parent node))
+ (setq indent (cons (if (treeview-last-child-p parent)
+ dir-treeview-indent-last-unit
+ dir-treeview-indent-unit)
+ indent)
+ node parent))
+ indent))
+
(defgroup tree-inspector nil
"tree-inspector"
:group 'applications)
@@ -97,6 +116,27 @@ in a format understood by `kbd'. Commands a names of Lisp
functions."
:group 'tree-inspector
:type '(repeat (cons (string :tag "Key ") (function :tag "Command"))))
+(defcustom tree-inspector-indent-unit " | "
+ "Symbol to indent directories when the parent is not the last child."
+ :group 'tree-inspector
+ :type 'string)
+
+(defcustom tree-inspector-indent-last-unit " "
+ "Symbol to indent directories when the parent is the last child of its
parent."
+ :group 'tree-inspector
+ :type 'string)
+
+(defcustom tree-inspector-folded-node-control "[+]"
+ "Control symbol for folded directories."
+ :group 'tree-inspector
+ :type 'string)
+
+(defcustom tree-inspector-expanded-node-control "[-]"
+ "Control symbol for expanded directories."
+ :group 'tree-inspector
+ :type 'string)
+
+
(defun tree-inspector-inspect (data)
(let ((buffer (get-buffer-create (format "*tree-inspector: %s*" data))))
(with-current-buffer buffer
@@ -105,11 +145,13 @@ in a format understood by `kbd'. Commands a names of
Lisp functions."
(setq-local treeview-get-indent-function
(lambda (node) (list " ")))
(setq-local treeview-get-label-function #'first)
+ (setq-local treeview-get-indent-function #'tree-inspector--get-indent)
(setq-local treeview-get-control-function
(lambda (node)
- (if (treeview-get-node-children node)
- "[+]"
- nil)))
+ (when (treeview-get-node-children node)
+ (if (treeview-node-folded-p node)
+ tree-inspector-folded-node-control
+ tree-inspector-expanded-node-control))))
(setq-local treeview-update-node-children-function
(cl-constantly nil))
(setq-local treeview-after-node-expanded-function
@@ -124,8 +166,10 @@ in a format understood by `kbd'. Commands a names of Lisp
functions."
(treeview-make-keymap tree-inspector-label-keymap)))
(treeview-display-node (tree-inspector--make-node data))
(setq buffer-read-only t)
+ (local-set-key (kbd "q") #'kill-current-buffer)
(display-buffer buffer))))
(tree-inspector-inspect 2)
(tree-inspector-inspect (list 1 2 3))
+(tree-inspector-inspect (list 1 2 3 (list "lala" "sf")))
- [elpa] externals/inspector updated (f04c60a5d3 -> 0b213e931c), ELPA Syncer, 2022/09/10
- [elpa] externals/inspector e2e56201a0 01/39: Starting a tree-inspector with treeview, ELPA Syncer, 2022/09/10
- [elpa] externals/inspector 06eb60bcff 03/39: tree-inspector: indentation,
ELPA Syncer <=
- [elpa] externals/inspector 56579dae8a 05/39: tree-inspector: hash-table inspector, ELPA Syncer, 2022/09/10
- [elpa] externals/inspector 838b08706a 02/39: tree-inspector work, ELPA Syncer, 2022/09/10
- [elpa] externals/inspector faf590dded 06/39: tree-inspector: alist inspector, ELPA Syncer, 2022/09/10
- [elpa] externals/inspector 068b754a0a 07/39: tree-inspector: vectors, ELPA Syncer, 2022/09/10
- [elpa] externals/inspector d43bb09ae9 11/39: tree-inspector: housekeeping, ELPA Syncer, 2022/09/10
- [elpa] externals/inspector 4066d7b441 13/39: Starting some tree-inspector tests, ELPA Syncer, 2022/09/10
- [elpa] externals/inspector 8b000e4e4e 15/39: tree-inspector: tests, ELPA Syncer, 2022/09/10
- [elpa] externals/inspector 130c43c6b6 19/39: tree-inspector: records, ELPA Syncer, 2022/09/10
- [elpa] externals/inspector 394fb22811 09/39: ..., ELPA Syncer, 2022/09/10
- [elpa] externals/inspector 98d3d56723 10/39: tree-inspector: provide, ELPA Syncer, 2022/09/10