From: Damien Cassou <damien@cassou.me>
To: mousebot@riseup.net, emacs-devel@gnu.org
Subject: hierarchy-print doesn't allow sending indent-string arg to hierarchy-map
Date: Wed, 26 Jul 2023 18:16:04 +0200 [thread overview]
Message-ID: <87a5vi4piz.fsf@cassou.me> (raw)
In-Reply-To: b505ea2b-eca7-2233-255e-23cbbbed502e@riseup.net
Hi,
you are right that something isn't good enough. The fix you suggest
fixes the problem. Unfortunately, it is backward incompatible: all
usages of `hierarchy-print' passing a custom value for TO-STRING will
now fail because TO-STRING should now read a second argument.
Additionally, I think it shouldn't be the responsibility of
`hierarchy-print' to take care of the indentation.
Had I been smart enough, I would probably have written `hierarchy-print'
this way instead:
(defun hierarchy-print (hierarchy &optional to-string)
(let ((to-string (or to-string (lambda (item) (format "%s" item)))))
(hierarchy-map
(lambda (item indent)
(insert (funcall to-string item ident) "\n"))
hierarchy)))
That is:
- TO-STRING takes 2 parameters
- indentation should be decided by the user through a dedicated value
TO-STRING value, e.g., with
(hierarchy-labelfn-indent (lambda (item) (format "%s" item)))
But this implementation also breaks backward compatibility. What I
suggest:
1. Implement `hierarchy-print-line' with the implementation above (this
way we have a good implementation anyone can use)
2. Refactor and simplify `hierarchy-print` to avoid duplication with
`hierarchy-print-line' but keeping backward compatibility.
What do you think? Would you mind sending a patch?
(please keep me on CC)
Best
--
Damien Cassou
"Success is the ability to go from one failure to another without
losing enthusiasm." --Winston Churchill
next reply other threads:[~2023-07-26 16:16 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-26 16:16 Damien Cassou [this message]
2023-07-29 13:33 ` hierarchy-print doesn't allow sending indent-string arg to hierarchy-map mousebot
2023-07-30 6:16 ` Damien Cassou
2023-08-01 11:11 ` mousebot
2023-08-02 15:48 ` Damien Cassou
-- strict thread matches above, loose matches on Subject: below --
2023-07-12 13:43 mousebot
2023-07-13 3:38 ` Michael Heerdegen
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=87a5vi4piz.fsf@cassou.me \
--to=damien@cassou.me \
--cc=emacs-devel@gnu.org \
--cc=mousebot@riseup.net \
/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).