* bug#55900: [PATCH] Hierarchy – Defer the Computation of Children @ 2022-06-11 6:52 Wamm K. D. 2022-06-11 8:21 ` Eli Zaretskii 0 siblings, 1 reply; 15+ messages in thread From: Wamm K. D. @ 2022-06-11 6:52 UTC (permalink / raw) To: 55900 [-- Attachment #1: Type: text/plain, Size: 964 bytes --] Tags: patch Pretty much as the subject describes; this should allow for users to lazily load hierarchy branches when loading everything at once would otherwise be too consuming, up-front (or if dealing with an infinite tree). My current use-case with this feature is mapping a file hierarchy on a server; each node has to be queried against the API of the server so it only makes sense to make the HTTP call when the user wants to load the node (rather than a bunch of HTTP calls, all at once). In GNU Emacs 28.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.30, cairo version 1.16.0) System Description: Guix System Configured using: 'configure CONFIG_SHELL=/gnu/store/4y5m9lb8k3qkb1y9m02sw9w9a6hacd16-bash-minimal-5.1.8/bin/bash SHELL=/gnu/store/4y5m9lb8k3qkb1y9m02sw9w9a6hacd16-bash-minimal-5.1.8/bin/bash --prefix=/gnu/store/8avvrqis68nvpnv7z4vmd745hji5jyrk-emacs-28.1 --enable-fast-install --with-modules --with-cairo --disable-build-details' [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-Allow-Hierarchy-to-delay-computing-children.patch --] [-- Type: text/patch, Size: 6999 bytes --] From 44c5f8bf00ea51d47c4a9d5127233ef303734f92 Mon Sep 17 00:00:00 2001 From: "Wamm K. D" <jaft.r@outlook.com> Date: Sat, 11 Jun 2022 01:21:43 -0500 Subject: [PATCH] Allow Hierarchy to delay computing children Add an option to allow users to specify that computing the children of the hierarchy should be delayed to when the user calls for them, by utilizing the tree-widget :expander property. * lisp/emacs-lisp/hierarchy.el (hierarchy-add-tree) (hierarchy-add-trees): Add parameter 'delay-children-p'. * lisp/emacs-lisp/hierarchy.el (hierarchy--create-delayed-tree-widget): Add function. * lisp/emacs-lisp/hierarchy.el (hierarchy-convert-to-tree-widget): Utilize ':expander' if delaying children. --- lisp/emacs-lisp/hierarchy.el | 78 ++++++++++++++++++++++++++++-------- 1 file changed, 61 insertions(+), 17 deletions(-) diff --git a/lisp/emacs-lisp/hierarchy.el b/lisp/emacs-lisp/hierarchy.el index 6c95d86b47..55faaa1b3f 100644 --- a/lisp/emacs-lisp/hierarchy.el +++ b/lisp/emacs-lisp/hierarchy.el @@ -71,7 +71,8 @@ (:conc-name hierarchy--)) (roots (list)) ; list of the hierarchy roots (no parent) (parents (make-hash-table :test 'equal)) ; map an item to its parent - (children (make-hash-table :test 'equal)) ; map an item to its childre + (children (make-hash-table :test 'equal)) ; map an item to its children + (delaying-parents (make-hash-table :test 'equal)) ; map an item to its childrenfn ;; cache containing the set of all items in the hierarchy (seen-items (make-hash-table :test 'equal))) ; map an item to t @@ -133,7 +134,8 @@ keys are :key and :test." "Create a hierarchy and return it." (hierarchy--make)) -(defun hierarchy-add-tree (hierarchy item parentfn &optional childrenfn acceptfn) +(defun hierarchy-add-tree (hierarchy item parentfn + &optional childrenfn acceptfn delay-children-p) "In HIERARCHY, add ITEM. PARENTFN is either nil or a function defining the child-to-parent @@ -151,7 +153,12 @@ CHILDRENFN are expected to be coherent with each other. ACCEPTFN is a function returning non-nil if its parameter (any object) should be an item of the hierarchy. By default, ACCEPTFN returns non-nil -if its parameter is non-nil." +if its parameter is non-nil. + +DELAY-CHILDREN-P is a predicate determining whether the children that would +normally be processed by CHILDRENFN should, instead, have their processing be +delayed and stored to be processed by CHILDRENFN when the child is selected +during use of the hierarchy." (unless (hierarchy-has-item hierarchy item) (let ((acceptfn (or acceptfn #'identity))) (hierarchy--seen-items-add hierarchy item) @@ -159,19 +166,25 @@ if its parameter is non-nil." (when (funcall acceptfn parent) (hierarchy--add-relation hierarchy item parent acceptfn) (hierarchy-add-tree hierarchy parent parentfn childrenfn))) - (let ((children (and childrenfn (funcall childrenfn item)))) - (mapc (lambda (child) - (when (funcall acceptfn child) - (hierarchy--add-relation hierarchy child item acceptfn) - (hierarchy-add-tree hierarchy child parentfn childrenfn))) - children))))) - -(defun hierarchy-add-trees (hierarchy items parentfn &optional childrenfn acceptfn) + (if delay-children-p + (map-put! (hierarchy--delaying-parents hierarchy) item childrenfn) + (let ((children (and childrenfn (funcall childrenfn item)))) + (map-put! (hierarchy--delaying-parents hierarchy) item nil) + (mapc (lambda (child) + (when (funcall acceptfn child) + (hierarchy--add-relation hierarchy child item acceptfn) + (hierarchy-add-tree hierarchy child parentfn childrenfn))) + children)))))) + +(defun hierarchy-add-trees (hierarchy items parentfn + &optional childrenfn acceptfn delay-children-p) "Call `hierarchy-add-tree' on HIERARCHY and each element of ITEMS. -PARENTFN, CHILDRENFN and ACCEPTFN have the same meaning as in `hierarchy-add'." +PARENTFN, CHILDRENFN, ACCEPTFN, and DELAY-CHILDREN-P have the same meaning as in +`hierarchy-add'." (seq-map (lambda (item) - (hierarchy-add-tree hierarchy item parentfn childrenfn acceptfn)) + (hierarchy-add-tree hierarchy item parentfn + childrenfn acceptfn delay-children-p)) items)) (defun hierarchy-add-list (hierarchy list &optional wrap childrenfn) @@ -541,6 +554,26 @@ nil. The buffer is returned." buffer)) (declare-function widget-convert "wid-edit") +(defun hierarchy--create-delayed-tree-widget (elem labelfn indent fn) + "Return a list of tree-widgets for a hierarchy created from the childrenfn. +ELEM is the element of the hierarchy passed from +`hierarchy-convert-to-tree-widget'; it and the children function are used +to generate the children of the element dynamically. +LABELFN is the same function passed to `hierarchy-convert-to-tree-widget'. +INDENT is the same function passed to `hierarchy-convert-to-tree-widget'. +FN is the function used to discover the children of ELEM." + (lambda (widget) + (mapcar + (lambda (item) + (widget-convert + 'tree-widget + :tag (hierarchy-labelfn-to-string labelfn item indent) + :expander (hierarchy--create-delayed-tree-widget + item + labelfn + (1+ indent) + fn))) + (funcall fn elem)))) (defun hierarchy-convert-to-tree-widget (hierarchy labelfn) "Return a tree-widget for HIERARCHY. @@ -550,10 +583,21 @@ node label." (require 'wid-edit) (require 'tree-widget) (hierarchy-map-tree (lambda (item indent children) - (widget-convert - 'tree-widget - :tag (hierarchy-labelfn-to-string labelfn item indent) - :args children)) + (let ((childrenfn (map-elt + (hierarchy--delaying-parents hierarchy) + item))) + (apply + #'widget-convert + (list 'tree-widget + :tag (hierarchy-labelfn-to-string labelfn item indent) + (if childrenfn :expander :args) + (if childrenfn + (hierarchy--create-delayed-tree-widget + item + labelfn + (1+ indent) + childrenfn) + children))))) hierarchy)) (defun hierarchy-tree-display (hierarchy labelfn &optional buffer) -- 2.36.1 ^ permalink raw reply related [flat|nested] 15+ messages in thread
* bug#55900: [PATCH] Hierarchy – Defer the Computation of Children 2022-06-11 6:52 bug#55900: [PATCH] Hierarchy – Defer the Computation of Children Wamm K. D. @ 2022-06-11 8:21 ` Eli Zaretskii 2022-06-12 9:01 ` Wamm K. D. [not found] ` <87mtei1cii.fsf@outlook.com> 0 siblings, 2 replies; 15+ messages in thread From: Eli Zaretskii @ 2022-06-11 8:21 UTC (permalink / raw) To: Wamm K. D.; +Cc: 55900 > From: "Wamm K. D." <jaft.r@outlook.com> > Date: Sat, 11 Jun 2022 01:52:13 -0500 > > Pretty much as the subject describes; this should allow for users to > lazily load hierarchy branches when loading everything at once would > otherwise be too consuming, up-front (or if dealing with an infinite > tree). Thanks. > * lisp/emacs-lisp/hierarchy.el (hierarchy-add-tree) (hierarchy-add-trees): > Add parameter 'delay-children-p'. Please use our style of commit log messages. The above should be * lisp/emacs-lisp/hierarchy.el (hierarchy-add-tree) (hierarchy-add-trees): Add parameter 'delay-children-p'. > +(defun hierarchy--create-delayed-tree-widget (elem labelfn indent fn) > + "Return a list of tree-widgets for a hierarchy created from the childrenfn. The first line of the doc string should ideally mention the arguments. This one doesn't, and it also seems to misname one argument: it's FN, not childrenfn, right? Can this be improved? Can you add some tests of this new functionality? Also, I think this warrants a NEWS entry to describe the new feature. ^ permalink raw reply [flat|nested] 15+ messages in thread
* bug#55900: [PATCH] Hierarchy – Defer the Computation of Children 2022-06-11 8:21 ` Eli Zaretskii @ 2022-06-12 9:01 ` Wamm K. D. [not found] ` <87mtei1cii.fsf@outlook.com> 1 sibling, 0 replies; 15+ messages in thread From: Wamm K. D. @ 2022-06-12 9:01 UTC (permalink / raw) To: Eli Zaretskii; +Cc: 55900 [-- Attachment #1: Type: text/plain, Size: 2293 bytes --] On Sat. (Jun 11, 2022) at 04:21:59 AM -04, Eli Zaretskii <eliz@gnu.org> wrote: >> From: "Wamm K. D." <jaft.r@outlook.com> >> Date: Sat, 11 Jun 2022 01:52:13 -0500 >> >> Pretty much as the subject describes; this should allow for users to >> lazily load hierarchy branches when loading everything at once would >> otherwise be too consuming, up-front (or if dealing with an infinite >> tree). > > Thanks. > >> * lisp/emacs-lisp/hierarchy.el (hierarchy-add-tree) (hierarchy-add-trees): >> Add parameter 'delay-children-p'. > > Please use our style of commit log messages. The above should be > > * lisp/emacs-lisp/hierarchy.el (hierarchy-add-tree) > (hierarchy-add-trees): Add parameter 'delay-children-p'. Mmm; gotcha. This hadn't been clear, to me; I thought the example given in the CONTRIBUTE file was that way because the line was long and the main point of its demonstration was what to do with a case of more than one function. I've adjusted the commit message appropriately, now. >> +(defun hierarchy--create-delayed-tree-widget (elem labelfn indent fn) >> + "Return a list of tree-widgets for a hierarchy created from the childrenfn. > > The first line of the doc string should ideally mention the > arguments. This one doesn't, and it also seems to misname one > argument: it's FN, not childrenfn, right? Yeah; I was referencing the fact that this function is called childrenfn in a bunch of other functions but, for whatever reason, I didn't call it that here so that's why it isn't all-capitalized (while the reference to it, at the end, is and says FN). But that's weird; I don't know why I went with that name when I could've just…used the same name as every other function. I've corrected that, standardized. > Can you add some tests of this new functionality? I've added some; I didn't created tests for children functionality since the delayed computation means there aren't children (until someone activates the tree-widget and the children are computed with the provided function) but I create some tests to check that the root and parent elements were still functioning as expected, when using delayed children. > Also, I think this warrants a NEWS entry to describe the new feature. I've added that, as well. [-- Attachment #2: Patch to Hierarchy library to delay computation of children nodes --] [-- Type: text/x-patch, Size: 15477 bytes --] From 1ad834830c5d35b92c9e5ef2161d875218c7c1b6 Mon Sep 17 00:00:00 2001 From: "Wamm K. D" <jaft.r@outlook.com> Date: Sun, 12 Jun 2022 03:48:01 -0500 Subject: [PATCH] Allow Hierarchy to delay computing children Add an option to allow users to specify that computing the children of the hierarchy should be delayed to when the user calls for them, by utilizing the tree-widget :expander property. * lisp/emacs-lisp/hierarchy.el (hierarchy-add-tree) (hierarchy-add-trees): Add parameter 'delay-children-p'. * lisp/emacs-lisp/hierarchy.el (hierarchy--create-delayed-tree-widget): Add function. * lisp/emacs-lisp/hierarchy.el (hierarchy-convert-to-tree-widget): Utilize ':expander' if delaying children. * test/lisp/emacs-lisp/hierarchy-tests.el: Add tests for delayed-children functionality. --- etc/NEWS | 9 ++ lisp/emacs-lisp/hierarchy.el | 86 ++++++++++++--- test/lisp/emacs-lisp/hierarchy-tests.el | 141 ++++++++++++++++++++++++ 3 files changed, 218 insertions(+), 18 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 424d1250c3..a8c863cd20 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1756,6 +1756,15 @@ Enabling this minor mode turns on hiding header material, like If non-nil, files untracked by a VCS are considered to be part of the project by a VC project based on that VCS. +** Hierarchy + ++++ +*** Tree Display can delay computation of children +'hierarchy-add-tree' and 'hierarchy-add-trees' have an optional +argument, 'delay-children-p', which allows storing 'childrenfn' to the +nodes of a tree-widget display to be activated and computed only when +the users expands the node. + --- ** The autoarg.el library is now marked obsolete. This library provides the 'autoarg-mode' and 'autoarg-kp-mode' minor diff --git a/lisp/emacs-lisp/hierarchy.el b/lisp/emacs-lisp/hierarchy.el index 6c95d86b47..316cdcb30b 100644 --- a/lisp/emacs-lisp/hierarchy.el +++ b/lisp/emacs-lisp/hierarchy.el @@ -71,7 +71,8 @@ (:conc-name hierarchy--)) (roots (list)) ; list of the hierarchy roots (no parent) (parents (make-hash-table :test 'equal)) ; map an item to its parent - (children (make-hash-table :test 'equal)) ; map an item to its childre + (children (make-hash-table :test 'equal)) ; map an item to its children + (delaying-parents (make-hash-table :test 'equal)) ; map an item to its childrenfn ;; cache containing the set of all items in the hierarchy (seen-items (make-hash-table :test 'equal))) ; map an item to t @@ -133,7 +134,8 @@ keys are :key and :test." "Create a hierarchy and return it." (hierarchy--make)) -(defun hierarchy-add-tree (hierarchy item parentfn &optional childrenfn acceptfn) +(defun hierarchy-add-tree (hierarchy item parentfn + &optional childrenfn acceptfn delay-children-p) "In HIERARCHY, add ITEM. PARENTFN is either nil or a function defining the child-to-parent @@ -151,27 +153,39 @@ CHILDRENFN are expected to be coherent with each other. ACCEPTFN is a function returning non-nil if its parameter (any object) should be an item of the hierarchy. By default, ACCEPTFN returns non-nil -if its parameter is non-nil." +if its parameter is non-nil. + +DELAY-CHILDREN-P is a predicate determining whether the children that would +normally be processed by CHILDRENFN should, instead, have their processing be +delayed and stored to be processed by CHILDRENFN when the child is selected +during use of the hierarchy." (unless (hierarchy-has-item hierarchy item) (let ((acceptfn (or acceptfn #'identity))) (hierarchy--seen-items-add hierarchy item) (let ((parent (and parentfn (funcall parentfn item)))) (when (funcall acceptfn parent) (hierarchy--add-relation hierarchy item parent acceptfn) - (hierarchy-add-tree hierarchy parent parentfn childrenfn))) - (let ((children (and childrenfn (funcall childrenfn item)))) - (mapc (lambda (child) - (when (funcall acceptfn child) - (hierarchy--add-relation hierarchy child item acceptfn) - (hierarchy-add-tree hierarchy child parentfn childrenfn))) - children))))) - -(defun hierarchy-add-trees (hierarchy items parentfn &optional childrenfn acceptfn) + (hierarchy-add-tree hierarchy parent + parentfn (if delay-children-p nil childrenfn)))) + (if (and childrenfn delay-children-p) + (map-put! (hierarchy--delaying-parents hierarchy) item childrenfn) + (let ((children (and childrenfn (funcall childrenfn item)))) + (map-put! (hierarchy--delaying-parents hierarchy) item nil) + (mapc (lambda (child) + (when (funcall acceptfn child) + (hierarchy--add-relation hierarchy child item acceptfn) + (hierarchy-add-tree hierarchy child parentfn childrenfn))) + children)))))) + +(defun hierarchy-add-trees (hierarchy items parentfn + &optional childrenfn acceptfn delay-children-p) "Call `hierarchy-add-tree' on HIERARCHY and each element of ITEMS. -PARENTFN, CHILDRENFN and ACCEPTFN have the same meaning as in `hierarchy-add'." +PARENTFN, CHILDRENFN, ACCEPTFN, and DELAY-CHILDREN-P have the same meaning as in +`hierarchy-add'." (seq-map (lambda (item) - (hierarchy-add-tree hierarchy item parentfn childrenfn acceptfn)) + (hierarchy-add-tree hierarchy item parentfn + childrenfn acceptfn delay-children-p)) items)) (defun hierarchy-add-list (hierarchy list &optional wrap childrenfn) @@ -541,6 +555,31 @@ nil. The buffer is returned." buffer)) (declare-function widget-convert "wid-edit") +(defun hierarchy--create-delayed-tree-widget (elem labelfn indent childrenfn) + "Return a list of tree-widgets for the children generated by calling +CHILDRENFN on ELEM. + +ELEM is the element of the hierarchy passed from +`hierarchy-convert-to-tree-widget'; it and the CHILDRENFN are used to generate +the children of the element dynamically. + +LABELFN is the same function passed to `hierarchy-convert-to-tree-widget'. + +INDENT is the same function passed to `hierarchy-convert-to-tree-widget'. + +CHILDRENFN is the function used to discover the children of ELEM." + (lambda (widget) + (mapcar + (lambda (item) + (widget-convert + 'tree-widget + :tag (hierarchy-labelfn-to-string labelfn item indent) + :expander (hierarchy--create-delayed-tree-widget + item + labelfn + (1+ indent) + childrenfn))) + (funcall childrenfn elem)))) (defun hierarchy-convert-to-tree-widget (hierarchy labelfn) "Return a tree-widget for HIERARCHY. @@ -550,10 +589,21 @@ node label." (require 'wid-edit) (require 'tree-widget) (hierarchy-map-tree (lambda (item indent children) - (widget-convert - 'tree-widget - :tag (hierarchy-labelfn-to-string labelfn item indent) - :args children)) + (let ((childrenfn (map-elt + (hierarchy--delaying-parents hierarchy) + item))) + (apply + #'widget-convert + (list 'tree-widget + :tag (hierarchy-labelfn-to-string labelfn item indent) + (if childrenfn :expander :args) + (if childrenfn + (hierarchy--create-delayed-tree-widget + item + labelfn + (1+ indent) + childrenfn) + children))))) hierarchy)) (defun hierarchy-tree-display (hierarchy labelfn &optional buffer) diff --git a/test/lisp/emacs-lisp/hierarchy-tests.el b/test/lisp/emacs-lisp/hierarchy-tests.el index 41d3f2f3cc..8ba86966ea 100644 --- a/test/lisp/emacs-lisp/hierarchy-tests.el +++ b/test/lisp/emacs-lisp/hierarchy-tests.el @@ -552,5 +552,146 @@ (hierarchy-sort organisms) (should (equal (hierarchy-roots organisms) '(animal plant))))) +(defun hierarchy-examples-delayed--find-number (num) + "Find a number, NUM, by adding 1s together until you reach it. +This is entire contrived and mostly meant to be purposefully inefficient to +not be possible on a large scale. +Running the number 200 causes this function to crash; running this function in +`hierarchy-add-tree' with a root of 80 and no delayed children causes that to + crash." + + (funcall (lambda (funct) (funcall funct 1 funct)) + (lambda (n funct) + (if (< n num) + (+ 1 (funcall funct (+ 1 n) funct)) + 1)))) + +(defun hierarchy-examples-delayed--childrenfn (hier-elem) + "Return the children of HIER-ELEM. +Basially, feed the number, minus 1, to `hierarchy-examples-delayed--find-number' +and then create a list of the number plus 0.0–0.9." + + (when (> hier-elem 1) + (let ((next (hierarchy-examples-delayed--find-number (1- hier-elem)))) + (mapcar (lambda (dec) (+ next dec)) '(.0 .1 .2 .3 .4 .5 .6 .7 .8 .9))))) + +(ert-deftest hierarchy-delayed-add-one-root () + (let ((parentfn (lambda (_) nil)) + (hierarchy (hierarchy-new))) + (hierarchy-add-tree hierarchy 190 parentfn + #'hierarchy-examples-delayed--childrenfn nil t) + (should (equal (hierarchy-roots hierarchy) '(190))))) + +(ert-deftest hierarchy-delayed-add-one-item-with-parent () + (let ((parentfn (lambda (item) + (cl-case item + (190 191)))) + (hierarchy (hierarchy-new))) + (hierarchy-add-tree hierarchy 190 parentfn + #'hierarchy-examples-delayed--childrenfn nil t) + (should (equal (hierarchy-roots hierarchy) '(191))) + (should (equal (hierarchy-children hierarchy 191) '(190))) + (should (equal (hierarchy-children hierarchy 190) '())))) + +(ert-deftest hierarchy-delayed-add-one-item-with-parent-and-grand-parent () + (let ((parentfn (lambda (item) + (cl-case item + (190 191) + (191 192)))) + (hierarchy (hierarchy-new))) + (hierarchy-add-tree hierarchy 190 parentfn + #'hierarchy-examples-delayed--childrenfn nil t) + (should (equal (hierarchy-roots hierarchy) '(192))) + (should (equal (hierarchy-children hierarchy 192) '(191))) + (should (equal (hierarchy-children hierarchy 191) '(190))) + (should (equal (hierarchy-children hierarchy 190) '())))) + +(ert-deftest hierarchy-delayed-add-same-root-twice () + (let ((parentfn (lambda (_) nil)) + (hierarchy (hierarchy-new))) + (hierarchy-add-tree hierarchy 190 parentfn + #'hierarchy-examples-delayed--childrenfn nil t) + (hierarchy-add-tree hierarchy 190 parentfn + #'hierarchy-examples-delayed--childrenfn nil t) + (should (equal (hierarchy-roots hierarchy) '(190))))) + +(ert-deftest hierarchy-delayed-add-same-child-twice () + (let ((parentfn (lambda (item) + (cl-case item + (190 191)))) + (hierarchy (hierarchy-new))) + (hierarchy-add-tree hierarchy 190 parentfn + #'hierarchy-examples-delayed--childrenfn nil t) + (hierarchy-add-tree hierarchy 190 parentfn + #'hierarchy-examples-delayed--childrenfn nil t) + (should (equal (hierarchy-roots hierarchy) '(191))) + (should (equal (hierarchy-children hierarchy 191) '(190))) + (should (equal (hierarchy-children hierarchy 190) '())))) + +(ert-deftest hierarchy-delayed-add-item-and-its-parent () + (let ((parentfn (lambda (item) + (cl-case item + (190 191)))) + (hierarchy (hierarchy-new))) + (hierarchy-add-tree hierarchy 190 parentfn + #'hierarchy-examples-delayed--childrenfn nil t) + (hierarchy-add-tree hierarchy 191 parentfn + #'hierarchy-examples-delayed--childrenfn nil t) + (should (equal (hierarchy-roots hierarchy) '(191))) + (should (equal (hierarchy-children hierarchy 191) '(190))) + (should (equal (hierarchy-children hierarchy 190) '())))) + +(ert-deftest hierarchy-delayed-add-item-and-its-child () + (let ((parentfn (lambda (item) + (cl-case item + (190 191)))) + (hierarchy (hierarchy-new))) + (hierarchy-add-tree hierarchy 191 parentfn + #'hierarchy-examples-delayed--childrenfn nil t) + (hierarchy-add-tree hierarchy 190 parentfn + #'hierarchy-examples-delayed--childrenfn nil t) + (should (equal (hierarchy-roots hierarchy) '(191))) + (should (equal (hierarchy-children hierarchy 191) '(190))) + (should (equal (hierarchy-children hierarchy 190) '())))) + +(ert-deftest hierarchy-delayed-add-two-items-sharing-parent () + (let ((parentfn (lambda (item) + (cl-case item + (190 191) + (190.5 191)))) + (hierarchy (hierarchy-new))) + (hierarchy-add-tree hierarchy 190 parentfn + #'hierarchy-examples-delayed--childrenfn nil t) + (hierarchy-add-tree hierarchy 190.5 parentfn + #'hierarchy-examples-delayed--childrenfn nil t) + (should (equal (hierarchy-roots hierarchy) '(191))) + (should (equal (hierarchy-children hierarchy 191) '(190 190.5))))) + +(ert-deftest hierarchy-delayed-add-two-hierarchies () + (let ((parentfn (lambda (item) + (cl-case item + (190 191) + (circle 'shape)))) + (hierarchy (hierarchy-new))) + (hierarchy-add-tree hierarchy 190 parentfn + #'hierarchy-examples-delayed--childrenfn nil t) + (hierarchy-add-tree hierarchy 'circle parentfn) + (should (equal (hierarchy-roots hierarchy) '(191 shape))) + (should (equal (hierarchy-children hierarchy 191) '(190))) + (should (equal (hierarchy-children hierarchy 'shape) '(circle))))) + +(ert-deftest hierarchy-delayed-add-trees () + (let ((parentfn (lambda (item) + (cl-case item + (190 '191) + (190.5 '191) + (191 '192)))) + (hierarchy (hierarchy-new))) + (hierarchy-add-trees hierarchy '(191 190.5) parentfn + #'hierarchy-examples-delayed--childrenfn nil t) + (should (equal (hierarchy-roots hierarchy) '(192))) + (should (equal (hierarchy-children hierarchy '192) '(191))) + (should (equal (hierarchy-children hierarchy '191) '(190 190.5))))) + (provide 'hierarchy-tests) ;;; hierarchy-tests.el ends here -- 2.36.1 ^ permalink raw reply related [flat|nested] 15+ messages in thread
[parent not found: <87mtei1cii.fsf@outlook.com>]
* bug#55900: [PATCH] Hierarchy – Defer the Computation of Children [not found] ` <87mtei1cii.fsf@outlook.com> @ 2022-06-12 9:07 ` Jaft 2022-07-28 8:48 ` Eli Zaretskii [not found] ` <1383718586.2581914.1655024858024@mail.yahoo.com> 1 sibling, 1 reply; 15+ messages in thread From: Jaft @ 2022-06-12 9:07 UTC (permalink / raw) To: Eli Zaretskii; +Cc: 55900@debbugs.gnu.org [-- Attachment #1: Type: text/plain, Size: 2593 bytes --] Hmm; I tried to attach the patch with Gnus but it doesn't look like it actually added it…. Sending again, via the browser this time. On Sunday, June 12, 2022, 04:01:29 AM CDT, Wamm K. D. <jaft.r@outlook.com> wrote: > On Sat. (Jun 11, 2022) at 04:21:59 AM -04, Eli Zaretskii <eliz@gnu.org> wrote: >>> From: "Wamm K. D." <jaft.r@outlook.com> >>> Date: Sat, 11 Jun 2022 01:52:13 -0500 >>> >>> Pretty much as the subject describes; this should allow for users to >>> lazily load hierarchy branches when loading everything at once would >>> otherwise be too consuming, up-front (or if dealing with an infinite >>> tree). >> >> Thanks. >> >>> * lisp/emacs-lisp/hierarchy.el (hierarchy-add-tree) (hierarchy-add-trees): >>> Add parameter 'delay-children-p'. >> >> Please use our style of commit log messages. The above should be >> >> * lisp/emacs-lisp/hierarchy.el (hierarchy-add-tree) >> (hierarchy-add-trees): Add parameter 'delay-children-p'. > > Mmm; gotcha. This hadn't been clear, to me; I thought the example given > in the CONTRIBUTE file was that way because the line was long and the > main point of its demonstration was what to do with a case of more than > one function. I've adjusted the commit message appropriately, now. > >>> +(defun hierarchy--create-delayed-tree-widget (elem labelfn indent fn) >>> + "Return a list of tree-widgets for a hierarchy created from the childrenfn. >> >> The first line of the doc string should ideally mention the >> arguments. This one doesn't, and it also seems to misname one >> argument: it's FN, not childrenfn, right? > > Yeah; I was referencing the fact that this function is called childrenfn > in a bunch of other functions but, for whatever reason, I didn't call it > that here so that's why it isn't all-capitalized (while the reference to > it, at the end, is and says FN). But that's weird; I don't know why I > went with that name when I could've just…used the same name as every > other function. I've corrected that, standardized. > >> Can you add some tests of this new functionality? > > I've added some; I didn't created tests for children functionality since > the delayed computation means there aren't children (until someone > activates the tree-widget and the children are computed with the > provided function) but I create some tests to check that the root and > parent elements were still functioning as expected, when using delayed > children. > >> Also, I think this warrants a NEWS entry to describe the new feature. > > I've added that, as well. [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-Allow-Hierarchy-to-delay-computing-children.patch --] [-- Type: text/x-patch, Size: 15142 bytes --] From 1ad834830c5d35b92c9e5ef2161d875218c7c1b6 Mon Sep 17 00:00:00 2001 From: "Wamm K. D" <jaft.r@outlook.com> Date: Sun, 12 Jun 2022 03:48:01 -0500 Subject: [PATCH] Allow Hierarchy to delay computing children Add an option to allow users to specify that computing the children of the hierarchy should be delayed to when the user calls for them, by utilizing the tree-widget :expander property. * lisp/emacs-lisp/hierarchy.el (hierarchy-add-tree) (hierarchy-add-trees): Add parameter 'delay-children-p'. * lisp/emacs-lisp/hierarchy.el (hierarchy--create-delayed-tree-widget): Add function. * lisp/emacs-lisp/hierarchy.el (hierarchy-convert-to-tree-widget): Utilize ':expander' if delaying children. * test/lisp/emacs-lisp/hierarchy-tests.el: Add tests for delayed-children functionality. --- etc/NEWS | 9 ++ lisp/emacs-lisp/hierarchy.el | 86 ++++++++++++--- test/lisp/emacs-lisp/hierarchy-tests.el | 141 ++++++++++++++++++++++++ 3 files changed, 218 insertions(+), 18 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 424d1250c3..a8c863cd20 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1756,6 +1756,15 @@ Enabling this minor mode turns on hiding header material, like If non-nil, files untracked by a VCS are considered to be part of the project by a VC project based on that VCS. +** Hierarchy + ++++ +*** Tree Display can delay computation of children +'hierarchy-add-tree' and 'hierarchy-add-trees' have an optional +argument, 'delay-children-p', which allows storing 'childrenfn' to the +nodes of a tree-widget display to be activated and computed only when +the users expands the node. + --- ** The autoarg.el library is now marked obsolete. This library provides the 'autoarg-mode' and 'autoarg-kp-mode' minor diff --git a/lisp/emacs-lisp/hierarchy.el b/lisp/emacs-lisp/hierarchy.el index 6c95d86b47..316cdcb30b 100644 --- a/lisp/emacs-lisp/hierarchy.el +++ b/lisp/emacs-lisp/hierarchy.el @@ -71,7 +71,8 @@ (:conc-name hierarchy--)) (roots (list)) ; list of the hierarchy roots (no parent) (parents (make-hash-table :test 'equal)) ; map an item to its parent - (children (make-hash-table :test 'equal)) ; map an item to its childre + (children (make-hash-table :test 'equal)) ; map an item to its children + (delaying-parents (make-hash-table :test 'equal)) ; map an item to its childrenfn ;; cache containing the set of all items in the hierarchy (seen-items (make-hash-table :test 'equal))) ; map an item to t @@ -133,7 +134,8 @@ keys are :key and :test." "Create a hierarchy and return it." (hierarchy--make)) -(defun hierarchy-add-tree (hierarchy item parentfn &optional childrenfn acceptfn) +(defun hierarchy-add-tree (hierarchy item parentfn + &optional childrenfn acceptfn delay-children-p) "In HIERARCHY, add ITEM. PARENTFN is either nil or a function defining the child-to-parent @@ -151,27 +153,39 @@ CHILDRENFN are expected to be coherent with each other. ACCEPTFN is a function returning non-nil if its parameter (any object) should be an item of the hierarchy. By default, ACCEPTFN returns non-nil -if its parameter is non-nil." +if its parameter is non-nil. + +DELAY-CHILDREN-P is a predicate determining whether the children that would +normally be processed by CHILDRENFN should, instead, have their processing be +delayed and stored to be processed by CHILDRENFN when the child is selected +during use of the hierarchy." (unless (hierarchy-has-item hierarchy item) (let ((acceptfn (or acceptfn #'identity))) (hierarchy--seen-items-add hierarchy item) (let ((parent (and parentfn (funcall parentfn item)))) (when (funcall acceptfn parent) (hierarchy--add-relation hierarchy item parent acceptfn) - (hierarchy-add-tree hierarchy parent parentfn childrenfn))) - (let ((children (and childrenfn (funcall childrenfn item)))) - (mapc (lambda (child) - (when (funcall acceptfn child) - (hierarchy--add-relation hierarchy child item acceptfn) - (hierarchy-add-tree hierarchy child parentfn childrenfn))) - children))))) - -(defun hierarchy-add-trees (hierarchy items parentfn &optional childrenfn acceptfn) + (hierarchy-add-tree hierarchy parent + parentfn (if delay-children-p nil childrenfn)))) + (if (and childrenfn delay-children-p) + (map-put! (hierarchy--delaying-parents hierarchy) item childrenfn) + (let ((children (and childrenfn (funcall childrenfn item)))) + (map-put! (hierarchy--delaying-parents hierarchy) item nil) + (mapc (lambda (child) + (when (funcall acceptfn child) + (hierarchy--add-relation hierarchy child item acceptfn) + (hierarchy-add-tree hierarchy child parentfn childrenfn))) + children)))))) + +(defun hierarchy-add-trees (hierarchy items parentfn + &optional childrenfn acceptfn delay-children-p) "Call `hierarchy-add-tree' on HIERARCHY and each element of ITEMS. -PARENTFN, CHILDRENFN and ACCEPTFN have the same meaning as in `hierarchy-add'." +PARENTFN, CHILDRENFN, ACCEPTFN, and DELAY-CHILDREN-P have the same meaning as in +`hierarchy-add'." (seq-map (lambda (item) - (hierarchy-add-tree hierarchy item parentfn childrenfn acceptfn)) + (hierarchy-add-tree hierarchy item parentfn + childrenfn acceptfn delay-children-p)) items)) (defun hierarchy-add-list (hierarchy list &optional wrap childrenfn) @@ -541,6 +555,31 @@ nil. The buffer is returned." buffer)) (declare-function widget-convert "wid-edit") +(defun hierarchy--create-delayed-tree-widget (elem labelfn indent childrenfn) + "Return a list of tree-widgets for the children generated by calling +CHILDRENFN on ELEM. + +ELEM is the element of the hierarchy passed from +`hierarchy-convert-to-tree-widget'; it and the CHILDRENFN are used to generate +the children of the element dynamically. + +LABELFN is the same function passed to `hierarchy-convert-to-tree-widget'. + +INDENT is the same function passed to `hierarchy-convert-to-tree-widget'. + +CHILDRENFN is the function used to discover the children of ELEM." + (lambda (widget) + (mapcar + (lambda (item) + (widget-convert + 'tree-widget + :tag (hierarchy-labelfn-to-string labelfn item indent) + :expander (hierarchy--create-delayed-tree-widget + item + labelfn + (1+ indent) + childrenfn))) + (funcall childrenfn elem)))) (defun hierarchy-convert-to-tree-widget (hierarchy labelfn) "Return a tree-widget for HIERARCHY. @@ -550,10 +589,21 @@ node label." (require 'wid-edit) (require 'tree-widget) (hierarchy-map-tree (lambda (item indent children) - (widget-convert - 'tree-widget - :tag (hierarchy-labelfn-to-string labelfn item indent) - :args children)) + (let ((childrenfn (map-elt + (hierarchy--delaying-parents hierarchy) + item))) + (apply + #'widget-convert + (list 'tree-widget + :tag (hierarchy-labelfn-to-string labelfn item indent) + (if childrenfn :expander :args) + (if childrenfn + (hierarchy--create-delayed-tree-widget + item + labelfn + (1+ indent) + childrenfn) + children))))) hierarchy)) (defun hierarchy-tree-display (hierarchy labelfn &optional buffer) diff --git a/test/lisp/emacs-lisp/hierarchy-tests.el b/test/lisp/emacs-lisp/hierarchy-tests.el index 41d3f2f3cc..8ba86966ea 100644 --- a/test/lisp/emacs-lisp/hierarchy-tests.el +++ b/test/lisp/emacs-lisp/hierarchy-tests.el @@ -552,5 +552,146 @@ (hierarchy-sort organisms) (should (equal (hierarchy-roots organisms) '(animal plant))))) +(defun hierarchy-examples-delayed--find-number (num) + "Find a number, NUM, by adding 1s together until you reach it. +This is entire contrived and mostly meant to be purposefully inefficient to +not be possible on a large scale. +Running the number 200 causes this function to crash; running this function in +`hierarchy-add-tree' with a root of 80 and no delayed children causes that to + crash." + + (funcall (lambda (funct) (funcall funct 1 funct)) + (lambda (n funct) + (if (< n num) + (+ 1 (funcall funct (+ 1 n) funct)) + 1)))) + +(defun hierarchy-examples-delayed--childrenfn (hier-elem) + "Return the children of HIER-ELEM. +Basially, feed the number, minus 1, to `hierarchy-examples-delayed--find-number' +and then create a list of the number plus 0.0–0.9." + + (when (> hier-elem 1) + (let ((next (hierarchy-examples-delayed--find-number (1- hier-elem)))) + (mapcar (lambda (dec) (+ next dec)) '(.0 .1 .2 .3 .4 .5 .6 .7 .8 .9))))) + +(ert-deftest hierarchy-delayed-add-one-root () + (let ((parentfn (lambda (_) nil)) + (hierarchy (hierarchy-new))) + (hierarchy-add-tree hierarchy 190 parentfn + #'hierarchy-examples-delayed--childrenfn nil t) + (should (equal (hierarchy-roots hierarchy) '(190))))) + +(ert-deftest hierarchy-delayed-add-one-item-with-parent () + (let ((parentfn (lambda (item) + (cl-case item + (190 191)))) + (hierarchy (hierarchy-new))) + (hierarchy-add-tree hierarchy 190 parentfn + #'hierarchy-examples-delayed--childrenfn nil t) + (should (equal (hierarchy-roots hierarchy) '(191))) + (should (equal (hierarchy-children hierarchy 191) '(190))) + (should (equal (hierarchy-children hierarchy 190) '())))) + +(ert-deftest hierarchy-delayed-add-one-item-with-parent-and-grand-parent () + (let ((parentfn (lambda (item) + (cl-case item + (190 191) + (191 192)))) + (hierarchy (hierarchy-new))) + (hierarchy-add-tree hierarchy 190 parentfn + #'hierarchy-examples-delayed--childrenfn nil t) + (should (equal (hierarchy-roots hierarchy) '(192))) + (should (equal (hierarchy-children hierarchy 192) '(191))) + (should (equal (hierarchy-children hierarchy 191) '(190))) + (should (equal (hierarchy-children hierarchy 190) '())))) + +(ert-deftest hierarchy-delayed-add-same-root-twice () + (let ((parentfn (lambda (_) nil)) + (hierarchy (hierarchy-new))) + (hierarchy-add-tree hierarchy 190 parentfn + #'hierarchy-examples-delayed--childrenfn nil t) + (hierarchy-add-tree hierarchy 190 parentfn + #'hierarchy-examples-delayed--childrenfn nil t) + (should (equal (hierarchy-roots hierarchy) '(190))))) + +(ert-deftest hierarchy-delayed-add-same-child-twice () + (let ((parentfn (lambda (item) + (cl-case item + (190 191)))) + (hierarchy (hierarchy-new))) + (hierarchy-add-tree hierarchy 190 parentfn + #'hierarchy-examples-delayed--childrenfn nil t) + (hierarchy-add-tree hierarchy 190 parentfn + #'hierarchy-examples-delayed--childrenfn nil t) + (should (equal (hierarchy-roots hierarchy) '(191))) + (should (equal (hierarchy-children hierarchy 191) '(190))) + (should (equal (hierarchy-children hierarchy 190) '())))) + +(ert-deftest hierarchy-delayed-add-item-and-its-parent () + (let ((parentfn (lambda (item) + (cl-case item + (190 191)))) + (hierarchy (hierarchy-new))) + (hierarchy-add-tree hierarchy 190 parentfn + #'hierarchy-examples-delayed--childrenfn nil t) + (hierarchy-add-tree hierarchy 191 parentfn + #'hierarchy-examples-delayed--childrenfn nil t) + (should (equal (hierarchy-roots hierarchy) '(191))) + (should (equal (hierarchy-children hierarchy 191) '(190))) + (should (equal (hierarchy-children hierarchy 190) '())))) + +(ert-deftest hierarchy-delayed-add-item-and-its-child () + (let ((parentfn (lambda (item) + (cl-case item + (190 191)))) + (hierarchy (hierarchy-new))) + (hierarchy-add-tree hierarchy 191 parentfn + #'hierarchy-examples-delayed--childrenfn nil t) + (hierarchy-add-tree hierarchy 190 parentfn + #'hierarchy-examples-delayed--childrenfn nil t) + (should (equal (hierarchy-roots hierarchy) '(191))) + (should (equal (hierarchy-children hierarchy 191) '(190))) + (should (equal (hierarchy-children hierarchy 190) '())))) + +(ert-deftest hierarchy-delayed-add-two-items-sharing-parent () + (let ((parentfn (lambda (item) + (cl-case item + (190 191) + (190.5 191)))) + (hierarchy (hierarchy-new))) + (hierarchy-add-tree hierarchy 190 parentfn + #'hierarchy-examples-delayed--childrenfn nil t) + (hierarchy-add-tree hierarchy 190.5 parentfn + #'hierarchy-examples-delayed--childrenfn nil t) + (should (equal (hierarchy-roots hierarchy) '(191))) + (should (equal (hierarchy-children hierarchy 191) '(190 190.5))))) + +(ert-deftest hierarchy-delayed-add-two-hierarchies () + (let ((parentfn (lambda (item) + (cl-case item + (190 191) + (circle 'shape)))) + (hierarchy (hierarchy-new))) + (hierarchy-add-tree hierarchy 190 parentfn + #'hierarchy-examples-delayed--childrenfn nil t) + (hierarchy-add-tree hierarchy 'circle parentfn) + (should (equal (hierarchy-roots hierarchy) '(191 shape))) + (should (equal (hierarchy-children hierarchy 191) '(190))) + (should (equal (hierarchy-children hierarchy 'shape) '(circle))))) + +(ert-deftest hierarchy-delayed-add-trees () + (let ((parentfn (lambda (item) + (cl-case item + (190 '191) + (190.5 '191) + (191 '192)))) + (hierarchy (hierarchy-new))) + (hierarchy-add-trees hierarchy '(191 190.5) parentfn + #'hierarchy-examples-delayed--childrenfn nil t) + (should (equal (hierarchy-roots hierarchy) '(192))) + (should (equal (hierarchy-children hierarchy '192) '(191))) + (should (equal (hierarchy-children hierarchy '191) '(190 190.5))))) + (provide 'hierarchy-tests) ;;; hierarchy-tests.el ends here -- 2.36.1 ^ permalink raw reply related [flat|nested] 15+ messages in thread
* bug#55900: [PATCH] Hierarchy – Defer the Computation of Children 2022-06-12 9:07 ` Jaft @ 2022-07-28 8:48 ` Eli Zaretskii 0 siblings, 0 replies; 15+ messages in thread From: Eli Zaretskii @ 2022-07-28 8:48 UTC (permalink / raw) To: Jaft; +Cc: 55900 > Date: Sun, 12 Jun 2022 09:07:37 +0000 (UTC) > From: Jaft <jaft.r@outlook.com> > Cc: "55900@debbugs.gnu.org" <55900@debbugs.gnu.org> > > Hmm; I tried to attach the patch with Gnus but it doesn't look like it actually added it…. Sending again, via the browser this time. Thanks. Please see the few minor comments below. > --- a/etc/NEWS > +++ b/etc/NEWS > @@ -1756,6 +1756,15 @@ Enabling this minor mode turns on hiding header material, like > If non-nil, files untracked by a VCS are considered to be part of > the project by a VC project based on that VCS. > > +** Hierarchy > + > ++++ > +*** Tree Display can delay computation of children > +'hierarchy-add-tree' and 'hierarchy-add-trees' have an optional > +argument, 'delay-children-p', which allows storing 'childrenfn' to the > +nodes of a tree-widget display to be activated and computed only when > +the users expands the node. The first line (the heading) should end in a dot '.' The description itself is OK, but it sounds too detailed for NEWS. I'd suggest to make it shorter by dropping the reference to the optional argument's name and the "storing" part. It should be enough to say "which allows tree-widget display to be activated and computed only when the user expands the node". > (declare-function widget-convert "wid-edit") > +(defun hierarchy--create-delayed-tree-widget (elem labelfn indent childrenfn) > + "Return a list of tree-widgets for the children generated by calling > +CHILDRENFN on ELEM. The first line of a doc string should be a complete sentence. This is an internal function, so you could make the first sentence be less detailed. > --- a/test/lisp/emacs-lisp/hierarchy-tests.el > +++ b/test/lisp/emacs-lisp/hierarchy-tests.el > @@ -552,5 +552,146 @@ > (hierarchy-sort organisms) > (should (equal (hierarchy-roots organisms) '(animal plant))))) > > +(defun hierarchy-examples-delayed--find-number (num) > + "Find a number, NUM, by adding 1s together until you reach it. > +This is entire contrived and mostly meant to be purposefully inefficient to > +not be possible on a large scale. > +Running the number 200 causes this function to crash; running this function in > +`hierarchy-add-tree' with a root of 80 and no delayed children causes that to > + crash." Can you explain better what is the purpose of this function in the context of the tests which use it? ^ permalink raw reply [flat|nested] 15+ messages in thread
[parent not found: <1383718586.2581914.1655024858024@mail.yahoo.com>]
* bug#55900: [PATCH] Hierarchy – Defer the Computation of Children [not found] ` <1383718586.2581914.1655024858024@mail.yahoo.com> @ 2022-07-27 12:36 ` Jaft 2022-07-28 8:52 ` Eli Zaretskii 0 siblings, 1 reply; 15+ messages in thread From: Jaft @ 2022-07-27 12:36 UTC (permalink / raw) To: Eli Zaretskii; +Cc: 55900@debbugs.gnu.org Just checking if there was anything else I needed to provide for this or if my new additions are satisfactory. ^ permalink raw reply [flat|nested] 15+ messages in thread
* bug#55900: [PATCH] Hierarchy – Defer the Computation of Children 2022-07-27 12:36 ` Jaft @ 2022-07-28 8:52 ` Eli Zaretskii 2022-08-04 0:20 ` Jaft 0 siblings, 1 reply; 15+ messages in thread From: Eli Zaretskii @ 2022-07-28 8:52 UTC (permalink / raw) To: Jaft; +Cc: 55900 > Date: Wed, 27 Jul 2022 12:36:55 +0000 (UTC) > From: Jaft <jaft.r@outlook.com> > Cc: "55900@debbugs.gnu.org" <55900@debbugs.gnu.org> > > Just checking if there was anything else I needed to provide for this or if my new additions are satisfactory. Sorry for the delay. I've just sent a few minor comments to the patch. And I don't see a copyright assignment from you on file. Did you do the legal paperwork for that, and if so, when was that? Thanks. ^ permalink raw reply [flat|nested] 15+ messages in thread
* bug#55900: [PATCH] Hierarchy – Defer the Computation of Children 2022-07-28 8:52 ` Eli Zaretskii @ 2022-08-04 0:20 ` Jaft 2022-08-04 6:12 ` Eli Zaretskii 0 siblings, 1 reply; 15+ messages in thread From: Jaft @ 2022-08-04 0:20 UTC (permalink / raw) To: Eli Zaretskii; +Cc: 55900@debbugs.gnu.org [-- Attachment #1: Type: text/plain, Size: 829 bytes --] > On Thursday, July 28, 2022, 03:51:59 AM CDT, Eli Zaretskii <eliz@gnu.org> wrote: > > > > > > > Date: Wed, 27 Jul 2022 12:36:55 +0000 (UTC) > > From: Jaft <jaft.r@outlook.com> > > Cc: "55900@debbugs.gnu.org" <55900@debbugs.gnu.org> > > > > Just checking if there was anything else I needed to provide for this or if my new additions are satisfactory. > > Sorry for the delay. I've just sent a few minor comments to the > patch. No worries; I think I've addressed your comments. > And I don't see a copyright assignment from you on file. Did you do > the legal paperwork for that, and if so, when was that? I have not yet; this is my first code contribution to Emacs so I'm not entirely familiar with the process, I'm afraid. What steps should I take to accomplish this? > Thanks. No problem. [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-Allow-Hierarchy-to-delay-computing-children.patch --] [-- Type: text/x-patch, Size: 15033 bytes --] From 47881e04dc55952b8216a7591736d6172d9e5db1 Mon Sep 17 00:00:00 2001 From: "Wamm K. D" <jaft.r@outlook.com> Date: Wed, 3 Aug 2022 19:05:08 -0500 Subject: [PATCH] Allow Hierarchy to delay computing children Add an option to allow users to specify that computing the children of the hierarchy should be delayed to when the user calls for them, by utilizing the tree-widget :expander property. * lisp/emacs-lisp/hierarchy.el (hierarchy-add-tree) (hierarchy-add-trees): Add parameter 'delay-children-p'. * lisp/emacs-lisp/hierarchy.el (hierarchy--create-delayed-tree-widget): Add function. * lisp/emacs-lisp/hierarchy.el (hierarchy-convert-to-tree-widget): Utilize ':expander' if delaying children. * test/lisp/emacs-lisp/hierarchy-tests.el: Add tests for delayed-children functionality. --- etc/NEWS | 8 ++ lisp/emacs-lisp/hierarchy.el | 85 +++++++++++--- test/lisp/emacs-lisp/hierarchy-tests.el | 143 ++++++++++++++++++++++++ 3 files changed, 218 insertions(+), 18 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 7e8ed465eb..41d39cb8c5 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2142,6 +2142,14 @@ the shell session terminates. *** New user option 'calc-kill-line-numbering'. Set it to nil to exclude line numbering from kills and copies. +** Hierarchy + ++++ +*** Tree Display can delay computation of children. +'hierarchy-add-tree' and 'hierarchy-add-trees' have an optional +argument which allows tree-widget display to be activated and computed +only when the user expands the node. + ** Miscellaneous --- diff --git a/lisp/emacs-lisp/hierarchy.el b/lisp/emacs-lisp/hierarchy.el index 6c95d86b47..4cb5ba64a8 100644 --- a/lisp/emacs-lisp/hierarchy.el +++ b/lisp/emacs-lisp/hierarchy.el @@ -71,7 +71,8 @@ (:conc-name hierarchy--)) (roots (list)) ; list of the hierarchy roots (no parent) (parents (make-hash-table :test 'equal)) ; map an item to its parent - (children (make-hash-table :test 'equal)) ; map an item to its childre + (children (make-hash-table :test 'equal)) ; map an item to its children + (delaying-parents (make-hash-table :test 'equal)) ; map an item to its childrenfn ;; cache containing the set of all items in the hierarchy (seen-items (make-hash-table :test 'equal))) ; map an item to t @@ -133,7 +134,8 @@ keys are :key and :test." "Create a hierarchy and return it." (hierarchy--make)) -(defun hierarchy-add-tree (hierarchy item parentfn &optional childrenfn acceptfn) +(defun hierarchy-add-tree (hierarchy item parentfn + &optional childrenfn acceptfn delay-children-p) "In HIERARCHY, add ITEM. PARENTFN is either nil or a function defining the child-to-parent @@ -151,27 +153,39 @@ CHILDRENFN are expected to be coherent with each other. ACCEPTFN is a function returning non-nil if its parameter (any object) should be an item of the hierarchy. By default, ACCEPTFN returns non-nil -if its parameter is non-nil." +if its parameter is non-nil. + +DELAY-CHILDREN-P is a predicate determining whether the children that would +normally be processed by CHILDRENFN should, instead, have their processing be +delayed and stored to be processed by CHILDRENFN when the child is selected +during use of the hierarchy." (unless (hierarchy-has-item hierarchy item) (let ((acceptfn (or acceptfn #'identity))) (hierarchy--seen-items-add hierarchy item) (let ((parent (and parentfn (funcall parentfn item)))) (when (funcall acceptfn parent) (hierarchy--add-relation hierarchy item parent acceptfn) - (hierarchy-add-tree hierarchy parent parentfn childrenfn))) - (let ((children (and childrenfn (funcall childrenfn item)))) - (mapc (lambda (child) - (when (funcall acceptfn child) - (hierarchy--add-relation hierarchy child item acceptfn) - (hierarchy-add-tree hierarchy child parentfn childrenfn))) - children))))) - -(defun hierarchy-add-trees (hierarchy items parentfn &optional childrenfn acceptfn) + (hierarchy-add-tree hierarchy parent + parentfn (if delay-children-p nil childrenfn)))) + (if (and childrenfn delay-children-p) + (map-put! (hierarchy--delaying-parents hierarchy) item childrenfn) + (let ((children (and childrenfn (funcall childrenfn item)))) + (map-put! (hierarchy--delaying-parents hierarchy) item nil) + (mapc (lambda (child) + (when (funcall acceptfn child) + (hierarchy--add-relation hierarchy child item acceptfn) + (hierarchy-add-tree hierarchy child parentfn childrenfn))) + children)))))) + +(defun hierarchy-add-trees (hierarchy items parentfn + &optional childrenfn acceptfn delay-children-p) "Call `hierarchy-add-tree' on HIERARCHY and each element of ITEMS. -PARENTFN, CHILDRENFN and ACCEPTFN have the same meaning as in `hierarchy-add'." +PARENTFN, CHILDRENFN, ACCEPTFN, and DELAY-CHILDREN-P have the same meaning as in +`hierarchy-add'." (seq-map (lambda (item) - (hierarchy-add-tree hierarchy item parentfn childrenfn acceptfn)) + (hierarchy-add-tree hierarchy item parentfn + childrenfn acceptfn delay-children-p)) items)) (defun hierarchy-add-list (hierarchy list &optional wrap childrenfn) @@ -541,6 +555,30 @@ nil. The buffer is returned." buffer)) (declare-function widget-convert "wid-edit") +(defun hierarchy--create-delayed-tree-widget (elem labelfn indent childrenfn) + "Return a list of tree-widgets for the children generated. + +ELEM is the element of the hierarchy passed from +`hierarchy-convert-to-tree-widget'; it and the CHILDRENFN are used to generate +the children of the element dynamically. + +LABELFN is the same function passed to `hierarchy-convert-to-tree-widget'. + +INDENT is the same function passed to `hierarchy-convert-to-tree-widget'. + +CHILDRENFN is the function used to discover the children of ELEM." + (lambda (widget) + (mapcar + (lambda (item) + (widget-convert + 'tree-widget + :tag (hierarchy-labelfn-to-string labelfn item indent) + :expander (hierarchy--create-delayed-tree-widget + item + labelfn + (1+ indent) + childrenfn))) + (funcall childrenfn elem)))) (defun hierarchy-convert-to-tree-widget (hierarchy labelfn) "Return a tree-widget for HIERARCHY. @@ -550,10 +588,21 @@ node label." (require 'wid-edit) (require 'tree-widget) (hierarchy-map-tree (lambda (item indent children) - (widget-convert - 'tree-widget - :tag (hierarchy-labelfn-to-string labelfn item indent) - :args children)) + (let ((childrenfn (map-elt + (hierarchy--delaying-parents hierarchy) + item))) + (apply + #'widget-convert + (list 'tree-widget + :tag (hierarchy-labelfn-to-string labelfn item indent) + (if childrenfn :expander :args) + (if childrenfn + (hierarchy--create-delayed-tree-widget + item + labelfn + (1+ indent) + childrenfn) + children))))) hierarchy)) (defun hierarchy-tree-display (hierarchy labelfn &optional buffer) diff --git a/test/lisp/emacs-lisp/hierarchy-tests.el b/test/lisp/emacs-lisp/hierarchy-tests.el index 41d3f2f3cc..d83460a2ba 100644 --- a/test/lisp/emacs-lisp/hierarchy-tests.el +++ b/test/lisp/emacs-lisp/hierarchy-tests.el @@ -552,5 +552,148 @@ (hierarchy-sort organisms) (should (equal (hierarchy-roots organisms) '(animal plant))))) +(defun hierarchy-examples-delayed--find-number (num) + "Find a number, NUM, by adding 1s together until you reach it. +This is entire contrived and mostly meant to be purposefully inefficient to +not be possible on a large scale. +Running the number 200 causes this function to crash; running this function in +`hierarchy-add-tree' with a root of 80 and no delayed children causes that to + crash. +If generating hierarchy children is not delayed, tests for that functionality +should fail as this function will crash." + + (funcall (lambda (funct) (funcall funct 1 funct)) + (lambda (n funct) + (if (< n num) + (+ 1 (funcall funct (+ 1 n) funct)) + 1)))) + +(defun hierarchy-examples-delayed--childrenfn (hier-elem) + "Return the children of HIER-ELEM. +Basially, feed the number, minus 1, to `hierarchy-examples-delayed--find-number' +and then create a list of the number plus 0.0–0.9." + + (when (> hier-elem 1) + (let ((next (hierarchy-examples-delayed--find-number (1- hier-elem)))) + (mapcar (lambda (dec) (+ next dec)) '(.0 .1 .2 .3 .4 .5 .6 .7 .8 .9))))) + +(ert-deftest hierarchy-delayed-add-one-root () + (let ((parentfn (lambda (_) nil)) + (hierarchy (hierarchy-new))) + (hierarchy-add-tree hierarchy 190 parentfn + #'hierarchy-examples-delayed--childrenfn nil t) + (should (equal (hierarchy-roots hierarchy) '(190))))) + +(ert-deftest hierarchy-delayed-add-one-item-with-parent () + (let ((parentfn (lambda (item) + (cl-case item + (190 191)))) + (hierarchy (hierarchy-new))) + (hierarchy-add-tree hierarchy 190 parentfn + #'hierarchy-examples-delayed--childrenfn nil t) + (should (equal (hierarchy-roots hierarchy) '(191))) + (should (equal (hierarchy-children hierarchy 191) '(190))) + (should (equal (hierarchy-children hierarchy 190) '())))) + +(ert-deftest hierarchy-delayed-add-one-item-with-parent-and-grand-parent () + (let ((parentfn (lambda (item) + (cl-case item + (190 191) + (191 192)))) + (hierarchy (hierarchy-new))) + (hierarchy-add-tree hierarchy 190 parentfn + #'hierarchy-examples-delayed--childrenfn nil t) + (should (equal (hierarchy-roots hierarchy) '(192))) + (should (equal (hierarchy-children hierarchy 192) '(191))) + (should (equal (hierarchy-children hierarchy 191) '(190))) + (should (equal (hierarchy-children hierarchy 190) '())))) + +(ert-deftest hierarchy-delayed-add-same-root-twice () + (let ((parentfn (lambda (_) nil)) + (hierarchy (hierarchy-new))) + (hierarchy-add-tree hierarchy 190 parentfn + #'hierarchy-examples-delayed--childrenfn nil t) + (hierarchy-add-tree hierarchy 190 parentfn + #'hierarchy-examples-delayed--childrenfn nil t) + (should (equal (hierarchy-roots hierarchy) '(190))))) + +(ert-deftest hierarchy-delayed-add-same-child-twice () + (let ((parentfn (lambda (item) + (cl-case item + (190 191)))) + (hierarchy (hierarchy-new))) + (hierarchy-add-tree hierarchy 190 parentfn + #'hierarchy-examples-delayed--childrenfn nil t) + (hierarchy-add-tree hierarchy 190 parentfn + #'hierarchy-examples-delayed--childrenfn nil t) + (should (equal (hierarchy-roots hierarchy) '(191))) + (should (equal (hierarchy-children hierarchy 191) '(190))) + (should (equal (hierarchy-children hierarchy 190) '())))) + +(ert-deftest hierarchy-delayed-add-item-and-its-parent () + (let ((parentfn (lambda (item) + (cl-case item + (190 191)))) + (hierarchy (hierarchy-new))) + (hierarchy-add-tree hierarchy 190 parentfn + #'hierarchy-examples-delayed--childrenfn nil t) + (hierarchy-add-tree hierarchy 191 parentfn + #'hierarchy-examples-delayed--childrenfn nil t) + (should (equal (hierarchy-roots hierarchy) '(191))) + (should (equal (hierarchy-children hierarchy 191) '(190))) + (should (equal (hierarchy-children hierarchy 190) '())))) + +(ert-deftest hierarchy-delayed-add-item-and-its-child () + (let ((parentfn (lambda (item) + (cl-case item + (190 191)))) + (hierarchy (hierarchy-new))) + (hierarchy-add-tree hierarchy 191 parentfn + #'hierarchy-examples-delayed--childrenfn nil t) + (hierarchy-add-tree hierarchy 190 parentfn + #'hierarchy-examples-delayed--childrenfn nil t) + (should (equal (hierarchy-roots hierarchy) '(191))) + (should (equal (hierarchy-children hierarchy 191) '(190))) + (should (equal (hierarchy-children hierarchy 190) '())))) + +(ert-deftest hierarchy-delayed-add-two-items-sharing-parent () + (let ((parentfn (lambda (item) + (cl-case item + (190 191) + (190.5 191)))) + (hierarchy (hierarchy-new))) + (hierarchy-add-tree hierarchy 190 parentfn + #'hierarchy-examples-delayed--childrenfn nil t) + (hierarchy-add-tree hierarchy 190.5 parentfn + #'hierarchy-examples-delayed--childrenfn nil t) + (should (equal (hierarchy-roots hierarchy) '(191))) + (should (equal (hierarchy-children hierarchy 191) '(190 190.5))))) + +(ert-deftest hierarchy-delayed-add-two-hierarchies () + (let ((parentfn (lambda (item) + (cl-case item + (190 191) + (circle 'shape)))) + (hierarchy (hierarchy-new))) + (hierarchy-add-tree hierarchy 190 parentfn + #'hierarchy-examples-delayed--childrenfn nil t) + (hierarchy-add-tree hierarchy 'circle parentfn) + (should (equal (hierarchy-roots hierarchy) '(191 shape))) + (should (equal (hierarchy-children hierarchy 191) '(190))) + (should (equal (hierarchy-children hierarchy 'shape) '(circle))))) + +(ert-deftest hierarchy-delayed-add-trees () + (let ((parentfn (lambda (item) + (cl-case item + (190 '191) + (190.5 '191) + (191 '192)))) + (hierarchy (hierarchy-new))) + (hierarchy-add-trees hierarchy '(191 190.5) parentfn + #'hierarchy-examples-delayed--childrenfn nil t) + (should (equal (hierarchy-roots hierarchy) '(192))) + (should (equal (hierarchy-children hierarchy '192) '(191))) + (should (equal (hierarchy-children hierarchy '191) '(190 190.5))))) + (provide 'hierarchy-tests) ;;; hierarchy-tests.el ends here -- 2.37.1 ^ permalink raw reply related [flat|nested] 15+ messages in thread
* bug#55900: [PATCH] Hierarchy – Defer the Computation of Children 2022-08-04 0:20 ` Jaft @ 2022-08-04 6:12 ` Eli Zaretskii 2022-10-27 16:13 ` Jaft 0 siblings, 1 reply; 15+ messages in thread From: Eli Zaretskii @ 2022-08-04 6:12 UTC (permalink / raw) To: Jaft; +Cc: 55900 > Date: Thu, 4 Aug 2022 00:20:05 +0000 (UTC) > From: Jaft <jaft.r@outlook.com> > Cc: "55900@debbugs.gnu.org" <55900@debbugs.gnu.org> > > > Sorry for the delay. I've just sent a few minor comments to the > > patch. > > No worries; I think I've addressed your comments. Thanks, I will look at that soon. > > And I don't see a copyright assignment from you on file. Did you do > > the legal paperwork for that, and if so, when was that? > > I have not yet; this is my first code contribution to Emacs so I'm not entirely familiar with the process, I'm afraid. What steps should I take to accomplish this? Instructions sent off-list. ^ permalink raw reply [flat|nested] 15+ messages in thread
* bug#55900: [PATCH] Hierarchy – Defer the Computation of Children 2022-08-04 6:12 ` Eli Zaretskii @ 2022-10-27 16:13 ` Jaft 2022-10-27 17:17 ` Eli Zaretskii 0 siblings, 1 reply; 15+ messages in thread From: Jaft @ 2022-10-27 16:13 UTC (permalink / raw) To: Eli Zaretskii; +Cc: 55900@debbugs.gnu.org [-- Attachment #1: Type: text/plain, Size: 901 bytes --] Hi, Eli. I've submitted my copyright assignment and've been informed it's been completed. We should be ready to proceed, as far as I understand. On Thursday, August 4, 2022 at 01:12:39 AM CDT, Eli Zaretskii <eliz@gnu.org> wrote: > Date: Thu, 4 Aug 2022 00:20:05 +0000 (UTC) > From: Jaft <jaft.r@outlook.com> > Cc: "55900@debbugs.gnu.org" <55900@debbugs.gnu.org> > > > Sorry for the delay. I've just sent a few minor comments to the > > patch. > > No worries; I think I've addressed your comments. Thanks, I will look at that soon. > > And I don't see a copyright assignment from you on file. Did you do > > the legal paperwork for that, and if so, when was that? > > I have not yet; this is my first code contribution to Emacs so I'm not entirely familiar with the process, I'm afraid. What steps should I take to accomplish this? Instructions sent off-list. [-- Attachment #2: Type: text/html, Size: 2476 bytes --] ^ permalink raw reply [flat|nested] 15+ messages in thread
* bug#55900: [PATCH] Hierarchy – Defer the Computation of Children 2022-10-27 16:13 ` Jaft @ 2022-10-27 17:17 ` Eli Zaretskii 2022-10-27 19:14 ` Jaft 0 siblings, 1 reply; 15+ messages in thread From: Eli Zaretskii @ 2022-10-27 17:17 UTC (permalink / raw) To: Jaft; +Cc: 55900 > Date: Thu, 27 Oct 2022 16:13:05 +0000 (UTC) > From: Jaft <jaft.r@outlook.com> > Cc: "55900@debbugs.gnu.org" <55900@debbugs.gnu.org> > > I've submitted my copyright assignment and've been informed it's been completed. > > We should be ready to proceed, as far as I understand. Thanks. I installed the changeset, but one of the tests you added fails here: Test hierarchy-delayed-add-trees backtrace: signal(ert-test-failed (((should (equal (hierarchy-children hierarch ert-fail(((should (equal (hierarchy-children hierarchy '191) '(190 1 (if (unwind-protect (setq value-714 (apply fn-712 args-713)) (setq f (let (form-description-716) (if (unwind-protect (setq value-714 (app (let ((value-714 'ert-form-evaluation-aborted-715)) (let (form-descr (let* ((fn-712 #'equal) (args-713 (condition-case err (let ((signal- (let ((parentfn #'(lambda (item) (cond ((eql item ...) '191) ((eql i (closure (t) nil (let ((parentfn #'(lambda (item) (cond (... ...) (. ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-test ert-run-test(#s(ert-test :name hierarchy-delayed-add-trees :document ert-run-or-rerun-test(#s(ert--stats :selector ... :tests ... :test-m ert-run-tests((not (or (tag :unstable) (tag :nativecomp))) #f(compil ert-run-tests-batch((not (or (tag :unstable) (tag :nativecomp)))) ert-run-tests-batch-and-exit((not (or (tag :unstable) (tag :nativeco eval((ert-run-tests-batch-and-exit '(not (or (tag :unstable) (tag :n command-line-1(("-L" ";." "-l" "ert" "-l" "lisp/emacs-lisp/hierarchy command-line() normal-top-level() Test hierarchy-delayed-add-trees condition: (ert-test-failed ((should (equal (hierarchy-children hierarchy ...) '(190 190.5))) :form (equal (190.5) (190 190.5)) :value nil :explanation (proper-lists-of-different-length 1 2 (190.5) (190 190.5) first-mismatch-at 0))) FAILED 24/68 hierarchy-delayed-add-trees (0.000000 sec) at lisp/emacs-lisp/hierarchy-tests.el:685 Could you please work on fixing this test? Thanks. ^ permalink raw reply [flat|nested] 15+ messages in thread
* bug#55900: [PATCH] Hierarchy – Defer the Computation of Children 2022-10-27 17:17 ` Eli Zaretskii @ 2022-10-27 19:14 ` Jaft 2022-10-28 7:36 ` Eli Zaretskii 0 siblings, 1 reply; 15+ messages in thread From: Jaft @ 2022-10-27 19:14 UTC (permalink / raw) To: Eli Zaretskii; +Cc: 55900@debbugs.gnu.org [-- Attachment #1.1: Type: text/plain, Size: 2707 bytes --] Sorry about that, Eli. Looks like it was a typo, on my part; I could've sworn I'd went through and, you know, run each of these tests when I'd first made them so I'm sorry this one seemed to've slipped through. It looks to be passing, now, with the proper values in place. On Thursday, October 27, 2022 at 12:17:37 PM CDT, Eli Zaretskii <eliz@gnu.org> wrote: > Date: Thu, 27 Oct 2022 16:13:05 +0000 (UTC) > From: Jaft <jaft.r@outlook.com> > Cc: "55900@debbugs.gnu.org" <55900@debbugs.gnu.org> > > I've submitted my copyright assignment and've been informed it's been completed. > > We should be ready to proceed, as far as I understand. Thanks. I installed the changeset, but one of the tests you added fails here: Test hierarchy-delayed-add-trees backtrace: signal(ert-test-failed (((should (equal (hierarchy-children hierarch ert-fail(((should (equal (hierarchy-children hierarchy '191) '(190 1 (if (unwind-protect (setq value-714 (apply fn-712 args-713)) (setq f (let (form-description-716) (if (unwind-protect (setq value-714 (app (let ((value-714 'ert-form-evaluation-aborted-715)) (let (form-descr (let* ((fn-712 #'equal) (args-713 (condition-case err (let ((signal- (let ((parentfn #'(lambda (item) (cond ((eql item ...) '191) ((eql i (closure (t) nil (let ((parentfn #'(lambda (item) (cond (... ...) (. ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-test ert-run-test(#s(ert-test :name hierarchy-delayed-add-trees :document ert-run-or-rerun-test(#s(ert--stats :selector ... :tests ... :test-m ert-run-tests((not (or (tag :unstable) (tag :nativecomp))) #f(compil ert-run-tests-batch((not (or (tag :unstable) (tag :nativecomp)))) ert-run-tests-batch-and-exit((not (or (tag :unstable) (tag :nativeco eval((ert-run-tests-batch-and-exit '(not (or (tag :unstable) (tag :n command-line-1(("-L" ";." "-l" "ert" "-l" "lisp/emacs-lisp/hierarchy command-line() normal-top-level() Test hierarchy-delayed-add-trees condition: (ert-test-failed ((should (equal (hierarchy-children hierarchy ...) '(190 190.5))) :form (equal (190.5) (190 190.5)) :value nil :explanation (proper-lists-of-different-length 1 2 (190.5) (190 190.5) first-mismatch-at 0))) FAILED 24/68 hierarchy-delayed-add-trees (0.000000 sec) at lisp/emacs-lisp/hierarchy-tests.el:685 Could you please work on fixing this test? Thanks. [-- Attachment #1.2: Type: text/html, Size: 5415 bytes --] [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-Fix-failing-test-for-package-Hierarchy.patch --] [-- Type: text/x-patch, Size: 1208 bytes --] From d1f00a672953cfb1a58959cd32f09ae63a4172ee Mon Sep 17 00:00:00 2001 From: "Wamm K. D" <jaft.r@outlook.com> Date: Thu, 27 Oct 2022 14:07:03 -0500 Subject: [PATCH] Fix failing test for package Hierarchy This fixes a typo in one of the tests of Hierarchy which was causing the test to fail. * test/lisp/emacs-lisp/hierarchy-tests.el: Fix typo in hierarchy-delayed-add-trees --- test/lisp/emacs-lisp/hierarchy-tests.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/lisp/emacs-lisp/hierarchy-tests.el b/test/lisp/emacs-lisp/hierarchy-tests.el index d83460a2ba..97a0f7ba52 100644 --- a/test/lisp/emacs-lisp/hierarchy-tests.el +++ b/test/lisp/emacs-lisp/hierarchy-tests.el @@ -689,7 +689,7 @@ and then create a list of the number plus 0.0–0.9." (190.5 '191) (191 '192)))) (hierarchy (hierarchy-new))) - (hierarchy-add-trees hierarchy '(191 190.5) parentfn + (hierarchy-add-trees hierarchy '(190 190.5) parentfn #'hierarchy-examples-delayed--childrenfn nil t) (should (equal (hierarchy-roots hierarchy) '(192))) (should (equal (hierarchy-children hierarchy '192) '(191))) -- 2.38.0 ^ permalink raw reply related [flat|nested] 15+ messages in thread
* bug#55900: [PATCH] Hierarchy – Defer the Computation of Children 2022-10-27 19:14 ` Jaft @ 2022-10-28 7:36 ` Eli Zaretskii 2022-10-28 7:52 ` Jaft 0 siblings, 1 reply; 15+ messages in thread From: Eli Zaretskii @ 2022-10-28 7:36 UTC (permalink / raw) To: Jaft; +Cc: 55900-done > Date: Thu, 27 Oct 2022 19:14:15 +0000 (UTC) > From: Jaft <jaft.r@outlook.com> > Cc: "55900@debbugs.gnu.org" <55900@debbugs.gnu.org> > > Sorry about that, Eli. Looks like it was a typo, on my part; I could've sworn I'd went through and, you know, run > each of these tests when I'd first made them so I'm sorry this one seemed to've slipped through. It looks to be > passing, now, with the proper values in place. Thanks, installed, and the tests pass now. Please in the future make sure you commit your changes in a repository clone where our Git commit hooks are used, so that your patches won't be rejected when I install them. This patch you sent had too long lines in the commit log message, so it was rejected, and I needed to fix that by hand. ^ permalink raw reply [flat|nested] 15+ messages in thread
* bug#55900: [PATCH] Hierarchy – Defer the Computation of Children 2022-10-28 7:36 ` Eli Zaretskii @ 2022-10-28 7:52 ` Jaft 2022-10-28 7:56 ` Eli Zaretskii 0 siblings, 1 reply; 15+ messages in thread From: Jaft @ 2022-10-28 7:52 UTC (permalink / raw) To: Eli Zaretskii; +Cc: 55900-done@debbugs.gnu.org [-- Attachment #1: Type: text/plain, Size: 1004 bytes --] Oh; sure thing, will do. Does the Savannah repo. not have them? That was the one I'd used. I made the commit with Magit, from there. On Friday, October 28, 2022 at 02:36:33 AM CDT, Eli Zaretskii <eliz@gnu.org> wrote: > Date: Thu, 27 Oct 2022 19:14:15 +0000 (UTC) > From: Jaft <jaft.r@outlook.com> > Cc: "55900@debbugs.gnu.org" <55900@debbugs.gnu.org> > > Sorry about that, Eli. Looks like it was a typo, on my part; I could've sworn I'd went through and, you know, run > each of these tests when I'd first made them so I'm sorry this one seemed to've slipped through. It looks to be > passing, now, with the proper values in place. Thanks, installed, and the tests pass now. Please in the future make sure you commit your changes in a repository clone where our Git commit hooks are used, so that your patches won't be rejected when I install them. This patch you sent had too long lines in the commit log message, so it was rejected, and I needed to fix that by hand. [-- Attachment #2: Type: text/html, Size: 2348 bytes --] ^ permalink raw reply [flat|nested] 15+ messages in thread
* bug#55900: [PATCH] Hierarchy – Defer the Computation of Children 2022-10-28 7:52 ` Jaft @ 2022-10-28 7:56 ` Eli Zaretskii 0 siblings, 0 replies; 15+ messages in thread From: Eli Zaretskii @ 2022-10-28 7:56 UTC (permalink / raw) To: Jaft; +Cc: 55900 > Date: Fri, 28 Oct 2022 07:52:20 +0000 (UTC) > From: Jaft <jaft.r@outlook.com> > Cc: "55900-done@debbugs.gnu.org" <55900-done@debbugs.gnu.org> > > Oh; sure thing, will do. Does the Savannah repo. not have them? That was the one I'd used. I made the > commit with Magit, from there. I don't know what Magit does. When you clone the repository, you should have the hooks in the .git/hooks/ subdirectory of the repository. ^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2022-10-28 7:56 UTC | newest] Thread overview: 15+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2022-06-11 6:52 bug#55900: [PATCH] Hierarchy – Defer the Computation of Children Wamm K. D. 2022-06-11 8:21 ` Eli Zaretskii 2022-06-12 9:01 ` Wamm K. D. [not found] ` <87mtei1cii.fsf@outlook.com> 2022-06-12 9:07 ` Jaft 2022-07-28 8:48 ` Eli Zaretskii [not found] ` <1383718586.2581914.1655024858024@mail.yahoo.com> 2022-07-27 12:36 ` Jaft 2022-07-28 8:52 ` Eli Zaretskii 2022-08-04 0:20 ` Jaft 2022-08-04 6:12 ` Eli Zaretskii 2022-10-27 16:13 ` Jaft 2022-10-27 17:17 ` Eli Zaretskii 2022-10-27 19:14 ` Jaft 2022-10-28 7:36 ` Eli Zaretskii 2022-10-28 7:52 ` Jaft 2022-10-28 7:56 ` Eli Zaretskii
Code repositories for project(s) associated with this external index https://git.savannah.gnu.org/cgit/emacs.git https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.