minad / consult

:mag: consult.el - Consulting completing-read
GNU General Public License v3.0
1.12k stars 98 forks source link

Add support to display the matched heading's sub-headings also as candidates in the consult-outline's completion #987

Closed IceAsteroid closed 1 month ago

IceAsteroid commented 1 month ago

Is it possible to display the matched heading and plus its sub-headdings as candidates in consult-outline?

For example:

* Colors
** Red
*** Apple
** Yellow
*** Banana
* Fruits
** Orange
** Apple

Say if I search for Colors, the minibufer's candidates would be:

* Colors
** Red
*** Apple
** Yellow
*** Banana

If heading level is triggerd, say Level 2, the candidates would be:

* Colors
** Red
** Yellow

The reason why not to use consult-org-heading instead, is because it displays subheadings preceded by its parent headings.

When a subheading is deeply nested, the heading can't be displayed correctly as it's truncated at the edge, except its parent headings are shown.

It would however be:

first-level heading A/subheading1/subheading1.1/subheading1.1.1/sub->
first-level heading B/subheading1/subheading1.1/subheading1.1.1/sub->

Edit: In conclusion, if to search a heading would also produce its sub-headings as candidates below it, it'd still be clear of the levels of each heading, with even only asterisks in org, or semi-colons in elisp, etc,

minad commented 1 month ago

Duplicate https://github.com/minad/consult/discussions/862

IceAsteroid commented 1 month ago

@minad The issue of what it's described, is not exactly duplicated with #862

IceAsteroid commented 4 weeks ago

Duplicate #862

Not exactly duplicate though, the implementations are different. Here I just want consult to be able to display the searched heading and also its sub-headings as candidates, nothing else. No nesting "nested parent titles" like "parent1/parent2/the_subheading" etc

Let's be clear, this is actually very useful and intuitive. The operational logic in emacs, especially org-mode combined with consult, is very different from other GUI programs.

By default, headings in org-mode don't show what, and how many sub headings they have when collapsed. This is why I was urged to have a way to solve this

You can see the following pictures, I managed to implement it with a big help by dalanicolai

consult-org-issue1

consult-org-issue2

So when headings are collapsed, I know what headings exactly have sub-headings, and where to expand to take a look.

It barely solves this at least for the navigation in the buffer.

But when an org file is too big, I gotta use consult for quicker navigation across the file.

Now, with consult-org-heading or consult-oultine, the operational logic is strongly incomplete and discouraging.

Say if I search for a heading, its sub-headings are no way or configured to be shown as candidates, why?

It's ok if an org file is small, but when getting bigger, this problem is gonna be increasingly annoying.

consult-org-heading can theoretically do this, but when a heading's title or its parents' titles are getting longer, it's barely unusable, especially in smaller screened devices like a 13-inch laptop, which the heading's title is exceeded and truncated at the edge by its too long parent titles