[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/taxy 81285bf 1/4: Add: (taxy-magit-section) New slots
From: |
ELPA Syncer |
Subject: |
[elpa] externals/taxy 81285bf 1/4: Add: (taxy-magit-section) New slots |
Date: |
Mon, 6 Sep 2021 11:57:19 -0400 (EDT) |
branch: externals/taxy
commit 81285bf3455032ff8de74ccd1da629a5a92ade7f
Author: Adam Porter <adam@alphapapa.net>
Commit: Adam Porter <adam@alphapapa.net>
Add: (taxy-magit-section) New slots
---
README.org | 7 ++++
taxy-magit-section.el | 105 +++++++++++++++++++++++++++++++-------------------
taxy.info | 99 +++++++++++++++++++++++++++++------------------
3 files changed, 134 insertions(+), 77 deletions(-)
diff --git a/README.org b/README.org
index 7e1c625..ee5c594 100644
--- a/README.org
+++ b/README.org
@@ -776,6 +776,13 @@ Note that while =taxy-magit-section.el= is installed with
the =taxy= package, th
** 0.5-pre
+*** Additions
+
++ Function ~taxy-magit-section-insert~ takes new arguments:
+ - ~:initial-depth~ sets the level at which the first level of hierarchy
is considered to be at, for purposes of indentation. Setting it to a negative
number prevents indentation of so many levels (i.e. setting it to -1 causes the
first two levels to be unindented, since the first level will be considered to
be at depth -1, and the second at depth 0).
+ - ~:blank-between-depth~ sets the level up to which blank lines are
inserted between sections (i.e. setting it to 1 causes blank lines to be
inserted between sections up to depth 1, but not between sections deeper than
that).
++ Struct ~taxy-magit-section~ has a new ~heading-face~ slot, a function which
takes a depth level argument and returns the face with which to propertize that
section's heading.
+
*** Fixes
+ Example ~diredy~ referred to an old function name.
diff --git a/taxy-magit-section.el b/taxy-magit-section.el
index 9076fb7..f762062 100644
--- a/taxy-magit-section.el
+++ b/taxy-magit-section.el
@@ -40,11 +40,25 @@
;;;; Structs
-(cl-defstruct (taxy-magit-section (:include taxy))
- ;; This struct is not required to be used for taxys passed to
- ;; `taxy-magit-section-insert', but it allows a visibility function
- ;; to be specified to override the default for it.
+;; NOTE: When making `taxy-magit-section' structs at runtime
+;; (e.g. with `taxy-take-keyed'), the struct's `make' slot must be set
+;; to a function that returns a new struct with the other slots set as
+;; desired; the slots' values do not automatically propagate to
+;; structs with the default `make' function. (Using `cl-labels' to
+;; define the `make' function makes this simple.)
+
+;; MAYBE: In `taxy-take-keyed', use `taxy-emptied' to copy structs
+;; with inheritance for relevant slots, so defining custom `make'
+;; functions wouldn't be necessary.
+
+(cl-defstruct (taxy-magit-section
+ (:include taxy
+ (make #'make-taxy-magit-section)))
+ ;; MAYBE: Pass parent section to the :make function, would make
+ ;; inheritance easier (and/or use EIEIO, but that would reduce
+ ;; performance, since slot accessors can't be optimized).
(visibility-fn #'taxy-magit-section-visibility)
+ (heading-face (lambda (_depth) 'magit-section-heading))
(indent 2)
format-fn)
@@ -53,14 +67,17 @@
;;;; Functions
-(cl-defun taxy-magit-section-insert (taxy &key (items 'first))
+(cl-defun taxy-magit-section-insert (taxy &key (items 'first) (initial-depth
0) (blank-between-depth 1))
"Insert a `magit-section' for TAXY into current buffer.
-If ITEMS is `first', insert a taxy's items before its
-descendant taxys; if `last', insert them after descendants."
- (let* ((depth 0)
- (magit-section-set-visibility-hook (cons
#'taxy-magit-section-visibility magit-section-set-visibility-hook)))
+If ITEMS is `first', insert a taxy's items before its descendant
+taxys; if `last', insert them after descendants. INITIAL-DEPTH
+is the initial indentation depth; it may be, e.g. -1 to make the
+second level unindented. BLANK-BETWEEN-DEPTH is the level up to
+which blank lines are inserted between sections at that level."
+ (let* ((magit-section-set-visibility-hook
+ (cons #'taxy-magit-section-visibility
magit-section-set-visibility-hook)))
(cl-labels ((insert-item
- (item format-fn indent)
+ (item format-fn depth indent)
(magit-insert-section (magit-section item)
(magit-insert-section-body
;; This is a tedious way to give the indent
@@ -71,42 +88,50 @@ descendant taxys; if `last', insert them after descendants."
;; `magit-section' didn't navigate the sections
;; properly anymore.
(let* ((formatted (funcall format-fn item))
- (indent (make-string (+ 2 (* depth indent)) ? )))
+ (indent (make-string (+ 2 (* (pcase depth
+ ((pred (> 0)) 0)
+ (_ depth))
+ indent)) ? )))
(add-text-properties 0 (length indent)
(text-properties-at 0 formatted)
indent)
(insert indent formatted "\n")))))
(insert-taxy
- (taxy) (let ((magit-section-set-visibility-hook
magit-section-set-visibility-hook)
- (format-fn (cl-typecase taxy
- (taxy-magit-section
- (taxy-magit-section-format-fn
taxy))
- (t (lambda (o) (format "%s" o))))))
- (cl-typecase taxy
- (taxy-magit-section
- (when (taxy-magit-section-visibility-fn taxy)
- (push (taxy-magit-section-visibility-fn taxy)
magit-section-set-visibility-hook))))
- (magit-insert-section (magit-section taxy)
- (magit-insert-heading
- (make-string (* depth taxy-magit-section-indent)
? )
- (propertize (taxy-name taxy) 'face
'magit-section-heading)
- (format " (%s%s)"
- (if (taxy-description taxy)
- (concat (taxy-description taxy) " ")
- "")
- (taxy-size taxy)))
- (magit-insert-section-body
- (when (eq 'first items)
- (dolist (item (taxy-items taxy))
- (insert-item item format-fn
(taxy-magit-section-indent taxy))))
- (cl-incf depth)
- (mapc #'insert-taxy (taxy-taxys taxy))
- (cl-decf depth)
- (when (eq 'last items)
- (dolist (item (taxy-items taxy))
- (insert-item item format-fn
(taxy-magit-section-indent taxy)))))))))
+ (taxy depth) (let ((magit-section-set-visibility-hook
magit-section-set-visibility-hook)
+ (format-fn (cl-typecase taxy
+ (taxy-magit-section
+
(taxy-magit-section-format-fn taxy))
+ (t (lambda (o) (format "%s"
o))))))
+ (cl-typecase taxy
+ (taxy-magit-section
+ (when (taxy-magit-section-visibility-fn
taxy)
+ (push (taxy-magit-section-visibility-fn
taxy) magit-section-set-visibility-hook))))
+ (magit-insert-section (magit-section taxy)
+ (magit-insert-heading
+ (make-string (* (pcase depth
+ ((pred (> 0)) 0)
+ (_ depth))
+ taxy-magit-section-indent)
? )
+ (propertize (taxy-name taxy)
+ 'face (funcall
(taxy-magit-section-heading-face taxy) depth))
+ (format " (%s%s)"
+ (if (taxy-description taxy)
+ (concat (taxy-description
taxy) " ")
+ "")
+ (taxy-size taxy)))
+ (magit-insert-section-body
+ (when (eq 'first items)
+ (dolist (item (taxy-items taxy))
+ (insert-item item format-fn depth
(taxy-magit-section-indent taxy))))
+ (dolist (taxy (taxy-taxys taxy))
+ (insert-taxy taxy (1+ depth)))
+ (when (eq 'last items)
+ (dolist (item (taxy-items taxy))
+ (insert-item item format-fn depth
(taxy-magit-section-indent taxy)))))
+ (when (<= depth blank-between-depth)
+ (insert "\n"))))))
(magit-insert-section (magit-section)
- (insert-taxy taxy)))))
+ (insert-taxy taxy initial-depth)))))
(cl-defun taxy-magit-section-pp (taxy &key (items 'first))
"Pretty-print TAXY into a buffer with `magit-section' and show it."
diff --git a/taxy.info b/taxy.info
index 195ad21..c45a432 100644
--- a/taxy.info
+++ b/taxy.info
@@ -56,10 +56,12 @@ Changelog
0.5-pre
+* Additions::
* Fixes::
+
0.3
* Changes::
@@ -70,7 +72,7 @@ Changelog
0.2
* Changes: Changesx.
-* Additions::
+* Additions: Additionsx.
* Fixes: Fixesxx.
Development
@@ -920,12 +922,34 @@ File: README.info, Node: 05-pre, Next: 04, Up:
Changelog
* Menu:
+* Additions::
* Fixes::
-File: README.info, Node: Fixes, Up: 05-pre
+File: README.info, Node: Additions, Next: Fixes, Up: 05-pre
+
+4.1.1 Additions
+---------------
+
+ • Function ‘taxy-magit-section-insert’ takes new arguments:
+ • ‘:initial-depth’ sets the level at which the first level of
+ hierarchy is considered to be at, for purposes of indentation.
+ Setting it to a negative number prevents indentation of so
+ many levels (i.e. setting it to -1 causes the first two
+ levels to be unindented, since the first level will be
+ considered to be at depth -1, and the second at depth 0).
+ • ‘:blank-between-depth’ sets the level up to which blank lines
+ are inserted between sections (i.e. setting it to 1 causes
+ blank lines to be inserted between sections up to depth 1, but
+ not between sections deeper than that).
+ • Struct ‘taxy-magit-section’ has a new ‘heading-face’ slot, a
+ function which takes a depth level argument and returns the face
+ with which to propertize that section’s heading.
+
+
+File: README.info, Node: Fixes, Prev: Additions, Up: 05-pre
-4.1.1 Fixes
+4.1.2 Fixes
-----------
• Example ‘diredy’ referred to an old function name.
@@ -982,11 +1006,11 @@ File: README.info, Node: 02, Next: 01, Prev: 03, Up:
Changelog
* Menu:
* Changes: Changesx.
-* Additions::
+* Additions: Additionsx.
* Fixes: Fixesxx.
-File: README.info, Node: Changesx, Next: Additions, Up: 02
+File: README.info, Node: Changesx, Next: Additionsx, Up: 02
4.4.1 Changes
-------------
@@ -996,7 +1020,7 @@ File: README.info, Node: Changesx, Next: Additions, Up:
02
reason to maintain two versions.
-File: README.info, Node: Additions, Next: Fixesxx, Prev: Changesx, Up: 02
+File: README.info, Node: Additionsx, Next: Fixesxx, Prev: Changesx, Up: 02
4.4.2 Additions
---------------
@@ -1014,7 +1038,7 @@ File: README.info, Node: Additions, Next: Fixesxx,
Prev: Changesx, Up: 02
*note example: "Chains" of independent multi-level dynamic taxys.
-File: README.info, Node: Fixesxx, Prev: Additions, Up: 02
+File: README.info, Node: Fixesxx, Prev: Additionsx, Up: 02
4.4.3 Fixes
-----------
@@ -1078,36 +1102,37 @@ GPLv3
Tag Table:
Node: Top218
-Node: Examples1709
-Node: Numbery (starting basically)2028
-Node: Lettery (filling incrementally)7783
-Node: Sporty (understanding completely)10463
-Node: Applications16450
-Node: Installation16850
-Node: Usage17151
-Node: Dynamic taxys19288
-Node: Multi-level dynamic taxys21843
-Node: "Chains" of independent multi-level dynamic taxys24036
-Node: Reusable taxys26908
-Node: Threading macros31077
-Node: Modifying filled taxys31616
-Node: Magit section32699
-Node: Changelog33357
-Node: 05-pre33543
-Node: Fixes33651
-Node: 0433787
-Node: 0334013
-Node: Changes34140
-Node: Fixesx34489
-Node: 0234921
-Node: Changesx35073
-Node: Additions35358
-Node: Fixesxx36272
-Node: 0136520
-Node: Development36619
-Node: Copyright assignment36825
-Node: Credits37412
-Node: License37602
+Node: Examples1736
+Node: Numbery (starting basically)2055
+Node: Lettery (filling incrementally)7810
+Node: Sporty (understanding completely)10490
+Node: Applications16477
+Node: Installation16877
+Node: Usage17178
+Node: Dynamic taxys19315
+Node: Multi-level dynamic taxys21870
+Node: "Chains" of independent multi-level dynamic taxys24063
+Node: Reusable taxys26935
+Node: Threading macros31104
+Node: Modifying filled taxys31643
+Node: Magit section32726
+Node: Changelog33384
+Node: 05-pre33570
+Node: Additions33692
+Node: Fixes34752
+Node: 0434906
+Node: 0335132
+Node: Changes35259
+Node: Fixesx35608
+Node: 0236040
+Node: Changesx36204
+Node: Additionsx36490
+Node: Fixesxx37405
+Node: 0137654
+Node: Development37753
+Node: Copyright assignment37959
+Node: Credits38546
+Node: License38736
End Tag Table