[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/inspector d43bb09ae9 11/39: tree-inspector: housekeepin
From: |
ELPA Syncer |
Subject: |
[elpa] externals/inspector d43bb09ae9 11/39: tree-inspector: housekeeping |
Date: |
Sat, 10 Sep 2022 17:57:47 -0400 (EDT) |
branch: externals/inspector
commit d43bb09ae9ff90a9bb6dae355892d652869f308c
Author: Mariano Montone <marianomontone@gmail.com>
Commit: Mariano Montone <marianomontone@gmail.com>
tree-inspector: housekeeping
---
tree-inspector-tests.el | 14 ++++
tree-inspector.el | 203 ++++++++++++++++++++++++++----------------------
2 files changed, 124 insertions(+), 93 deletions(-)
diff --git a/tree-inspector-tests.el b/tree-inspector-tests.el
new file mode 100644
index 0000000000..4c3f313ba8
--- /dev/null
+++ b/tree-inspector-tests.el
@@ -0,0 +1,14 @@
+;; (tree-inspector-inspect 2)
+;; (tree-inspector-inspect (list 1 2 3))
+;; (tree-inspector-inspect (list 1 2 3 (list "lala" "sf")))
+;; (tree-inspector-inspect (let ((tab (make-hash-table)))
+;; (puthash 'a 22 tab)
+;; (puthash 'b 44 tab)
+;; tab))
+;; (tree-inspector-inspect '((a . 22) (b . "lala")))
+;; (tree-inspector-inspect [1 2 3 4 5 6 6 7 7 7 8 8 8 8 9 9])
+
+;; (request
"https://www.govtrack.us/api/v2/role?current=true&role_type=senator"
+;; :success
+;; (lambda (&rest args)
+;; (tree-inspector-inspect (json-read-from-string (getf args :data)))))
diff --git a/tree-inspector.el b/tree-inspector.el
index 8da00d08d0..11afcb948d 100644
--- a/tree-inspector.el
+++ b/tree-inspector.el
@@ -1,8 +1,97 @@
+;; tree-inspector.el --- Inspector tool for Emacs Lisp object that uses a
treeview -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2021-2022 Free Software Foundation, Inc.
+
+;; Author: Mariano Montone <marianomontone@gmail.com>
+;; URL: https://github.com/mmontone/emacs-inspector
+;; Keywords: debugging, tool, emacs-lisp, development
+;; Version: 0.2
+;; Package-Requires: ((emacs "25"))
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Inspector tool for Emacs Lisp object that uses a treeview.
+
+;;; Code:
+
(require 'eieio)
(require 'treeview)
(require 'mule-util)
-;;---- Utils ----------
+;;---------- Settings --------------------------------------------------------
+
+(defgroup tree-inspector nil
+ "tree-inspector"
+ :group 'applications)
+
+(defcustom tree-inspector-control-keymap
+ '(("<mouse-1>" . treeview-toggle-node-state-at-event)
+ ("<mouse-2>" . treeview-toggle-node-state-at-event)
+ ("<mouse-3>" . dir-treeview-popup-node-menu-at-mouse)
+ ("RET" . treeview-toggle-node-state-at-point)
+ ("SPC" . treeview-toggle-node-state-at-point)
+ ("e" . tree-inspector-popup-node-menu-at-point))
+ "Keymap of the control symbols.
+A list of assignments of key sequences to commands. Key sequences are strings
+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-label-keymap
+ '(("<mouse-1>" . tree-inspector-inspect-object-at-event)
+ ("<mouse-2>" . tree-inspector-inspect-object-at-event)
+ ("<mouse-3>" . tree-inspector-popup-node-menu-at-mouse)
+ ("RET" . tree-inspector-inspect-object-at-point)
+ ("e" . tree-inspector-popup-node-menu-at-point)
+ ("<C-down-mouse-1>" . ignore)
+ ("<C-mouse-1>" . treeview-toggle-select-node-at-event)
+ ("<S-down-mouse-1>" . ignore)
+ ("<S-mouse-1>" . treeview-select-gap-above-node-at-event))
+ "Keymap of the labels.
+A list of assignments of key sequences to commands. Key sequences are strings
+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-use-specialized-inspectors-for-lists t
+ "Whether to use specialized inspectors for plists and alists."
+ :type 'boolean
+ :group 'inspector)
+
+(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)
+
+;;-------- Utils ----------------------------------------------------------
(defun tree-inspector--princ-to-string (object)
"Print OBJECT to string using `princ'."
@@ -46,6 +135,22 @@
(prin1-to-string object)
30 nil nil "..."))
+;;-------------- treeview functions
--------------------------------------------
+
+(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)
+ tree-inspector-indent-unit
+ indent)
+ node parent))
+ indent))
+
(defun tree-inspector--set-node-children (node children)
(mapc (lambda (child)
(treeview-set-node-parent child node))
@@ -59,7 +164,8 @@
(when children
(tree-inspector--set-node-children node children))))))
-(cl-defgeneric tree-inspector--node-children (node))
+(cl-defgeneric tree-inspector--node-children (node)
+ (:documentation "Return the NODE children treeview nodes."))
(cl-defmethod tree-inspector--node-children ((object cons))
(cond
@@ -88,10 +194,7 @@
(cl-defmethod tree-inspector--node-children ((object vector))
(cl-map 'list
- (lambda (item)
- (let ((child (tree-inspector--make-node item)))
- (treeview-set-node-parent child node)
- child))
+ #'tree-inspector--make-node
object))
(cl-defgeneric tree-inspector--make-node (object)
@@ -197,79 +300,8 @@
(tree-inspector--set-node-children node children)
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)
- tree-inspector-indent-unit
- indent)
- node parent))
- indent))
-
-(defgroup tree-inspector nil
- "tree-inspector"
- :group 'applications)
-
-(defcustom tree-inspector-control-keymap
- '(("<mouse-1>" . treeview-toggle-node-state-at-event)
- ("<mouse-2>" . treeview-toggle-node-state-at-event)
- ("<mouse-3>" . dir-treeview-popup-node-menu-at-mouse)
- ("RET" . treeview-toggle-node-state-at-point)
- ("SPC" . treeview-toggle-node-state-at-point)
- ("e" . tree-inspector-popup-node-menu-at-point))
- "Keymap of the control symbols.
-A list of assignments of key sequences to commands. Key sequences are strings
-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-label-keymap
- '(("<mouse-1>" . tree-inspector-inspect-object-at-event)
- ("<mouse-2>" . tree-inspector-inspect-object-at-event)
- ("<mouse-3>" . tree-inspector-popup-node-menu-at-mouse)
- ("RET" . tree-inspector-inspect-object-at-point)
- ("e" . tree-inspector-popup-node-menu-at-point)
- ("<C-down-mouse-1>" . ignore)
- ("<C-mouse-1>" . treeview-toggle-select-node-at-event)
- ("<S-down-mouse-1>" . ignore)
- ("<S-mouse-1>" . treeview-select-gap-above-node-at-event))
- "Keymap of the labels.
-A list of assignments of key sequences to commands. Key sequences are strings
-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-use-specialized-inspectors-for-lists t
- "Whether to use specialized inspectors for plists and alists."
- :type 'boolean
- :group 'inspector)
-
-(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)
+ "Inspect DATA with a tree-inspector."
(let ((buffer (get-buffer-create (format "*tree-inspector: %s*"
(tree-inspector--print-object
data)))))
(with-current-buffer buffer
@@ -306,18 +338,3 @@ in a format understood by `kbd'. Commands a names of Lisp
functions."
(switch-to-buffer buffer))))
(provide 'tree-inspector)
-
-;; (tree-inspector-inspect 2)
-;; (tree-inspector-inspect (list 1 2 3))
-;; (tree-inspector-inspect (list 1 2 3 (list "lala" "sf")))
-;; (tree-inspector-inspect (let ((tab (make-hash-table)))
-;; (puthash 'a 22 tab)
-;; (puthash 'b 44 tab)
-;; tab))
-;; (tree-inspector-inspect '((a . 22) (b . "lala")))
-;; (tree-inspector-inspect [1 2 3 4 5 6 6 7 7 7 8 8 8 8 9 9])
-
-;; (request
"https://www.govtrack.us/api/v2/role?current=true&role_type=senator"
-;; :success
-;; (lambda (&rest args)
-;; (tree-inspector-inspect (json-read-from-string (getf args :data)))))
- [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, 2022/09/10
- [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 <=
- [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
- [elpa] externals/inspector 236ef196a0 24/39: tree-inspector: fixes, ELPA Syncer, 2022/09/10
- [elpa] externals/inspector fc9712651c 36/39: More complete package commentary, ELPA Syncer, 2022/09/10
- [elpa] externals/inspector 5828d49207 21/39: tree-inspector: inspect-last-sexp, ELPA Syncer, 2022/09/10
- [elpa] externals/inspector 1f1469ec9d 22/39: tree-inspector: buffers, windows, frames, ELPA Syncer, 2022/09/10
- [elpa] externals/inspector 49586fc18b 23/39: tree-inspector: buffers, windows, overlays, frames, ELPA Syncer, 2022/09/10