Subject: Re: bug#71284: 30.0.50; [PATCH] Add support for outline-minor-mode to Eshell

From: Juri Linkov <[email-masked]>
Date: Mon, 03 Jun 2024 09:45:37 +0300

> In any case, the more I think about this, the more my current patch seems
> like the wrong way to go about this. Even just describing the user-facing
> behavior in all scenarios is pretty complex, so I think it might be better
> to keep it simple and have a single outline level.
>
> That said, for the multi-line prompt case, I wonder if it would make sense
> for outline.el to support multi-line headers. If I could mark the entire
> prompt + command input as a "header", then collapsing it would look better:
> users would still see all of their input in the collapsed node.

The multi-line headers have such disadvantage that the outlines
are not compact anymore.  Also multi-line headers might have
more technial issues with displaying an ellipsis at the end.

> It would look something like so:
>
>   v /home/user/dir
>     $ cat some-file.txt
>     output
>     output
>     output
>
>   > /home/user/dir
>     $ cat some-file.txt...

This is a known problem.  Recently I had to add a special handling
in c-ts-mode--outline-predicate to put the outline heading on the
line with the function name instead of the first line with types:

    static void
  v bset_mode_name (struct buffer *b, Lisp_Object val)
    {
      b->mode_name_ = val;
    }

    static void
  v bset_name (struct buffer *b, Lisp_Object val)
    {
      b->name_ = val;
    }

In your case you could do something similar in eshell-outline-search
to put the outline heading on the meaningful line:

    /home/user/dir
  v $ cat some-file.txt
    output
    output
    output

This is not ideal either since the first line belongs to the
previous outline.  This is a known problem too.  For example,
in etc/NEWS, the top +++ is not part of the outline, e.g.

  +++
  *** 'outline-minor-mode' is supported in tree-sitter major modes.
  It can be used in all tree-sitter major modes that set either the
  variable 'treesit-simple-imenu-settings' or 'treesit-outline-predicate'.