[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: hierarchy-print doesn't allow sending indent-string arg to hierarchy
From: |
Michael Heerdegen |
Subject: |
Re: hierarchy-print doesn't allow sending indent-string arg to hierarchy-map |
Date: |
Thu, 13 Jul 2023 05:38:11 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
Hello,
Maybe Damien (the author) doesn't read this, I added an CC field.
mousebot <mousebot@riseup.net> writes:
> hi emacs,
>
> `hierarchy-labelfn-indent' takes an optional second argument
> `indent-string'.
>
> `hierarchy-print' calls `hierarchy-labelfn-indent', but doesn't allow
> providing it with an `indent-string' arg.
>
> it also provides no second argument to the labelfn arg of
> `hierarchy-labelfn-indent'.
>
> hierarchy-print looks like this:
>
> ```
> (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)))
> ```
>
>
> i'm working on a client and i'm using a copy of `hierarchy-print' that
> looks like this:
>
> ```
> (defun hierarchy-print (hierarchy &optional to-string indent-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 indent) ; add indent
> (insert (funcall to-string item indent)
> "\n")) ; add indent
> indent-string) ; add indent-string
> hierarchy)))
> ```
>
> i provide optional arg `indent-string' and hand it to
> `hierarchy-map'. i also provide a second 'indent' arg to the lambda
> that is the first arg for `hierarchy-labelfn-indent', indent is then
> given as the last arg of `funcall'. this allows me to print indented
> tree structures, which i was unable to achieve otherwise.
>
> is there a reason this isn't the way `hierarchy-print' is coded? is
> there perhaps another way to achieve the same result? i have little
> experience with `hierarchy.el'.
>
> regards,
> m