unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Michael Heerdegen <michael_heerdegen@web.de>
To: emacs-devel@gnu.org
Cc: Damien Cassou <damien@cassou.me>
Subject: Re: hierarchy-print doesn't allow sending indent-string arg to hierarchy-map
Date: Thu, 13 Jul 2023 05:38:11 +0200	[thread overview]
Message-ID: <878rbkmqfw.fsf@web.de> (raw)
In-Reply-To: b505ea2b-eca7-2233-255e-23cbbbed502e@riseup.net

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




  reply	other threads:[~2023-07-13  3:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-12 13:43 hierarchy-print doesn't allow sending indent-string arg to hierarchy-map mousebot
2023-07-13  3:38 ` Michael Heerdegen [this message]
  -- strict thread matches above, loose matches on Subject: below --
2023-07-26 16:16 Damien Cassou
2023-07-29 13:33 ` mousebot
2023-07-30  6:16   ` Damien Cassou
2023-08-01 11:11     ` mousebot
2023-08-02 15:48       ` Damien Cassou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=878rbkmqfw.fsf@web.de \
    --to=michael_heerdegen@web.de \
    --cc=damien@cassou.me \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).