From unknown Mon Jun 23 18:28:50 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#38378 <38378@debbugs.gnu.org> To: bug#38378 <38378@debbugs.gnu.org> Subject: Status: 26.3.50; [PATCH] Add the hierarchy library Reply-To: bug#38378 <38378@debbugs.gnu.org> Date: Tue, 24 Jun 2025 01:28:50 +0000 retitle 38378 26.3.50; [PATCH] Add the hierarchy library reassign 38378 emacs submitter 38378 Damien Cassou severity 38378 wishlist tag 38378 patch fixed thanks From debbugs-submit-bounces@debbugs.gnu.org Mon Nov 25 14:04:51 2019 Received: (at submit) by debbugs.gnu.org; 25 Nov 2019 19:04:51 +0000 Received: from localhost ([127.0.0.1]:49693 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iZJfF-00077X-OU for submit@debbugs.gnu.org; Mon, 25 Nov 2019 14:04:51 -0500 Received: from lists.gnu.org ([209.51.188.17]:39349) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iZJfC-00077P-SL for submit@debbugs.gnu.org; Mon, 25 Nov 2019 14:04:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41970) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iZJf5-0002Mw-SG for bug-gnu-emacs@gnu.org; Mon, 25 Nov 2019 14:04:46 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,URIBL_BLOCKED autolearn=disabled version=3.3.2 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iZJeu-0006E1-67 for bug-gnu-emacs@gnu.org; Mon, 25 Nov 2019 14:04:36 -0500 Received: from mail.choca.pics ([62.210.108.126]:42510) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iZJep-0006As-HL; Mon, 25 Nov 2019 14:04:26 -0500 Received: from localhost (localhost.localdomain [IPv6:::1]) by mail.choca.pics (Postfix) with ESMTP id C3E6DF1EAF0; Mon, 25 Nov 2019 20:03:46 +0100 (CET) Received: from mail.choca.pics ([IPv6:::1]) by localhost (mail.choca.pics [IPv6:::1]) (amavisd-new, port 10032) with ESMTP id 08j1iQdy3eIr; Mon, 25 Nov 2019 20:03:40 +0100 (CET) Received: from localhost (localhost.localdomain [IPv6:::1]) by mail.choca.pics (Postfix) with ESMTP id 17C28F1EAF1; Mon, 25 Nov 2019 20:03:40 +0100 (CET) X-Virus-Scanned: amavisd-new at choca.pics Received: from mail.choca.pics ([IPv6:::1]) by localhost (mail.choca.pics [IPv6:::1]) (amavisd-new, port 10026) with ESMTP id Lhs8rlTqy2tP; Mon, 25 Nov 2019 20:03:39 +0100 (CET) Received: from luz4 (254.116.5.93.rev.sfr.net [93.5.116.254]) by mail.choca.pics (Postfix) with ESMTPSA id 5CE37F1EAF0; Mon, 25 Nov 2019 20:03:39 +0100 (CET) From: Damien Cassou To: bug-gnu-emacs@gnu.org Subject: 26.3.50; [PATCH] Add the hierarchy library Date: Mon, 25 Nov 2019 20:03:38 +0100 Message-ID: <871rtv3hit.fsf@cassou.me> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 62.210.108.126 X-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: submit Cc: johnw@newartisans.com, joaotavora@gmail.com, eliz@gnu.org, monnier@IRO.UMontreal.CA, clement.pitclaudel@live.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.4 (--) --=-=-= Content-Type: text/plain Hi everyone, Please find attached a patch adding hierarchy.el and hierarchy-tests.el. The hierarchy library allows to create, query, navigate and display hierarchy structures. Two years ago, I suggested adding this library to ELPA and you guys on CC answered you wanted it in Emacs core: https://lists.gnu.org/archive/html/emacs-devel/2017-10/msg00624.html You also had several suggestions and I implemented none of them. I agree they all make sense, I just haven't found motivation to do that yet because hierarchy is working well for me already. What do you think? -- Damien Cassou "Success is the ability to go from one failure to another without losing enthusiasm." --Winston Churchill --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-lisp-emacs-lisp-hierarchy.el-New-file.patch >From 98c2a5bb85f591dd0da75bf2bc5b06cdcd70fdfc Mon Sep 17 00:00:00 2001 From: Damien Cassou Date: Mon, 25 Nov 2019 19:44:49 +0100 Subject: [PATCH] * lisp/emacs-lisp/hierarchy.el: New file. * test/lisp/emacs-lisp/hierarchy-tests.el: New file. --- lisp/emacs-lisp/hierarchy.el | 566 ++++++++++++++++++++++++ test/lisp/emacs-lisp/hierarchy-tests.el | 556 +++++++++++++++++++++++ 2 files changed, 1122 insertions(+) create mode 100644 lisp/emacs-lisp/hierarchy.el create mode 100644 test/lisp/emacs-lisp/hierarchy-tests.el diff --git a/lisp/emacs-lisp/hierarchy.el b/lisp/emacs-lisp/hierarchy.el new file mode 100644 index 0000000000..4e6d7f1fde --- /dev/null +++ b/lisp/emacs-lisp/hierarchy.el @@ -0,0 +1,566 @@ +;;; hierarchy.el --- Library to create and display hierarchy structures -*- lexical-binding: t; -*- + +;; Copyright (C) 2017-2019 Damien Cassou + +;; Author: Damien Cassou +;; Maintainer: emacs-devel@gnu.org + +;; This file is part of GNU Emacs. + +;; GNU Emacs 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. + +;; GNU Emacs 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 GNU Emacs. If not, see . + +;;; Commentary: + +;; Library to create, query, navigate and display hierarchy structures. + +;; Creation: After having created a hierarchy with `hierarchy-new', populate it by +;; calling `hierarchy-add-tree' or `hierarchy-add-trees'. You can then optionally sort its +;; element with `hierarchy-sort'. + +;; Querying: You can learn more about your hierarchy by using functions such as +;; `hierarchy-roots', `hierarchy-has-item', `hierarchy-length', `hierarchy-parent', `hierarchy-descendant-p'. + +;; Navigation: When your hierarchy is ready, you can use `hierarchy-map-item', `hierarchy-map', +;; and `map-tree' to apply functions to elements of the hierarchy. + +;; Display: You can display a hierarchy as a tabulated list using +;; `hierarchy-tabulated-display' and as an expandable/foldable tree +;; using `hierarchy-convert-to-tree-widget'. The +;; `hierarchy-labelfn-*' functions will help you display each item of +;; the hierarchy the way you want it. + +;;; Limitation: + +;; - Current implementation uses #'equal to find and distinguish +;; elements. Support for user-provided equality definition is +;; desired but not yet implemented; +;; +;; - nil can't be added to a hierarchy; +;; +;; - the hierarchy is computed eagerly. + +;;; Code: + +(require 'seq) +(require 'map) +(require 'subr-x) + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Helpers +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(cl-defstruct (hierarchy + (:constructor hierarchy--make) + (: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 + ;; cache containing the set of all items in the hierarchy + (seen-items (make-hash-table :test 'equal))) ; map an item to t + +(defun hierarchy--seen-items-add (hierarchy item) + "In HIERARCHY, add ITEM to seen items." + (map-put (hierarchy--seen-items hierarchy) item t)) + +(defun hierarchy--compute-roots (hierarchy) + "Search roots of HIERARCHY and return them." + (cl-set-difference + (map-keys (hierarchy--seen-items hierarchy)) + (map-keys (hierarchy--parents hierarchy)) + :test #'equal)) + +(defun hierarchy--sort-roots (hierarchy sortfn) + "Compute, sort and store the roots of HIERARCHY. + +SORTFN is a function taking two items of the hierarchy as parameter and +returning non-nil if the first parameter is lower than the second." + (setf (hierarchy--roots hierarchy) + (sort (hierarchy--compute-roots hierarchy) + sortfn))) + +(defun hierarchy--add-relation (hierarchy item parent acceptfn) + "In HIERARCHY, add ITEM as child of PARENT. + +ACCEPTFN is a function returning non-nil if its parameter (any object) +should be an item of the hierarchy." + (let* ((existing-parent (hierarchy-parent hierarchy item)) + (has-parent-p (funcall acceptfn existing-parent))) + (cond + ((and has-parent-p (not (equal existing-parent parent))) + (error "An item (%s) can only have one parent: '%s' vs '%s'" + item existing-parent parent)) + ((not has-parent-p) + (let ((existing-children (map-elt (hierarchy--children hierarchy) parent (list)))) + (map-put (hierarchy--children hierarchy) parent (append existing-children (list item)))) + (map-put (hierarchy--parents hierarchy) item parent))))) + +(defun hierarchy--set-equal (list1 list2 &rest cl-keys) + "Return non-nil if LIST1 and LIST2 have same elements. + +I.e., if every element of LIST1 also appears in LIST2 and if +every element of LIST2 also appears in LIST1. + +CL-KEYS are key-value pairs just like in `cl-subsetp'. Supported +keys are :key and :test." + (and (apply 'cl-subsetp list1 list2 cl-keys) + (apply 'cl-subsetp list2 list1 cl-keys))) + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Creation +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defun hierarchy-new () + "Create a hierarchy and return it." + (hierarchy--make)) + +(defun hierarchy-add-tree (hierarchy item parentfn &optional childrenfn acceptfn) + "In HIERARCHY, add ITEM. + +PARENTFN is either nil or a function defining the child-to-parent +relationship: this function takes an item as parameter and should return +the parent of this item in the hierarchy. If the item has no parent in the +hierarchy (i.e., it should be a root), the function should return an object +not accepted by acceptfn (i.e., nil for the default value of acceptfn). + +CHILDRENFN is either nil or a function defining the parent-to-children +relationship: this function takes an item as parameter and should return a +list of children of this item in the hierarchy. + +If both PARENTFN and CHILDRENFN are non-nil, the results of PARENTFN and +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." + (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) + "Call `hierarchy-add-tree' on HIERARCHY and each element of ITEMS. + +PARENTFN, CHILDRENFN and ACCEPTFN have the same meaning as in `hierarchy-add'." + (seq-map (lambda (item) + (hierarchy-add-tree hierarchy item parentfn childrenfn acceptfn)) + items)) + +(defun hierarchy-add-list (hierarchy list &optional wrap childrenfn) + "Add to HIERARCHY the sub-lists in LIST. + +If WRAP is non-nil, allow duplicate items in LIST by wraping each +item in a cons (id . item). The root's id is 1. + +CHILDRENFN is a function (defaults to `cdr') taking LIST as a +parameter which should return LIST's children (a list). Each +child is (recursively) passed as a parameter to CHILDRENFN to get +its own children. Because of this parameter, LIST can be +anything, not necessarily a list." + (let* ((childrenfn (or childrenfn #'cdr)) + (id 0) + (wrapfn (lambda (item) + (if wrap + (cons (setq id (1+ id)) item) + item))) + (unwrapfn (if wrap #'cdr #'identity))) + (hierarchy-add-tree + hierarchy (funcall wrapfn list) nil + (lambda (item) + (mapcar wrapfn (funcall childrenfn + (funcall unwrapfn item))))) + hierarchy)) + +(defun hierarchy-from-list (list &optional wrap childrenfn) + "Create and return a hierarchy built from LIST. + +This function passes LIST, WRAP and CHILDRENFN unchanged to +`hierarchy-add-list'." + (hierarchy-add-list (hierarchy-new) list wrap childrenfn)) + +(defun hierarchy-sort (hierarchy &optional sortfn) + "Modify HIERARCHY so that its roots and item's children are sorted. + +SORTFN is a function taking two items of the hierarchy as parameter and +returning non-nil if the first parameter is lower than the second. By +default, SORTFN is `string-lessp'." + (let ((sortfn (or sortfn #'string-lessp))) + (hierarchy--sort-roots hierarchy sortfn) + (mapc (lambda (parent) + (setf + (map-elt (hierarchy--children hierarchy) parent) + (sort (map-elt (hierarchy--children hierarchy) parent) sortfn))) + (map-keys (hierarchy--children hierarchy))))) + +(defun hierarchy-extract-tree (hierarchy item) + "Return a copy of HIERARCHY with ITEM's descendants and parents." + (if (not (hierarchy-has-item hierarchy item)) + nil + (let ((tree (hierarchy-new))) + (hierarchy-add-tree tree item + (lambda (each) (hierarchy-parent hierarchy each)) + (lambda (each) + (when (or (equal each item) + (hierarchy-descendant-p hierarchy each item)) + (hierarchy-children hierarchy each)))) + tree))) + +(defun hierarchy-copy (hierarchy) + "Return a copy of HIERARCHY. + +Items in HIERARCHY are shared, but structure is not." + (hierarchy-map-hierarchy (lambda (item _) (identity item)) hierarchy)) + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Querying +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defun hierarchy-items (hierarchy) + "Return a list of all items of HIERARCHY." + (map-keys (hierarchy--seen-items hierarchy))) + +(defun hierarchy-has-item (hierarchy item) + "Return t if HIERARCHY includes ITEM." + (map-contains-key (hierarchy--seen-items hierarchy) item)) + +(defun hierarchy-empty-p (hierarchy) + "Return t if HIERARCHY is empty." + (= 0 (hierarchy-length hierarchy))) + +(defun hierarchy-length (hierarchy) + "Return the number of items in HIERARCHY." + (hash-table-count (hierarchy--seen-items hierarchy))) + +(defun hierarchy-has-root (hierarchy item) + "Return t if one of HIERARCHY's roots is ITEM. + +A root is an item with no parent." + (seq-contains (hierarchy-roots hierarchy) item)) + +(defun hierarchy-roots (hierarchy) + "Return all roots of HIERARCHY. + +A root is an item with no parent." + (let ((roots (hierarchy--roots hierarchy))) + (or roots + (hierarchy--compute-roots hierarchy)))) + +(defun hierarchy-leafs (hierarchy &optional node) + "Return all leafs of HIERARCHY. + +A leaf is an item with no child. + +If NODE is an item of HIERARCHY, only return leafs under NODE." + (let ((leafs (cl-set-difference + (map-keys (hierarchy--seen-items hierarchy)) + (map-keys (hierarchy--children hierarchy))))) + (if (hierarchy-has-item hierarchy node) + (seq-filter (lambda (item) (hierarchy-descendant-p hierarchy item node)) leafs) + leafs))) + +(defun hierarchy-parent (hierarchy item) + "In HIERARCHY, return parent of ITEM." + (map-elt (hierarchy--parents hierarchy) item)) + +(defun hierarchy-children (hierarchy parent) + "In HIERARCHY, return children of PARENT." + (map-elt (hierarchy--children hierarchy) parent (list))) + +(defun hierarchy-child-p (hierarchy item1 item2) + "In HIERARCHY, return non-nil if and only if ITEM1 is a child of ITEM2." + (equal (hierarchy-parent hierarchy item1) item2)) + +(defun hierarchy-descendant-p (hierarchy item1 item2) + "In HIERARCHY, return non-nil if and only if ITEM1 is a descendant of ITEM2. + +ITEM1 is a descendant of ITEM2 if and only if both are items of HIERARCHY +and either: + +- ITEM1 is child of ITEM2, or +- ITEM1's parent is a descendant of ITEM2." + (and + (hierarchy-has-item hierarchy item1) + (hierarchy-has-item hierarchy item2) + (or + (hierarchy-child-p hierarchy item1 item2) + (hierarchy-descendant-p hierarchy (hierarchy-parent hierarchy item1) item2)))) + +(defun hierarchy-equal (hierarchy1 hierarchy2) + "Return t if HIERARCHY1 and HIERARCHY2 are equal. + +Two equal hierarchies share the same items and the same +relationships among them." + (and (hierarchy-p hierarchy1) + (hierarchy-p hierarchy2) + (= (hierarchy-length hierarchy1) (hierarchy-length hierarchy2)) + ;; parents are the same + (seq-every-p (lambda (child) + (equal (hierarchy-parent hierarchy1 child) + (hierarchy-parent hierarchy2 child))) + (map-keys (hierarchy--parents hierarchy1))) + ;; children are the same + (seq-every-p (lambda (parent) + (hierarchy--set-equal + (hierarchy-children hierarchy1 parent) + (hierarchy-children hierarchy2 parent) + :test #'equal)) + (map-keys (hierarchy--children hierarchy1))))) + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Navigation +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defun hierarchy-map-item (func item hierarchy &optional indent) + "Return the result of applying FUNC to ITEM and its descendants in HIERARCHY. + +This function navigates the tree top-down: FUNCTION is first called on item +and then on each of its children. Results are concatenated in a list. + +INDENT is a number (default 0) representing the indentation of ITEM in +HIERARCHY. FUNC should take 2 argument: the item and its indentation +level." + (let ((indent (or indent 0))) + (cons + (funcall func item indent) + (seq-mapcat (lambda (child) (hierarchy-map-item func child hierarchy (1+ indent))) + (hierarchy-children hierarchy item))))) + +(defun hierarchy-map (func hierarchy &optional indent) + "Return the result of applying FUNC to each element of HIERARCHY. + +This function navigates the tree top-down: FUNCTION is first called on each +root. To do so, it calls `hierarchy-map-item' on each root +sequentially. Results are concatenated in a list. + +FUNC should take 2 arguments: the item and its indentation level. + +INDENT is a number (default 0) representing the indentation of HIERARCHY's +roots." + (let ((indent (or indent 0))) + (seq-mapcat (lambda (root) (hierarchy-map-item func root hierarchy indent)) + (hierarchy-roots hierarchy)))) + +(defun hierarchy-map-tree (function hierarchy &optional item indent) + "Apply FUNCTION on each item of HIERARCHY under ITEM. + +This function navigates the tree bottom-up: FUNCTION is first called on +leafs and the result is passed as parameter when calling FUNCTION on +parents. + +FUNCTION should take 3 parameters: the current item, its indentation +level (a number), and a list representing the result of applying +`hierarchy-map-tree' to each child of the item. + +INDENT is 0 by default and is passed as second parameter to FUNCTION. +INDENT is incremented by 1 at each level of the tree. + +This function returns the result of applying FUNCTION to ITEM (the first +root if nil)." + (let ((item (or item (car (hierarchy-roots hierarchy)))) + (indent (or indent 0))) + (funcall function item indent + (mapcar (lambda (child) + (hierarchy-map-tree function hierarchy child (1+ indent))) + (hierarchy-children hierarchy item))))) + +(defun hierarchy-map-hierarchy (function hierarchy) + "Apply FUNCTION to each item of HIERARCHY in a new hierarchy. + +FUNCTION should take 2 parameters, the current item and its +indentation level (a number), and should return an item to be +added to the new hierarchy." + (let* ((items (make-hash-table :test #'equal)) + (transform (lambda (item) (map-elt items item)))) + ;; Make 'items', a table mapping original items to their + ;; transformation + (hierarchy-map (lambda (item indent) + (map-put items item (funcall function item indent))) + hierarchy) + (hierarchy--make + :roots (mapcar transform (hierarchy-roots hierarchy)) + :parents (let ((result (make-hash-table :test #'equal))) + (map-apply (lambda (child parent) + (map-put result + (funcall transform child) + (funcall transform parent))) + (hierarchy--parents hierarchy)) + result) + :children (let ((result (make-hash-table :test #'equal))) + (map-apply (lambda (parent children) + (map-put result + (funcall transform parent) + (seq-map transform children))) + (hierarchy--children hierarchy)) + result) + :seen-items (let ((result (make-hash-table :test #'equal))) + (map-apply (lambda (item v) + (map-put result + (funcall transform item) + v)) + (hierarchy--seen-items hierarchy)) + result)))) + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Display +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defun hierarchy-labelfn-indent (labelfn &optional indent-string) + "Return a function rendering LABELFN indented with INDENT-STRING. + +INDENT-STRING defaults to a 2-space string. Indentation is +multiplied by the depth of the displayed item." + (let ((indent-string (or indent-string " "))) + (lambda (item indent) + (dotimes (_ indent) (insert indent-string)) + (funcall labelfn item indent)))) + +(defun hierarchy-labelfn-button (labelfn actionfn) + "Return a function rendering LABELFN in a button. + +Clicking the button triggers ACTIONFN. ACTIONFN is a function +taking an item of HIERARCHY and an indentation value (a number) +as input. This function is called when an item is clicked. The +return value of ACTIONFN is ignored." + (lambda (item indent) + (let ((start (point))) + (funcall labelfn item indent) + (make-text-button start (point) + 'action (lambda (_) (funcall actionfn item indent)))))) + +(defun hierarchy-labelfn-button-if (labelfn buttonp actionfn) + "Return a function rendering LABELFN as a button if BUTTONP. + +Pass LABELFN and ACTIONFN to `hierarchy-labelfn-button' if +BUTTONP is non-nil. Otherwise, render LABELFN without making it +a button. + +BUTTONP is a function taking an item of HIERARCHY and an +indentation value (a number) as input." + (lambda (item indent) + (if (funcall buttonp item indent) + (funcall (hierarchy-labelfn-button labelfn actionfn) item indent) + (funcall labelfn item indent)))) + +(defun hierarchy-labelfn-to-string (labelfn item indent) + "Execute LABELFN on ITEM and INDENT. Return result as a string." + (with-temp-buffer + (funcall labelfn item indent) + (buffer-substring (point-min) (point-max)))) + +(defun hierarchy-print (hierarchy &optional to-string) + "Insert HIERARCHY in current buffer as plain text. + +Use TO-STRING to convert each element to a string. TO-STRING is +a function taking an item of HIERARCHY as input and returning a +string. If nil, TO-STRING defaults to a call to `format' with \"%s\"." + (let ((to-string (or to-string (lambda (item) (format "%s" item))))) + (hierarchy-map + (hierarchy-labelfn-indent (lambda (item _) (insert (funcall to-string item) "\n"))) + hierarchy))) + +(defun hierarchy-to-string (hierarchy &optional to-string) + "Return a string representing HIERARCHY. + +TO-STRING is passed unchanged to `hierarchy-print'." + (with-temp-buffer + (hierarchy-print hierarchy to-string) + (buffer-substring (point-min) (point-max)))) + +(defun hierarchy-tabulated-imenu-action (_item-name position) + "Move to ITEM-NAME at POSITION in current buffer." + (goto-char position) + (back-to-indentation)) + +(define-derived-mode hierarchy-tabulated-mode tabulated-list-mode "Hierarchy tabulated" + "Major mode to display a hierarchy as a tabulated list." + (setq-local imenu-generic-expression + ;; debbugs: 26457 - Cannot pass a function to + ;; imenu-generic-expression. Add + ;; `hierarchy-tabulated-imenu-action' to the end of the + ;; list when bug is fixed + '(("Item" "^[[:space:]]+\\(?1:.+\\)$" 1)))) + +(defun hierarchy-tabulated-display (hierarchy labelfn &optional buffer) + "Display HIERARCHY as a tabulated list in `hierarchy-tabulated-mode'. + +LABELFN is a function taking an item of HIERARCHY and an indentation +level (a number) as input and inserting a string to be displayed in the +table. + +The tabulated list is displayed in BUFFER, or a newly created buffer if +nil. The buffer is returned." + (let ((buffer (or buffer (generate-new-buffer "hierarchy-tabulated")))) + (with-current-buffer buffer + (hierarchy-tabulated-mode) + (setq tabulated-list-format + (vector '("Item name" 0 nil))) + (setq tabulated-list-entries + (hierarchy-map (lambda (item indent) + (list item (vector (hierarchy-labelfn-to-string labelfn item indent)))) + hierarchy)) + (tabulated-list-init-header) + (tabulated-list-print)) + buffer)) + +(declare-function widget-convert "wid-edit") +(defun hierarchy-convert-to-tree-widget (hierarchy labelfn) + "Return a tree-widget for HIERARCHY. + +LABELFN is a function taking an item of HIERARCHY and an indentation +value (a number) as parameter and inserting a string to be displayed as a +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)) + hierarchy)) + +(defun hierarchy-tree-display (hierarchy labelfn &optional buffer) + "Display HIERARCHY as a tree widget in a new buffer. + +HIERARCHY and LABELFN are passed unchanged to +`hierarchy-convert-to-tree-widget'. + +The tree widget is displayed in BUFFER, or a newly created buffer if +nil. The buffer is returned." + (let ((buffer (or buffer (generate-new-buffer "*hierarchy-tree*"))) + (tree-widget (hierarchy-convert-to-tree-widget hierarchy labelfn))) + (with-current-buffer buffer + (setq-local buffer-read-only t) + (let ((inhibit-read-only t)) + (erase-buffer) + (widget-create tree-widget) + (goto-char (point-min)) + (special-mode))) + buffer)) + +(provide 'hierarchy) + +;;; hierarchy.el ends here diff --git a/test/lisp/emacs-lisp/hierarchy-tests.el b/test/lisp/emacs-lisp/hierarchy-tests.el new file mode 100644 index 0000000000..23cfc79d84 --- /dev/null +++ b/test/lisp/emacs-lisp/hierarchy-tests.el @@ -0,0 +1,556 @@ +;;; hierarchy-tests.el --- Tests for hierarchy.el + +;; Copyright (C) 2017-2019 Damien Cassou + +;; Author: Damien Cassou +;; Maintainer: emacs-devel@gnu.org + +;; This file is part of GNU Emacs. + +;; GNU Emacs 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. + +;; GNU Emacs 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 GNU Emacs. If not, see . + +;;; Commentary: + +;; Tests for hierarchy.el + +;;; Code: + +(require 'ert) +(require 'hierarchy) + +(defun hierarchy-animals () + "Create a sorted animal hierarchy." + (let ((parentfn (lambda (item) (cl-case item + (dove 'bird) + (pigeon 'bird) + (bird 'animal) + (dolphin 'animal) + (cow 'animal)))) + (hierarchy (hierarchy-new))) + (hierarchy-add-tree hierarchy 'dove parentfn) + (hierarchy-add-tree hierarchy 'pigeon parentfn) + (hierarchy-add-tree hierarchy 'dolphin parentfn) + (hierarchy-add-tree hierarchy 'cow parentfn) + (hierarchy-sort hierarchy) + hierarchy)) + +(ert-deftest hierarchy-add-one-root () + (let ((parentfn (lambda (_) nil)) + (hierarchy (hierarchy-new))) + (hierarchy-add-tree hierarchy 'animal parentfn) + (should (equal (hierarchy-roots hierarchy) '(animal))))) + +(ert-deftest hierarchy-add-one-item-with-parent () + (let ((parentfn (lambda (item) + (cl-case item + (bird 'animal)))) + (hierarchy (hierarchy-new))) + (hierarchy-add-tree hierarchy 'bird parentfn) + (should (equal (hierarchy-roots hierarchy) '(animal))) + (should (equal (hierarchy-children hierarchy 'animal) '(bird))))) + +(ert-deftest hierarchy-add-one-item-with-parent-and-grand-parent () + (let ((parentfn (lambda (item) + (cl-case item + (dove 'bird) + (bird 'animal)))) + (hierarchy (hierarchy-new))) + (hierarchy-add-tree hierarchy 'dove parentfn) + (should (equal (hierarchy-roots hierarchy) '(animal))) + (should (equal (hierarchy-children hierarchy 'animal) '(bird))) + (should (equal (hierarchy-children hierarchy 'bird) '(dove))))) + +(ert-deftest hierarchy-add-same-root-twice () + (let ((parentfn (lambda (_) nil)) + (hierarchy (hierarchy-new))) + (hierarchy-add-tree hierarchy 'animal parentfn) + (hierarchy-add-tree hierarchy 'animal parentfn) + (should (equal (hierarchy-roots hierarchy) '(animal))))) + +(ert-deftest hierarchy-add-same-child-twice () + (let ((parentfn (lambda (item) + (cl-case item + (bird 'animal)))) + (hierarchy (hierarchy-new))) + (hierarchy-add-tree hierarchy 'bird parentfn) + (hierarchy-add-tree hierarchy 'bird parentfn) + (should (equal (hierarchy-roots hierarchy) '(animal))) + (should (equal (hierarchy-children hierarchy 'animal) '(bird))))) + +(ert-deftest hierarchy-add-item-and-its-parent () + (let ((parentfn (lambda (item) + (cl-case item + (bird 'animal)))) + (hierarchy (hierarchy-new))) + (hierarchy-add-tree hierarchy 'bird parentfn) + (hierarchy-add-tree hierarchy 'animal parentfn) + (should (equal (hierarchy-roots hierarchy) '(animal))) + (should (equal (hierarchy-children hierarchy 'animal) '(bird))))) + +(ert-deftest hierarchy-add-item-and-its-child () + (let ((parentfn (lambda (item) + (cl-case item + (bird 'animal)))) + (hierarchy (hierarchy-new))) + (hierarchy-add-tree hierarchy 'animal parentfn) + (hierarchy-add-tree hierarchy 'bird parentfn) + (should (equal (hierarchy-roots hierarchy) '(animal))) + (should (equal (hierarchy-children hierarchy 'animal) '(bird))))) + +(ert-deftest hierarchy-add-two-items-sharing-parent () + (let ((parentfn (lambda (item) + (cl-case item + (dove 'bird) + (pigeon 'bird)))) + (hierarchy (hierarchy-new))) + (hierarchy-add-tree hierarchy 'dove parentfn) + (hierarchy-add-tree hierarchy 'pigeon parentfn) + (should (equal (hierarchy-roots hierarchy) '(bird))) + (should (equal (hierarchy-children hierarchy 'bird) '(dove pigeon))))) + +(ert-deftest hierarchy-add-two-hierarchies () + (let ((parentfn (lambda (item) + (cl-case item + (dove 'bird) + (circle 'shape)))) + (hierarchy (hierarchy-new))) + (hierarchy-add-tree hierarchy 'dove parentfn) + (hierarchy-add-tree hierarchy 'circle parentfn) + (should (equal (hierarchy-roots hierarchy) '(bird shape))) + (should (equal (hierarchy-children hierarchy 'bird) '(dove))) + (should (equal (hierarchy-children hierarchy 'shape) '(circle))))) + +(ert-deftest hierarchy-add-with-childrenfn () + (let ((childrenfn (lambda (item) + (cl-case item + (animal '(bird)) + (bird '(dove pigeon))))) + (hierarchy (hierarchy-new))) + (hierarchy-add-tree hierarchy 'animal nil childrenfn) + (should (equal (hierarchy-roots hierarchy) '(animal))) + (should (equal (hierarchy-children hierarchy 'animal) '(bird))) + (should (equal (hierarchy-children hierarchy 'bird) '(dove pigeon))))) + +(ert-deftest hierarchy-add-with-parentfn-and-childrenfn () + (let ((parentfn (lambda (item) + (cl-case item + (bird 'animal) + (animal 'life-form)))) + (childrenfn (lambda (item) + (cl-case item + (bird '(dove pigeon)) + (pigeon '(ashy-wood-pigeon))))) + (hierarchy (hierarchy-new))) + (hierarchy-add-tree hierarchy 'bird parentfn childrenfn) + (should (equal (hierarchy-roots hierarchy) '(life-form))) + (should (equal (hierarchy-children hierarchy 'life-form) '(animal))) + (should (equal (hierarchy-children hierarchy 'animal) '(bird))) + (should (equal (hierarchy-children hierarchy 'bird) '(dove pigeon))) + (should (equal (hierarchy-children hierarchy 'pigeon) '(ashy-wood-pigeon))))) + +(ert-deftest hierarchy-add-twice-with-parentfn-and-childrenfn () + (let* ((parentfn (lambda (item) + (cl-case item + (dove 'bird) + (bird 'animal)))) + (childrenfn (lambda (item) + (cl-case item + (animal '(bird)) + (bird '(dove))))) + (hierarchy (hierarchy-new))) + (hierarchy-add-tree hierarchy 'bird parentfn childrenfn) + (should (equal (hierarchy-children hierarchy 'animal) '(bird))) + (should (equal (hierarchy-children hierarchy 'bird) '(dove))))) + +(ert-deftest hierarchy-add-trees () + (let ((parentfn (lambda (item) + (cl-case item + (dove 'bird) + (pigeon 'bird) + (bird 'animal)))) + (hierarchy (hierarchy-new))) + (hierarchy-add-trees hierarchy '(dove pigeon) parentfn) + (should (equal (hierarchy-roots hierarchy) '(animal))) + (should (equal (hierarchy-children hierarchy 'animal) '(bird))) + (should (equal (hierarchy-children hierarchy 'bird) '(dove pigeon))))) + +(ert-deftest hierarchy-from-list () + (let ((hierarchy (hierarchy-from-list + '(animal (bird (dove) + (pigeon)) + (cow) + (dolphin))))) + (hierarchy-sort hierarchy (lambda (item1 item2) + (string< (car item1) + (car item2)))) + (should (equal (hierarchy-to-string hierarchy (lambda (item) (symbol-name (car item)))) + "animal\n bird\n dove\n pigeon\n cow\n dolphin\n")))) + +(ert-deftest hierarchy-from-list-with-duplicates () + (let ((hierarchy (hierarchy-from-list + '(a (b) (b)) + t))) + (hierarchy-sort hierarchy (lambda (item1 item2) + ;; sort by ID + (< (car item1) (car item2)))) + (should (equal (hierarchy-length hierarchy) 3)) + (should (equal (hierarchy-to-string + hierarchy + (lambda (item) + (format "%s(%s)" + (cadr item) + (car item)))) + "a(1)\n b(2)\n b(3)\n")))) + +(ert-deftest hierarchy-from-list-with-childrenfn () + (let ((hierarchy (hierarchy-from-list + "abc" + nil + (lambda (item) + (when (string= item "abc") + (split-string item "" t)))))) + (hierarchy-sort hierarchy (lambda (item1 item2) (string< item1 item2))) + (should (equal (hierarchy-length hierarchy) 4)) + (should (equal (hierarchy-to-string hierarchy) + "abc\n a\n b\n c\n")))) + +(ert-deftest hierarchy-add-relation-check-error-when-different-parent () + (let ((parentfn (lambda (item) + (cl-case item + (bird 'animal)))) + (hierarchy (hierarchy-new))) + (hierarchy-add-tree hierarchy 'bird parentfn) + (should-error + (hierarchy--add-relation hierarchy 'bird 'cow #'identity)))) + +(ert-deftest hierarchy-empty-p-return-non-nil-for-empty () + (should (hierarchy-empty-p (hierarchy-new)))) + +(ert-deftest hierarchy-empty-p-return-nil-for-non-empty () + (should-not (hierarchy-empty-p (hierarchy-animals)))) + +(ert-deftest hierarchy-length-of-empty-is-0 () + (should (equal (hierarchy-length (hierarchy-new)) 0))) + +(ert-deftest hierarchy-length-of-non-empty-counts-items () + (let ((parentfn (lambda (item) + (cl-case item + (bird 'animal) + (dove 'bird) + (pigeon 'bird)))) + (hierarchy (hierarchy-new))) + (hierarchy-add-tree hierarchy 'dove parentfn) + (hierarchy-add-tree hierarchy 'pigeon parentfn) + (should (equal (hierarchy-length hierarchy) 4)))) + +(ert-deftest hierarchy-has-root () + (let ((parentfn (lambda (item) + (cl-case item + (bird 'animal) + (dove 'bird) + (pigeon 'bird)))) + (hierarchy (hierarchy-new))) + (should-not (hierarchy-has-root hierarchy 'animal)) + (should-not (hierarchy-has-root hierarchy 'bird)) + (hierarchy-add-tree hierarchy 'dove parentfn) + (hierarchy-add-tree hierarchy 'pigeon parentfn) + (should (hierarchy-has-root hierarchy 'animal)) + (should-not (hierarchy-has-root hierarchy 'bird)))) + +(ert-deftest hierarchy-leafs () + (let ((animals (hierarchy-animals))) + (should (equal (hierarchy-leafs animals) + '(dove pigeon dolphin cow))))) + +(ert-deftest hierarchy-leafs-includes-lonely-roots () + (let ((parentfn (lambda (item) nil)) + (hierarchy (hierarchy-new))) + (hierarchy-add-tree hierarchy 'foo parentfn) + (should (equal (hierarchy-leafs hierarchy) + '(foo))))) + +(ert-deftest hierarchy-leafs-of-node () + (let ((animals (hierarchy-animals))) + (should (equal (hierarchy-leafs animals 'cow) '())) + (should (equal (hierarchy-leafs animals 'animal) '(dove pigeon dolphin cow))) + (should (equal (hierarchy-leafs animals 'bird) '(dove pigeon))) + (should (equal (hierarchy-leafs animals 'dove) '())))) + +(ert-deftest hierarchy-child-p () + (let ((animals (hierarchy-animals))) + (should (hierarchy-child-p animals 'dove 'bird)) + (should (hierarchy-child-p animals 'bird 'animal)) + (should (hierarchy-child-p animals 'cow 'animal)) + (should-not (hierarchy-child-p animals 'cow 'bird)) + (should-not (hierarchy-child-p animals 'bird 'cow)) + (should-not (hierarchy-child-p animals 'animal 'dove)) + (should-not (hierarchy-child-p animals 'animal 'bird)))) + +(ert-deftest hierarchy-descendant () + (let ((animals (hierarchy-animals))) + (should (hierarchy-descendant-p animals 'dove 'animal)) + (should (hierarchy-descendant-p animals 'dove 'bird)) + (should (hierarchy-descendant-p animals 'bird 'animal)) + (should (hierarchy-descendant-p animals 'cow 'animal)) + (should-not (hierarchy-descendant-p animals 'cow 'bird)) + (should-not (hierarchy-descendant-p animals 'bird 'cow)) + (should-not (hierarchy-descendant-p animals 'animal 'dove)) + (should-not (hierarchy-descendant-p animals 'animal 'bird)))) + +(ert-deftest hierarchy-descendant-if-not-same () + (let ((animals (hierarchy-animals))) + (should-not (hierarchy-descendant-p animals 'cow 'cow)) + (should-not (hierarchy-descendant-p animals 'dove 'dove)) + (should-not (hierarchy-descendant-p animals 'bird 'bird)) + (should-not (hierarchy-descendant-p animals 'animal 'animal)))) + +;; keywords supported: :test :key +(ert-deftest hierarchy--set-equal () + (should (hierarchy--set-equal '(1 2 3) '(1 2 3))) + (should (hierarchy--set-equal '(1 2 3) '(3 2 1))) + (should (hierarchy--set-equal '(3 2 1) '(1 2 3))) + (should-not (hierarchy--set-equal '(2 3) '(3 2 1))) + (should-not (hierarchy--set-equal '(1 2 3) '(2 3))) + (should-not (hierarchy--set-equal '("1" "2") '("2" "1") :test #'eq)) + (should (hierarchy--set-equal '("1" "2") '("2" "1") :test #'equal)) + (should-not (hierarchy--set-equal '(1 2) '(-1 -2))) + (should (hierarchy--set-equal '(1 2) '(-1 -2) :key #'abs)) + (should-not (hierarchy--set-equal '(("1" 1) ("2" 1)) '(("1" 2) ("2" 2)))) + (should-not (hierarchy--set-equal '(("1" 1) ("2" 1)) '(("1" 2) ("2" 2)) :key #'car)) + (should-not (hierarchy--set-equal '(("1" 1) ("2" 1)) '(("1" 2) ("2" 2)) :test #'equal)) + (should (hierarchy--set-equal '(("1" 1) ("2" 1)) '(("1" 2) ("2" 2)) :key #'car :test #'equal))) + +(ert-deftest hierarchy-equal-returns-true-for-same-hierarchy () + (let ((animals (hierarchy-animals))) + (should (hierarchy-equal animals animals)) + (should (hierarchy-equal (hierarchy-animals) animals)))) + +(ert-deftest hierarchy-equal-returns-true-for-hierarchy-copies () + (let ((animals (hierarchy-animals))) + (should (hierarchy-equal animals (hierarchy-copy animals))))) + +(ert-deftest hierarchy-map-item-on-leaf () + (let* ((animals (hierarchy-animals)) + (result (hierarchy-map-item (lambda (item indent) (cons item indent)) + 'cow + animals))) + (should (equal result '((cow . 0)))))) + +(ert-deftest hierarchy-map-item-on-leaf-with-indent () + (let* ((animals (hierarchy-animals)) + (result (hierarchy-map-item (lambda (item indent) (cons item indent)) + 'cow + animals + 2))) + (should (equal result '((cow . 2)))))) + +(ert-deftest hierarchy-map-item-on-parent () + (let* ((animals (hierarchy-animals)) + (result (hierarchy-map-item (lambda (item indent) (cons item indent)) + 'bird + animals))) + (should (equal result '((bird . 0) (dove . 1) (pigeon . 1)))))) + +(ert-deftest hierarchy-map-item-on-grand-parent () + (let* ((animals (hierarchy-animals)) + (result (hierarchy-map-item (lambda (item indent) (cons item indent)) + 'animal + animals))) + (should (equal result '((animal . 0) (bird . 1) (dove . 2) (pigeon . 2) + (cow . 1) (dolphin . 1)))))) + +(ert-deftest hierarchy-map-conses () + (let* ((animals (hierarchy-animals)) + (result (hierarchy-map (lambda (item indent) + (cons item indent)) + animals))) + (should (equal result '((animal . 0) + (bird . 1) + (dove . 2) + (pigeon . 2) + (cow . 1) + (dolphin . 1)))))) + +(ert-deftest hierarchy-map-tree () + (let ((animals (hierarchy-animals))) + (should (equal (hierarchy-map-tree (lambda (item indent children) + (list item indent children)) + animals) + '(animal + 0 + ((bird 1 ((dove 2 nil) (pigeon 2 nil))) + (cow 1 nil) + (dolphin 1 nil))))))) + +(ert-deftest hierarchy-map-hierarchy-keeps-hierarchy () + (let* ((animals (hierarchy-animals)) + (result (hierarchy-map-hierarchy (lambda (item _) (identity item)) + animals))) + (should (hierarchy-equal animals result)))) + +(ert-deftest hierarchy-map-applies-function () + (let* ((animals (hierarchy-animals)) + (parentfn (lambda (item) + (cond + ((equal item "bird") "animal") + ((equal item "dove") "bird") + ((equal item "pigeon") "bird") + ((equal item "cow") "animal") + ((equal item "dolphin") "animal")))) + (expected (hierarchy-new))) + (hierarchy-add-tree expected "dove" parentfn) + (hierarchy-add-tree expected "pigeon" parentfn) + (hierarchy-add-tree expected "cow" parentfn) + (hierarchy-add-tree expected "dolphin" parentfn) + (should (hierarchy-equal + (hierarchy-map-hierarchy (lambda (item _) (symbol-name item)) animals) + expected)))) + +(ert-deftest hierarchy-extract-tree () + (let* ((animals (hierarchy-animals)) + (birds (hierarchy-extract-tree animals 'bird))) + (hierarchy-sort birds) + (should (equal (hierarchy-roots birds) '(animal))) + (should (equal (hierarchy-children birds 'animal) '(bird))) + (should (equal (hierarchy-children birds 'bird) '(dove pigeon))))) + +(ert-deftest hierarchy-extract-tree-nil-if-not-in-hierarchy () + (let* ((animals (hierarchy-animals))) + (should-not (hierarchy-extract-tree animals 'foobar)))) + +(ert-deftest hierarchy-items-of-empty-hierarchy-is-empty () + (should (seq-empty-p (hierarchy-items (hierarchy-new))))) + +(ert-deftest hierarchy-items-returns-sequence-of-same-length () + (let* ((animals (hierarchy-animals)) + (result (hierarchy-items animals))) + (should (= (seq-length result) (hierarchy-length animals))))) + +(ert-deftest hierarchy-items-return-all-elements-of-hierarchy () + (let* ((animals (hierarchy-animals)) + (result (hierarchy-items animals))) + (should (equal (seq-sort #'string< result) '(animal bird cow dolphin dove pigeon))))) + +(ert-deftest hierarchy-labelfn-indent-no-indent-if-0 () + (let* ((labelfn-base (lambda (_item _indent) (insert "foo"))) + (labelfn (hierarchy-labelfn-indent labelfn-base))) + (should (equal + (with-temp-buffer + (funcall labelfn "bar" 0) + (buffer-substring (point-min) (point-max))) + "foo")))) + +(ert-deftest hierarchy-labelfn-indent-three-times-if-3 () + (let* ((labelfn-base (lambda (_item _indent) (insert "foo"))) + (labelfn (hierarchy-labelfn-indent labelfn-base))) + (should (equal + (with-temp-buffer + (funcall labelfn "bar" 3) + (buffer-substring (point-min) (point-max))) + " foo")))) + +(ert-deftest hierarchy-labelfn-indent-default-indent-string () + (let* ((labelfn-base (lambda (_item _indent) (insert "foo"))) + (labelfn (hierarchy-labelfn-indent labelfn-base))) + (should (equal + (with-temp-buffer + (funcall labelfn "bar" 1) + (buffer-substring (point-min) (point-max))) + " foo")))) + +(ert-deftest hierarchy-labelfn-indent-custom-indent-string () + (let* ((labelfn-base (lambda (_item _indent) (insert "foo"))) + (labelfn (hierarchy-labelfn-indent labelfn-base "###")) + (content (with-temp-buffer + (funcall labelfn "bar" 1) + (buffer-substring (point-min) (point-max))))) + (should (equal content "###foo")))) + +(ert-deftest hierarchy-labelfn-button-propertize () + (let* ((labelfn-base (lambda (_item _indent) (insert "foo"))) + (actionfn #'identity) + (labelfn (hierarchy-labelfn-button labelfn-base actionfn)) + (properties (with-temp-buffer + (funcall labelfn "bar" 1) + (text-properties-at 1)))) + (should (equal (car properties) 'action)))) + +(ert-deftest hierarchy-labelfn-button-execute-labelfn () + (let* ((labelfn-base (lambda (_item _indent) (insert "foo"))) + (actionfn #'identity) + (labelfn (hierarchy-labelfn-button labelfn-base actionfn)) + (content (with-temp-buffer + (funcall labelfn "bar" 1) + (buffer-substring-no-properties (point-min) (point-max))))) + (should (equal content "foo")))) + +(ert-deftest hierarchy-labelfn-button-if-does-not-button-unless-condition () + (let ((labelfn-base (lambda (_item _indent) (insert "foo"))) + (spy-count 0) + (condition (lambda (_item _indent) nil))) + (cl-letf (((symbol-function 'hierarchy-labelfn-button) (lambda (_labelfn _actionfn) (lambda (_item _indent) (cl-incf spy-count))))) + (funcall (hierarchy-labelfn-button-if labelfn-base condition #'identity) nil nil) + (should (equal spy-count 0))))) + +(ert-deftest hierarchy-labelfn-button-if-does-button-when-condition () + (let ((labelfn-base (lambda (_item _indent) (insert "foo"))) + (spy-count 0) + (condition (lambda (_item _indent) t))) + (cl-letf (((symbol-function 'hierarchy-labelfn-button) (lambda (_labelfn _actionfn) (lambda (_item _indent) (cl-incf spy-count))))) + (funcall (hierarchy-labelfn-button-if labelfn-base condition #'identity) nil nil) + (should (equal spy-count 1))))) + +(ert-deftest hierarchy-labelfn-to-string () + (let ((labelfn (lambda (item _indent) (insert item)))) + (should (equal (hierarchy-labelfn-to-string labelfn "foo" 1) "foo")))) + +(ert-deftest hierarchy-print () + (let* ((animals (hierarchy-animals)) + (result (with-temp-buffer + (hierarchy-print animals) + (buffer-substring-no-properties (point-min) (point-max))))) + (should (equal result "animal\n bird\n dove\n pigeon\n cow\n dolphin\n")))) + +(ert-deftest hierarchy-to-string () + (let* ((animals (hierarchy-animals)) + (result (hierarchy-to-string animals))) + (should (equal result "animal\n bird\n dove\n pigeon\n cow\n dolphin\n")))) + +(ert-deftest hierarchy-tabulated-display () + (let* ((animals (hierarchy-animals)) + (labelfn (lambda (item _indent) (insert (symbol-name item)))) + (contents (with-temp-buffer + (hierarchy-tabulated-display animals labelfn (current-buffer)) + (buffer-substring-no-properties (point-min) (point-max))))) + (should (equal contents "animal\nbird\ndove\npigeon\ncow\ndolphin\n")))) + +(ert-deftest hierarchy-sort-non-root-nodes () + (let* ((animals (hierarchy-animals))) + (should (equal (hierarchy-roots animals) '(animal))) + (should (equal (hierarchy-children animals 'animal) '(bird cow dolphin))) + (should (equal (hierarchy-children animals 'bird) '(dove pigeon))))) + +(ert-deftest hierarchy-sort-roots () + (let* ((organisms (hierarchy-new)) + (parentfn (lambda (item) + (cl-case item + (oak 'plant) + (bird 'animal))))) + (hierarchy-add-tree organisms 'oak parentfn) + (hierarchy-add-tree organisms 'bird parentfn) + (hierarchy-sort organisms) + (should (equal (hierarchy-roots organisms) '(animal plant))))) + +(provide 'hierarchy-tests) +;;; hierarchy-tests.el ends here -- 2.23.0 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 09 02:32:58 2019 Received: (at submit) by debbugs.gnu.org; 9 Dec 2019 07:32:58 +0000 Received: from localhost ([127.0.0.1]:52543 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ieDXO-0005Yo-3g for submit@debbugs.gnu.org; Mon, 09 Dec 2019 02:32:58 -0500 Received: from lists.gnu.org ([209.51.188.17]:54387) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ieDXM-0005Yf-IQ for submit@debbugs.gnu.org; Mon, 09 Dec 2019 02:32:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48280) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ieDXL-0001S2-GM for bug-gnu-emacs@gnu.org; Mon, 09 Dec 2019 02:32:56 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,URIBL_BLOCKED autolearn=disabled version=3.3.2 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ieDXK-0004MN-D3 for bug-gnu-emacs@gnu.org; Mon, 09 Dec 2019 02:32:55 -0500 Received: from mail.choca.pics ([62.210.108.126]:56062) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ieDXK-000483-7P; Mon, 09 Dec 2019 02:32:54 -0500 Received: from localhost (localhost.localdomain [IPv6:::1]) by mail.choca.pics (Postfix) with ESMTP id 36EFAF094B8; Mon, 9 Dec 2019 08:31:45 +0100 (CET) Received: from mail.choca.pics ([IPv6:::1]) by localhost (mail.choca.pics [IPv6:::1]) (amavisd-new, port 10032) with ESMTP id yXcN30hIgV1T; Mon, 9 Dec 2019 08:31:44 +0100 (CET) Received: from localhost (localhost.localdomain [IPv6:::1]) by mail.choca.pics (Postfix) with ESMTP id 60213F094B9; Mon, 9 Dec 2019 08:31:44 +0100 (CET) X-Virus-Scanned: amavisd-new at choca.pics Received: from mail.choca.pics ([IPv6:::1]) by localhost (mail.choca.pics [IPv6:::1]) (amavisd-new, port 10026) with ESMTP id pIYorIOuSDtX; Mon, 9 Dec 2019 08:31:44 +0100 (CET) Received: from luz4 (unknown [86.215.186.82]) by mail.choca.pics (Postfix) with ESMTPSA id 0DA6DF094B8; Mon, 9 Dec 2019 08:31:44 +0100 (CET) From: Damien Cassou To: bug-gnu-emacs@gnu.org Subject: Re: 26.3.50; [PATCH] Add the hierarchy library In-Reply-To: <871rtv3hit.fsf@cassou.me> References: <871rtv3hit.fsf@cassou.me> Date: Mon, 09 Dec 2019 08:31:43 +0100 Message-ID: <87a7823qg0.fsf@cassou.me> MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 62.210.108.126 X-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: submit Cc: johnw@newartisans.com, joaotavora@gmail.com, eliz@gnu.org, monnier@IRO.UMontreal.CA, clement.pitclaudel@live.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.4 (--) Damien Cassou writes: > Please find attached a patch adding hierarchy.el and > hierarchy-tests.el. The hierarchy library allows to create, query, > navigate and display hierarchy structures. ping -- Damien Cassou "Success is the ability to go from one failure to another without losing enthusiasm." --Winston Churchill From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 09 04:46:08 2019 Received: (at submit) by debbugs.gnu.org; 9 Dec 2019 09:46:08 +0000 Received: from localhost ([127.0.0.1]:52603 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ieFcG-0001ID-CW for submit@debbugs.gnu.org; Mon, 09 Dec 2019 04:46:08 -0500 Received: from lists.gnu.org ([209.51.188.17]:44717) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ieFcF-0001I5-9d for submit@debbugs.gnu.org; Mon, 09 Dec 2019 04:46:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48574) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ieFcE-000758-4m for bug-gnu-emacs@gnu.org; Mon, 09 Dec 2019 04:46:07 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM, URIBL_BLOCKED autolearn=disabled version=3.3.2 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ieFcC-0005MW-SG for bug-gnu-emacs@gnu.org; Mon, 09 Dec 2019 04:46:06 -0500 Received: from mail-io1-xd35.google.com ([2607:f8b0:4864:20::d35]:44353) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ieFcC-0005LB-Jh; Mon, 09 Dec 2019 04:46:04 -0500 Received: by mail-io1-xd35.google.com with SMTP id z23so13980649iog.11; Mon, 09 Dec 2019 01:46:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=H9HO6wWCSbuRPEYxqhpJbZt+w/TGBQ+XRo1CsLb65xU=; b=ZAc842cBVzw1TSyHo05qWXoCME2p5bHac18HymxUGGb6S3j6NLNSGsQP/FAXycgJDM ycV4xJL5O2sY7aTDTci9I+5nyNBrT1q++bXB/GoM+3LsNbMNTmFQEpJXWkuc+8qkp/Sp BvteAmsxwOw4W3OPK809ttNHsYPygIfd6BmfCZ86kYtTKHcnJmyVhiUBJTWqk5aCDiiC uW6NYzmDCZBS3tp8b+G7t0k06YYjDDDQrtvT/qbNjGgq7aBKS/qvS79451Xf2HQP9nGt XHuYpGIwgE0PSQgnWNtbl4j2dDHWqG8Tu6Islza5hfqFQiSERx8pJictQ88jxU8IGvh2 M8XQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=H9HO6wWCSbuRPEYxqhpJbZt+w/TGBQ+XRo1CsLb65xU=; b=XXhv7/+1mVKaNBytLpTwYs/Hi67oV2saDWt4s0Jvthw0GU+9Z8sapqcY9Yu0E4s8h5 GQ27LAVHfS2/KMX1gGX6QaukkiGpI+urtjEiZOdsNAOSMundCmbtQRc60mjvEr0BdcEx 9zAK4jeppq7UFSwnvyI+xcXDWA6uus5pTzqDTBwSmARXqw+Jw3Gi2gZIIj2xyH8uxC+3 uHeoxhsuqWbiDq43JQW4Kxoh/RmVwwRyLDrv+HaZC3pZDSluiIrztieoHJ5bamq+GwiA 2BuzuYtpA6bJH0VrY3+CE9TMP8Q3BjgUgNTAQuBYFsKpmY3DNf9KBWmrQ0Y491rYxj56 fnCg== X-Gm-Message-State: APjAAAWndvVAnjDnEd6MXzisVQqmmwQPLvTg4cDAzMQZq5Hy048uFzcl 34jlxoblbQSVb+tS2QC18aUjoYC2S70x6dJqdSk= X-Google-Smtp-Source: APXvYqz9CCkpd/ukyu1vRoEN7XAroKOI7aSCeqpb50Nr9VE/UISJaqDgaYr/uQUPht/NP6YQS6ixfMUs75wyHmPgW1Y= X-Received: by 2002:a6b:c804:: with SMTP id y4mr21020708iof.9.1575884763745; Mon, 09 Dec 2019 01:46:03 -0800 (PST) MIME-Version: 1.0 References: <871rtv3hit.fsf@cassou.me> <87a7823qg0.fsf@cassou.me> In-Reply-To: <87a7823qg0.fsf@cassou.me> From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Date: Mon, 9 Dec 2019 10:45:52 +0100 Message-ID: Subject: Re: 26.3.50; [PATCH] Add the hierarchy library To: Damien Cassou Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::d35 X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit Cc: johnw@newartisans.com, bug-gnu-emacs@gnu.org, Eli Zaretskii , Stefan Monnier , clement.pitclaudel@live.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) Hi Damien, In the top-level comment you say ;; Library to create, query, navigate and display hierarchy structures. Did you omit "modify" specifically because it doesn't allow a created hierarchy to be mutated? if so, can you estimate the effort it would take to implement that step, given your knowledge of the internals? Thanks, Jo=C3=A3o On Mon, Dec 9, 2019 at 8:31 AM Damien Cassou wrote: > > Damien Cassou writes: > > Please find attached a patch adding hierarchy.el and > > hierarchy-tests.el. The hierarchy library allows to create, query, > > navigate and display hierarchy structures. > > ping > > -- > Damien Cassou > > "Success is the ability to go from one failure to another without > losing enthusiasm." --Winston Churchill --=20 Jo=C3=A3o T=C3=A1vora From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 09 05:53:32 2019 Received: (at 38378) by debbugs.gnu.org; 9 Dec 2019 10:53:32 +0000 Received: from localhost ([127.0.0.1]:52652 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ieGfU-000455-A7 for submit@debbugs.gnu.org; Mon, 09 Dec 2019 05:53:32 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:40117) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ieGfT-00044u-2b for 38378@debbugs.gnu.org; Mon, 09 Dec 2019 05:53:31 -0500 Received: by mail-wr1-f68.google.com with SMTP id c14so15646072wrn.7 for <38378@debbugs.gnu.org>; Mon, 09 Dec 2019 02:53:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=YucXfhUvPxc9taLGdaTaubrKagy35Jz50CSjrI+IM7g=; b=oIJV9c/K3DeO+Z01FQRVFtj7c6wCCwrKcuRSSDfM766nuL+N02/vjcGrvlmEtCuweF GaGvNtbgYQ2DNP93lImjjTAf0Ht+p+geYWCowUbhICIc3p2asndzrUM17jvCRY+49h1s AM325GmAjxVOCHc5rSYVVoU5E7n3ntg+Qv3Oyt/UHuQkhl4Kv90Y2dnUuptwwu6vjknp TRV9+AS1OxnTh8xC/HUj6mtJHGUVPr1nHdTnlqXgQT2TyGvHO2LoTo91/Ju4d05mqv6D a08EzEEO+2BdjZ5fzCxrH4B/0fAtAmkqKt+lA5lN1tsN5JUw2Uc5/mjDLDUJyaRSvJU0 gi8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=YucXfhUvPxc9taLGdaTaubrKagy35Jz50CSjrI+IM7g=; b=Y7/Bm+QqhAru2Gi8dtgMJoUwu4UAclqiUYrTPhyjs4wM0dpFK48HEkOZT6cnbb+Wgj ILwANY9NQQf4uo6fuLaOALHp5RkSWIVPTUV6yqwdBsp1N6zTWukatSzH8GHNygSipUYQ riZeBcTbbnpeIvV267GqwrlY4Oma9GCulBSxfvKu2Cr2fyo2VzM7hugJI4UsE0RmvTNc znb86HdCLBNW+2EGskOc8qbFqHwNwgykOJfUWUIeG4a5KDt3xGNI2KpeV9TaVoF+m3Xs OyHnIp8qGJSTi0QoeCD8A56p9XGinpWhAc7Q2nY47fvHpX3cKP8ywQHXuvfTfheWRzYc bYOg== X-Gm-Message-State: APjAAAVel0doCNysTWZGQ2CibfmnLQZcSUKe3C1Lha+Y5C41wqTmgZBe A2MH/8UhldfvaLuMK5tCgcY= X-Google-Smtp-Source: APXvYqwG2n4QEOjh2SKgeD3UmqvcCl3KFFNnkxaot1mZ0n7ULawe2FqVB/4zvUWfm9jMNsx6qu3mnQ== X-Received: by 2002:adf:e40f:: with SMTP id g15mr1445429wrm.223.1575888805198; Mon, 09 Dec 2019 02:53:25 -0800 (PST) Received: from [192.168.0.5] ([212.50.117.215]) by smtp.googlemail.com with ESMTPSA id u10sm12954468wmd.1.2019.12.09.02.53.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Dec 2019 02:53:24 -0800 (PST) Subject: Re: bug#38378: 26.3.50; [PATCH] Add the hierarchy library To: Damien Cassou , 38378@debbugs.gnu.org References: <871rtv3hit.fsf@cassou.me> From: Dmitry Gutov Message-ID: <8ccb16d7-34b5-c399-4270-aa7ae84fd9ff@yandex.ru> Date: Mon, 9 Dec 2019 12:53:22 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <871rtv3hit.fsf@cassou.me> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: 0.4 (/) X-Debbugs-Envelope-To: 38378 Cc: johnw@newartisans.com, joaotavora@gmail.com, monnier@IRO.UMontreal.CA, clement.pitclaudel@live.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.6 (/) On 25.11.2019 21:03, Damien Cassou wrote: > Two years ago, I suggested adding this library to ELPA and you guys on > CC answered you wanted it in Emacs core: > https://lists.gnu.org/archive/html/emacs-devel/2017-10/msg00624.html Eli said the core would benefit from it, but I wonder which existing features exactly could use it now. If none, I think GNU ELPA is the better place for it. And as soon as someone finds a specific use for it in the core, moving would be trivial. From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 09 07:21:26 2019 Received: (at 38378) by debbugs.gnu.org; 9 Dec 2019 12:21:26 +0000 Received: from localhost ([127.0.0.1]:52704 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ieI2Y-0006cJ-KV for submit@debbugs.gnu.org; Mon, 09 Dec 2019 07:21:26 -0500 Received: from mail.choca.pics ([62.210.108.126]:58790) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ieI2V-0006cA-T8 for 38378@debbugs.gnu.org; Mon, 09 Dec 2019 07:21:24 -0500 Received: from localhost (localhost.localdomain [IPv6:::1]) by mail.choca.pics (Postfix) with ESMTP id 318AFF094E7; Mon, 9 Dec 2019 13:21:22 +0100 (CET) Received: from mail.choca.pics ([IPv6:::1]) by localhost (mail.choca.pics [IPv6:::1]) (amavisd-new, port 10032) with ESMTP id wivTZqlxR8d4; Mon, 9 Dec 2019 13:21:21 +0100 (CET) Received: from localhost (localhost.localdomain [IPv6:::1]) by mail.choca.pics (Postfix) with ESMTP id 3D5D8F094E9; Mon, 9 Dec 2019 13:21:21 +0100 (CET) X-Virus-Scanned: amavisd-new at choca.pics Received: from mail.choca.pics ([IPv6:::1]) by localhost (mail.choca.pics [IPv6:::1]) (amavisd-new, port 10026) with ESMTP id t1Aqrz5xET5L; Mon, 9 Dec 2019 13:21:21 +0100 (CET) Received: from luz4 (unknown [86.215.185.132]) by mail.choca.pics (Postfix) with ESMTPSA id D1085F094E7; Mon, 9 Dec 2019 13:21:20 +0100 (CET) From: Damien Cassou To: Dmitry Gutov , 38378@debbugs.gnu.org Subject: Re: bug#38378: 26.3.50; [PATCH] Add the hierarchy library In-Reply-To: <8ccb16d7-34b5-c399-4270-aa7ae84fd9ff@yandex.ru> References: <871rtv3hit.fsf@cassou.me> <8ccb16d7-34b5-c399-4270-aa7ae84fd9ff@yandex.ru> Date: Mon, 09 Dec 2019 13:21:19 +0100 Message-ID: <87pngx3d1c.fsf@cassou.me> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 38378 Cc: johnw@newartisans.com, eliz@gnu.org, joaotavora@gmail.com, monnier@IRO.UMontreal.CA, clement.pitclaudel@live.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Dmitry Gutov writes: > Eli said the core would benefit from it, but I wonder which existing=20 > features exactly could use it now. > > If none, I think GNU ELPA is the better place for it. And as soon as=20 > someone finds a specific use for it in the core, moving would be trivial. Cl=C3=A9ment Pit-Claudel suggested "the tree displayed by profiler-report." in https://lists.gnu.org/archive/html/emacs-devel/2017-10/msg00675.html. Maybe proced's tree mode? I stated my opinion about this matter in the past (see https://lists.gnu.org/archive/html/emacs-devel/2017-10/msg00686.html): Damien Cassou wrote: > If you think Emacs would benefit from having hierarchy included, > please do include it. My philosophy is more in the opposite direction > (getting rid of as much as possible in the core to facilitate release > and to let package maintainers use the tools they want) To which Eli answered: Eli Zaretskii wrote: > As much as possible, but no more than that, I presume? Then the issue > here is whether this capability should or shouldn't be in core, as > other basics. I think it should. I let you decide. --=20 Damien Cassou "Success is the ability to go from one failure to another without losing enthusiasm." --Winston Churchill From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 09 07:23:43 2019 Received: (at submit) by debbugs.gnu.org; 9 Dec 2019 12:23:43 +0000 Received: from localhost ([127.0.0.1]:52708 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ieI4l-0006fx-1h for submit@debbugs.gnu.org; Mon, 09 Dec 2019 07:23:43 -0500 Received: from lists.gnu.org ([209.51.188.17]:46723) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ieI4k-0006fr-40 for submit@debbugs.gnu.org; Mon, 09 Dec 2019 07:23:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59001) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ieI4i-0007Zz-AE for bug-gnu-emacs@gnu.org; Mon, 09 Dec 2019 07:23:41 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ieI4g-0004Ca-Bq for bug-gnu-emacs@gnu.org; Mon, 09 Dec 2019 07:23:40 -0500 Received: from mail.choca.pics ([62.210.108.126]:60018) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ieI4e-0004C5-IU; Mon, 09 Dec 2019 07:23:37 -0500 Received: from localhost (localhost.localdomain [IPv6:::1]) by mail.choca.pics (Postfix) with ESMTP id 6E3F1F094E7; Mon, 9 Dec 2019 13:23:35 +0100 (CET) Received: from mail.choca.pics ([IPv6:::1]) by localhost (mail.choca.pics [IPv6:::1]) (amavisd-new, port 10032) with ESMTP id 8FvNT8Dsyfka; Mon, 9 Dec 2019 13:23:34 +0100 (CET) Received: from localhost (localhost.localdomain [IPv6:::1]) by mail.choca.pics (Postfix) with ESMTP id 39168F094E9; Mon, 9 Dec 2019 13:23:34 +0100 (CET) X-Virus-Scanned: amavisd-new at choca.pics Received: from mail.choca.pics ([IPv6:::1]) by localhost (mail.choca.pics [IPv6:::1]) (amavisd-new, port 10026) with ESMTP id kobLA5E7KK4n; Mon, 9 Dec 2019 13:23:34 +0100 (CET) Received: from luz4 (unknown [86.215.185.132]) by mail.choca.pics (Postfix) with ESMTPSA id D76DEF094E7; Mon, 9 Dec 2019 13:23:33 +0100 (CET) From: Damien Cassou To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Subject: Re: 26.3.50; [PATCH] Add the hierarchy library In-Reply-To: References: <871rtv3hit.fsf@cassou.me> <87a7823qg0.fsf@cassou.me> Date: Mon, 09 Dec 2019 13:23:33 +0100 Message-ID: <87muc13cxm.fsf@cassou.me> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 62.210.108.126 X-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: submit Cc: johnw@newartisans.com, bug-gnu-emacs@gnu.org, Eli Zaretskii , Stefan Monnier , clement.pitclaudel@live.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.4 (--) Jo=C3=A3o T=C3=A1vora writes: > ;; Library to create, query, navigate and display hierarchy structures. > > Did you omit "modify" specifically because it doesn't allow a created > hierarchy to be mutated? a Hierarchy is created with (hierarchy-new) and must then be mutated to add elements to it. This is the same as with (make-hash-table). --=20 Damien Cassou "Success is the ability to go from one failure to another without losing enthusiasm." --Winston Churchill From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 09 07:26:17 2019 Received: (at 38378) by debbugs.gnu.org; 9 Dec 2019 12:26:17 +0000 Received: from localhost ([127.0.0.1]:52713 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ieI7F-0006kB-HM for submit@debbugs.gnu.org; Mon, 09 Dec 2019 07:26:17 -0500 Received: from mail-io1-f67.google.com ([209.85.166.67]:41609) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ieI7E-0006jy-5A for 38378@debbugs.gnu.org; Mon, 09 Dec 2019 07:26:16 -0500 Received: by mail-io1-f67.google.com with SMTP id z26so14499558iot.8 for <38378@debbugs.gnu.org>; Mon, 09 Dec 2019 04:26:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=1wcVIjpStREs2u9b+6sxLWXI0ZYIA9Nl8INS+tptv6o=; b=K30cpmffp/qHEBKh6+3y2/xQKYFyRqcSS3D8LPyyhdG7KRpC1FyyziCdUWDMmb3aQ/ 7yTD16lBcC1IO+Z2vyHvN6rtq2trxYB9baALs1zuIbSYBjYbelByJ3YMDjevvDu7O1xI qdy6EplvR91uMi+icsm/B8aAD7GalBilCj0W7sARNLMcJ3FQnFNdv6GcecXtD4Ite5rT DYkfAgvZE+BgV/swVEjyqIC0q/59N0FvC5pJZtUtIrzLRZyKtnXMIK/CG4PiigAFtVix 7RjQ0TIG4d7y1z7+kHOkAjpzRD1zD/oIKwlpW2E303kxFp5l9iJNFOUk2UHJAZaKKqLY bLXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=1wcVIjpStREs2u9b+6sxLWXI0ZYIA9Nl8INS+tptv6o=; b=AfcV5IYQcO+O0KjjYjAQULiEAIK1HIh/ESCfGEHuBo2kiTWug6zeY8qmNH4xBy8hzO 4+hpU33VIn+skwc1CmAOLl9M/AduWBMEMKBFU4BtWHDIwgXKDhB8NwzrThbjQh8fcQaN a1RDGsYMRJ0hrSnvOeIkbThVrIb92RYV1e7njzmqJ6dikcp/7ubatgpa9eeL/M8G1Mlh BFjlTCrFiDgX7L91Tw03+lkNDTpKGziShqnhHfEEn1dWL+IYC/Mq4G1k9w68sO9ySjBs 09x8Vi7JMbCdjQCqHCHuOQxjusuGWmLZvwceCeFtn9zSTUoaxptOMLgkMsDxEH/arDJW a9Sg== X-Gm-Message-State: APjAAAUdErkntq4ekZxtSj22LWv+4303P2fE6LGgSs4UjntXIu/aCwM7 dYNzJthVM36kcgrxHaMjBvyWH27wwBw56HcrWBA= X-Google-Smtp-Source: APXvYqySvsvmib5Dsp4A/CFcmTrn1Vj9+TZDWbuei4fLja9ciMOwxb49Ym4sWge8LbF2b4x8e9TUDLCzelqEYS/Koi8= X-Received: by 2002:a5e:db0d:: with SMTP id q13mr20744499iop.199.1575894370491; Mon, 09 Dec 2019 04:26:10 -0800 (PST) MIME-Version: 1.0 References: <871rtv3hit.fsf@cassou.me> <8ccb16d7-34b5-c399-4270-aa7ae84fd9ff@yandex.ru> <87pngx3d1c.fsf@cassou.me> In-Reply-To: <87pngx3d1c.fsf@cassou.me> From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Date: Mon, 9 Dec 2019 13:25:59 +0100 Message-ID: Subject: Re: bug#38378: 26.3.50; [PATCH] Add the hierarchy library To: Damien Cassou Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 38378 Cc: johnw@newartisans.com, 38378@debbugs.gnu.org, clement.pitclaudel@live.com, Stefan Monnier , Dmitry Gutov , Eli Zaretskii X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On Mon, Dec 9, 2019 at 1:21 PM Damien Cassou wrote: > > Dmitry Gutov writes: > > Eli said the core would benefit from it, but I wonder which existing > > features exactly could use it now. > > > > If none, I think GNU ELPA is the better place for it. And as soon as > > someone finds a specific use for it in the core, moving would be trivia= l. FWIW, I agree with Dmitry here. > Cl=C3=A9ment Pit-Claudel suggested "the tree displayed by profiler-report= ." > in https://lists.gnu.org/archive/html/emacs-devel/2017-10/msg00675.html. > > Maybe proced's tree mode? So why don't we add a comment to those libraries and say: "if you're considering simplifying this code and adding some more features, consider installing Damien Cassous's as a :core GNU ELPA package in the core" . Would this work for everyone? Having it in ELPA is good for me if I ever want to upgrade it, then make SL= Y use it. But the clincher would be that you implement mutable trees :-) Jo=C3=A3o From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 09 07:27:38 2019 Received: (at 38378) by debbugs.gnu.org; 9 Dec 2019 12:27:38 +0000 Received: from localhost ([127.0.0.1]:52718 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ieI8X-0006mJ-Sp for submit@debbugs.gnu.org; Mon, 09 Dec 2019 07:27:38 -0500 Received: from mail-io1-f66.google.com ([209.85.166.66]:33061) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ieI8V-0006m1-Ob for 38378@debbugs.gnu.org; Mon, 09 Dec 2019 07:27:36 -0500 Received: by mail-io1-f66.google.com with SMTP id 2so11655641ion.0 for <38378@debbugs.gnu.org>; Mon, 09 Dec 2019 04:27:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=N4EXT+KAzvSkUibHj0irTKkqoM19twfIHPhL+1hl6bU=; b=mIZfW/HndLbwimd2AfrZRDZKjrTwOlBzq09GRYbMfg+mky/uSYkMJxiGF9bWINpOhn MlUfn9slBCeLErlacp6QTqgkta7OWC7yq+xf+3GhF2Gh12/mQr8ibpfh3NoAVS5i+XxM Vp12yJghPgDXb3cn4rVJ56tyzt75aY9HMODQlbZTZUl5G93fWQRs10LBEPRfVF3BWDMO lFyYnL/vR/+qGML9xB9Laj4JVdoMdIvIk1eqhudU/dOvhZ/YEo631LT941zErNxF+I+w KwjE9FJPuIGEcSlj0mNYpKvdOzABM2xhD8DoLuESg4uiP8HFU9XemPGV8vvdC1HioKTt X/ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=N4EXT+KAzvSkUibHj0irTKkqoM19twfIHPhL+1hl6bU=; b=OOi21FPUl4BEd1vjBW0WG98N7SygJMP2LyYNZlTzFC1zGFpguiQvGfCQVINntJ4p2W qzPLF9/KU4deD70i6x+GqEEGeJ0osq2a+15OtVOgHfP4X6f84l8BRSE8BFGgugaJoik+ gKPnPyiln6pY4vEqwbeEU6yvbsBX1Y7ILKBShXfoyZ0yhxdmUEHG45reO0GK6xmOe0T6 brSPnGbiegzkw0sbRqsUPYdB/1EY8ZKGJfmm7e/+DGA9SGZEmmr71eZeGD/dmI+StNc5 idUJFdFN4mihFnPummQaDICCd0TYMxcVAEAqdB80J2HUkp89xXOrt8OrBRgm60m6KC+C CFzw== X-Gm-Message-State: APjAAAU3yKRzeUljG79qKTxcxNrHw/zh63r6m3y69XRXg7T5oP0YUAMj KOT+2I1wKHuK4uOcOY42F1RQ8wYk9D66cWzNIYg= X-Google-Smtp-Source: APXvYqzdQjcWxQRy4EvLiopTxGV6piIcrc6bZbvRmede0W76ZgQ0gzrZR9cWO/yQ36h1WsGaKNyeS1S7JI6Doq6ptLA= X-Received: by 2002:a05:6638:762:: with SMTP id y2mr23782708jad.78.1575894448194; Mon, 09 Dec 2019 04:27:28 -0800 (PST) MIME-Version: 1.0 References: <871rtv3hit.fsf@cassou.me> <87a7823qg0.fsf@cassou.me> <87muc13cxm.fsf@cassou.me> In-Reply-To: <87muc13cxm.fsf@cassou.me> From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Date: Mon, 9 Dec 2019 13:27:17 +0100 Message-ID: Subject: Re: bug#38378: 26.3.50; [PATCH] Add the hierarchy library To: Damien Cassou Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 38378 Cc: johnw@newartisans.com, 38378@debbugs.gnu.org, Stefan Monnier , clement.pitclaudel@live.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On Mon, Dec 9, 2019 at 1:24 PM Damien Cassou wrote: > > Jo=C3=A3o T=C3=A1vora writes: > > ;; Library to create, query, navigate and display hierarchy structures. > > > > Did you omit "modify" specifically because it doesn't allow a created > > hierarchy to be mutated? > > a Hierarchy is created with (hierarchy-new) and must then be mutated to > add elements to it. This is the same as with (make-hash-table). But are existing external representations of that hierarchy (such as, say a buffer displaying it as text) automatically updated when you mutate it? Jo=C3=A3o From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 13 14:56:30 2019 Received: (at 38378) by debbugs.gnu.org; 13 Dec 2019 19:56:30 +0000 Received: from localhost ([127.0.0.1]:34661 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ifr38-0002Hv-1p for submit@debbugs.gnu.org; Fri, 13 Dec 2019 14:56:30 -0500 Received: from mail.choca.pics ([62.210.108.126]:51564) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ifr36-0002Hl-KR for 38378@debbugs.gnu.org; Fri, 13 Dec 2019 14:56:29 -0500 Received: from localhost (localhost.localdomain [IPv6:::1]) by mail.choca.pics (Postfix) with ESMTP id 7E3E7F09985; Fri, 13 Dec 2019 20:56:26 +0100 (CET) Received: from mail.choca.pics ([IPv6:::1]) by localhost (mail.choca.pics [IPv6:::1]) (amavisd-new, port 10032) with ESMTP id 1CgDbjnWbPVl; Fri, 13 Dec 2019 20:56:25 +0100 (CET) Received: from localhost (localhost.localdomain [IPv6:::1]) by mail.choca.pics (Postfix) with ESMTP id 90236F09986; Fri, 13 Dec 2019 20:56:25 +0100 (CET) X-Virus-Scanned: amavisd-new at choca.pics Received: from mail.choca.pics ([IPv6:::1]) by localhost (mail.choca.pics [IPv6:::1]) (amavisd-new, port 10026) with ESMTP id ZPq4oeJCUjTn; Fri, 13 Dec 2019 20:56:25 +0100 (CET) Received: from luz4 (254.116.5.93.rev.sfr.net [93.5.116.254]) by mail.choca.pics (Postfix) with ESMTPSA id 2D889F09985; Fri, 13 Dec 2019 20:56:25 +0100 (CET) From: Damien Cassou To: =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= Subject: Re: bug#38378: 26.3.50; [PATCH] Add the hierarchy library In-Reply-To: References: <871rtv3hit.fsf@cassou.me> <87a7823qg0.fsf@cassou.me> <87muc13cxm.fsf@cassou.me> Date: Fri, 13 Dec 2019 20:56:24 +0100 Message-ID: <87y2vgf193.fsf@cassou.me> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 38378 Cc: johnw@newartisans.com, 38378@debbugs.gnu.org, Stefan Monnier , clement.pitclaudel@live.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Jo=C3=A3o T=C3=A1vora writes: > On Mon, Dec 9, 2019 at 1:24 PM Damien Cassou wrote: >> a Hierarchy is created with (hierarchy-new) and must then be mutated to >> add elements to it. This is the same as with (make-hash-table). > > But are existing external representations of that hierarchy (such as, say > a buffer displaying it as text) automatically updated when you mutate it? nothing has been done or is planned to go in that direction. I guess it would be possible to add hooks here and there to implement something like that but I haven't spent any time thinking about it. --=20 Damien Cassou "Success is the ability to go from one failure to another without losing enthusiasm." --Winston Churchill From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 09 08:50:19 2020 Received: (at 38378) by debbugs.gnu.org; 9 Aug 2020 12:50:19 +0000 Received: from localhost ([127.0.0.1]:60330 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k4kmJ-0007ov-EI for submit@debbugs.gnu.org; Sun, 09 Aug 2020 08:50:19 -0400 Received: from quimby.gnus.org ([95.216.78.240]:35856) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k4kmI-0007oY-BG for 38378@debbugs.gnu.org; Sun, 09 Aug 2020 08:50:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=ZLkNSe1PAEhRnswuVzICWZ6cgYW/cnXqPlBr13lMLFA=; b=WO9F0/joVn7yPETE+d3r+YS6wr J+qEEODoLBCriJJ7Q40wbcMvueH7KCc0x9g2OD8BhbnQfej+Yok6ssB9f1VhqXVAcY8nIby0sbO5x aLG0jrG8YUXTIEHg3iDhYqkivWnqTVeTLDPq2N/EsNivZ0yfAWGRzMu0R7VS6QzUsFPA=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k4kls-00023I-Si; Sun, 09 Aug 2020 14:50:05 +0200 From: Lars Ingebrigtsen To: Damien Cassou Subject: Re: bug#38378: 26.3.50; [PATCH] Add the hierarchy library References: <871rtv3hit.fsf@cassou.me> Date: Sun, 09 Aug 2020 14:49:51 +0200 In-Reply-To: <871rtv3hit.fsf@cassou.me> (Damien Cassou's message of "Mon, 25 Nov 2019 20:03:38 +0100") Message-ID: <87eeogrnkg.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Damien Cassou writes: > Please find attached a patch adding hierarchy.el and > hierarchy-tests.el. The hierarchy library allows to create, query, > navigate and display hierarchy structures. > > Two years ago, I suggested [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 38378 Cc: johnw@newartisans.com, 38378@debbugs.gnu.org, clement.pitclaudel@live.com, joaotavora@gmail.com, eliz@gnu.org, monnier@IRO.UMontreal.CA X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Damien Cassou writes: > Please find attached a patch adding hierarchy.el and > hierarchy-tests.el. The hierarchy library allows to create, query, > navigate and display hierarchy structures. > > Two years ago, I suggested adding this library to ELPA and you guys on > CC answered you wanted it in Emacs core: > https://lists.gnu.org/archive/html/emacs-devel/2017-10/msg00624.html > > You also had several suggestions and I implemented none of them. I agree > they all make sense, I just haven't found motivation to do that yet > because hierarchy is working well for me already. > > What do you think? There was some discussion about whether to put this in ELPA or Emacs core, but Eli seemed to be in favour of having it in Emacs core, so I've now applied the patch. This makes sense to me, too -- it's infrastructure, so having it in the core makes things much easier for other applications to depend on it. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 09 08:50:19 2020 Received: (at control) by debbugs.gnu.org; 9 Aug 2020 12:50:19 +0000 Received: from localhost ([127.0.0.1]:60328 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k4kmJ-0007os-8u for submit@debbugs.gnu.org; Sun, 09 Aug 2020 08:50:19 -0400 Received: from quimby.gnus.org ([95.216.78.240]:35860) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k4kmI-0007oZ-DW for control@debbugs.gnu.org; Sun, 09 Aug 2020 08:50:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Subject:From:To:Message-Id:Date:Sender:Reply-To:Cc: MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=MRirPrCG8KEJ+0gpeo3z+TPk1ipcbdU4oLtkLMDJGjo=; b=Mfo7lFEgclCxUq8GtMZ+DZA1G7 Cr6RyiBtW9tThwIcnkNDIbTU7hItm8N1Zv+hhPEH9Yz/vwSKQUyaq2i09ZnmCfLO9agG29eRTErns 3hM5+gHvwKrgquSplsUHllgrsXTmK2AjEZhGhqp90p0oaNCpQhgu0yhXbxybv6g9lCl4=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k4kmA-00023W-JN for control@debbugs.gnu.org; Sun, 09 Aug 2020 14:50:12 +0200 Date: Sun, 09 Aug 2020 14:50:09 +0200 Message-Id: <87d040rnjy.fsf@gnus.org> To: control@debbugs.gnu.org From: Lars Ingebrigtsen Subject: control message for bug #38378 X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: tags 38378 fixed close 38378 28.1 quit Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) tags 38378 fixed close 38378 28.1 quit From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 09 08:52:38 2020 Received: (at 38378) by debbugs.gnu.org; 9 Aug 2020 12:52:38 +0000 Received: from localhost ([127.0.0.1]:60337 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k4koX-0007sp-RV for submit@debbugs.gnu.org; Sun, 09 Aug 2020 08:52:38 -0400 Received: from quimby.gnus.org ([95.216.78.240]:35898) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k4koS-0007sZ-Qo for 38378@debbugs.gnu.org; Sun, 09 Aug 2020 08:52:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=ZW/WuU4cBNTmkgYb4nR1HoMz6Gd25AnUAI/JZKiOrX0=; b=NKY4nKwAyNsHGP5CEiwZ1kkuKS v+5rwu3H3EL4ev8x/H1sRIgoxvzSBy3ZAZSynDIDV054fzs5aifgo+8Qd7XxQJO903poXwBHLYx/P 9oNdMc2lW3FALWc8TWG/8abRjlwYknEC+ieBvF/ycf9QJs2fev7lkt3RJ6/xYMwsZT18=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k4ko9-00024K-M7; Sun, 09 Aug 2020 14:52:19 +0200 From: Lars Ingebrigtsen To: Damien Cassou Subject: Re: bug#38378: 26.3.50; [PATCH] Add the hierarchy library References: <871rtv3hit.fsf@cassou.me> Date: Sun, 09 Aug 2020 14:52:11 +0200 In-Reply-To: <871rtv3hit.fsf@cassou.me> (Damien Cassou's message of "Mon, 25 Nov 2019 20:03:38 +0100") Message-ID: <878seorngk.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: (I forgot to mention that I did some changes to the code before committing it -- I folded some too-long lines, and I changed the copyright line to be the FSF's. I also changed map-put to map-put!, as [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 38378 Cc: johnw@newartisans.com, 38378@debbugs.gnu.org, clement.pitclaudel@live.com, joaotavora@gmail.com, eliz@gnu.org, monnier@IRO.UMontreal.CA X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) (I forgot to mention that I did some changes to the code before committing it -- I folded some too-long lines, and I changed the copyright line to be the FSF's. I also changed map-put to map-put!, as the former is now obsolete. The tests still ran after the changes, so I'm guessing that they didn't break anything, even if I haven't run the hierarchy functions myself.) -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From unknown Mon Jun 23 18:28:50 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Mon, 07 Sep 2020 11:24:08 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator