branch: externals/taxy
commit 8b66f800aa9ddddeff7c38f2857102e1f1e469bc
Author: Adam Porter <[email protected]>
Commit: Adam Porter <[email protected]>
Add: (taxy-lift)
The first new feature in a long time!
---
README.org | 5 ++++-
taxy.el | 25 +++++++++++++++++++++
taxy.info | 75 +++++++++++++++++++++++++++++++++++---------------------------
3 files changed, 72 insertions(+), 33 deletions(-)
diff --git a/README.org b/README.org
index 8776c0663e..1dba370c90 100644
--- a/README.org
+++ b/README.org
@@ -894,6 +894,8 @@ In Emacs 28+, see also =M-x shortdoc-display-group RET taxy
RET=.
- taxy-fill (items taxy) ::
Fill =taxy= with =items= according to its definition.
+- taxy-lift (taxy) :: Return =taxy= having "lifted" its sub-taxys. That is, a
sub-taxy which has fewer items than ~taxy-lift-min-items~ will have its items
\"lifted\" into its parent taxy's items, and the sub-taxy itself will be
removed from its parent taxy's taxys. This operates recursively within
=taxy='s sub-taxys.
+
- taxy-make-take-function (keys aliases) ::
Return a taxy "take" function for =keys=. Each of =keys= should be a
function alias defined in =aliases=, or a list of such =key-fns= (recursively,
ad infinitum, approximately). =aliases= should be an alist mapping aliases to
functions (such as defined with a definer defined by ~taxy-define-key-definer~).
@@ -935,7 +937,8 @@ In Emacs 28+, see also =M-x shortdoc-display-group RET taxy
RET=.
** v0.11-pre
-Nothing new yet.
+*Additions*
++ Function ~taxy-lift~, which "lifts" the items in sub-taxys which have fewer
than a certain number of items into parent taxys (helping to reduce the number
of taxys with only a few items in them).
** 0.10.2
diff --git a/taxy.el b/taxy.el
index e136655069..614be03ff8 100644
--- a/taxy.el
+++ b/taxy.el
@@ -119,6 +119,31 @@ when reusing taxy definitions."
(cl-loop for taxy in (taxy-taxys taxy)
append (taxy-flatten taxy))))
+(defvar taxy-lift-min-items 2
+ "In `taxy-lift', taxys with fewer than this many items will be \"lifted\".
+That is, their items will be lifted into their parent taxy, and the taxy
+itself will be removed from the parent taxy's taxys.
+
+This is defined as a special variable because passing the argument
+directly to the function would deny the ability to call the function in
+a threading style.")
+
+(defun taxy-lift (taxy)
+ "Return TAXY having \"lifted\" its sub-taxys.
+That is, a sub-taxy which has fewer items than `taxy-lift-min-items'
+will have its items \"lifted\" into its parent taxy's items, and the
+sub-taxy itself will be removed from its parent taxy's taxys. This
+operates recursively within TAXY's sub-taxys."
+ (cl-labels ((rec (taxy)
+ (mapc #'rec (taxy-taxys taxy))
+ (dolist (sub-taxy (taxy-taxys taxy))
+ (when (< 0 (length (taxy-items sub-taxy))
taxy-lift-min-items)
+ (cl-callf2 append (taxy-items sub-taxy) (taxy-items taxy))
+ (cl-callf2 remq sub-taxy (taxy-taxys taxy))
+ (setf (taxy-items sub-taxy) nil)))))
+ (rec taxy))
+ taxy)
+
(defun taxy-mapcar-items (fn taxy)
"Return copy of TAXY, having replaced its items with the value of FN on each.
Replaces every item in TAXY and its descendants. Useful to
diff --git a/taxy.info b/taxy.info
index 72f3bce942..564f037126 100644
--- a/taxy.info
+++ b/taxy.info
@@ -1076,6 +1076,13 @@ taxy-emptied (taxy)
taxy-fill (items taxy)
Fill ‘taxy’ with ‘items’ according to its definition.
+taxy-lift (taxy)
+ Return ‘taxy’ having "lifted" its sub-taxys. That is, a sub-taxy
+ which has fewer items than ‘taxy-lift-min-items’ will have its
+ items \"lifted\" into its parent taxy's items, and the sub-taxy
+ itself will be removed from its parent taxy's taxys. This operates
+ recursively within ‘taxy’'s sub-taxys.
+
taxy-make-take-function (keys aliases)
Return a taxy "take" function for ‘keys’. Each of ‘keys’ should be
a function alias defined in ‘aliases’, or a list of such ‘key-fns’
@@ -1159,7 +1166,11 @@ File: README.info, Node: v011-pre, Next: 0102, Up:
Changelog
4.1 v0.11-pre
=============
-Nothing new yet.
+*Additions*
+ • Function ‘taxy-lift’, which "lifts" the items in sub-taxys which
+ have fewer than a certain number of items into parent taxys
+ (helping to reduce the number of taxys with only a few items in
+ them).
File: README.info, Node: 0102, Next: 0101, Prev: v011-pre, Up: Changelog
@@ -1508,37 +1519,37 @@ Node: Defining a classification domain-specific
language33075
Node: Magit section37230
Node: Reference37898
Node: Functions38106
-Node: Macros40084
-Node: Changelog40734
-Node: v011-pre41019
-Node: 010241133
-Node: 010141368
-Node: 01041528
-Node: 0941744
-Node: Changes41854
-Node: 0842226
-Node: Additions42347
-Node: Fixes42491
-Node: 0742629
-Node: Additions (1)42754
-Node: 0643073
-Node: Additions (2)43198
-Node: 0544546
-Node: Additions (3)44691
-Node: Fixes (1)45799
-Node: 0445957
-Node: 0346179
-Node: Changes (1)46322
-Node: Fixes (2)46691
-Node: 0247130
-Node: Changes (2)47301
-Node: Additions (4)47591
-Node: Fixes (3)48514
-Node: 0148768
-Node: Development48869
-Node: Copyright assignment49075
-Node: Credits49670
-Node: License49860
+Node: Macros40439
+Node: Changelog41089
+Node: v011-pre41374
+Node: 010241705
+Node: 010141940
+Node: 01042100
+Node: 0942316
+Node: Changes42426
+Node: 0842798
+Node: Additions42919
+Node: Fixes43063
+Node: 0743201
+Node: Additions (1)43326
+Node: 0643645
+Node: Additions (2)43770
+Node: 0545118
+Node: Additions (3)45263
+Node: Fixes (1)46371
+Node: 0446529
+Node: 0346751
+Node: Changes (1)46894
+Node: Fixes (2)47263
+Node: 0247702
+Node: Changes (2)47873
+Node: Additions (4)48163
+Node: Fixes (3)49086
+Node: 0149340
+Node: Development49441
+Node: Copyright assignment49647
+Node: Credits50242
+Node: License50432
End Tag Table