localauthor / org-side-tree

Navigate Org-mode outlines in Emacs via side window
GNU General Public License v3.0
40 stars 4 forks source link

Unable to open the selected & collapsed sub-headings for org-mode buffer by org-side-tree #15

Closed IceAsteroid closed 5 months ago

IceAsteroid commented 5 months ago

Hi, greetings! @localauthor, long time no see :)

Selecting sub-headings of a heading but the corresponding heading is collapsed in the org-mode buffer, will not be able to expand the selected headings as expected.

It's as shown below:

https://github.com/localauthor/org-side-tree/assets/90975914/bab0890b-0624-4ee8-8198-972efe131098

localauthor commented 5 months ago

~It looks like you have outline-minor-mode subheadings inside code blocks in an org file. Is that right?~

Nevermind, I see that's not the issue. Looking into it...

localauthor commented 5 months ago

Could you evaluate the following function, then try again and see if the expected behavior occurs?

(defun org-side-tree-goto-marker (marker)
  "Go to MARKER, widen if necessary."
  (when (or (> marker (point-max))
            (< marker (point-min)))
    (widen))
  (goto-char marker)
  (outline-show-entry))
IceAsteroid commented 5 months ago

It worked. But the ending ellipsis is leftover in the end of the content

I also tested with bare configuration with org-side-tree, it turned out that was not caused by other packages or settings.

https://github.com/localauthor/org-side-tree/assets/90975914/a39824bb-ac11-42ae-b5ac-5c7ff77e6571

localauthor commented 5 months ago

The ellipsis stays there to indicate that there is some hidden text between that entry and the next heading. If you click on the heading "Eshell & Shell tweaaks with use of corfu", does the ellipsis stay there?

IceAsteroid commented 5 months ago

Sorry for long time not responding to this post, life's been really messy recently.

I used different fonts for headings and contents respectively, that might be what was confusing you.

You could see if I expanded the heading as shown in the video, the ellipsis was still there at the end of the content that was expanded for that heading. But it was displayed as by a different font that might look easy to neglect.

And when I expand a heading's content via org-side-tree, there will be an ellipsis there at the end of the content.

How to remove the ellipsis at the end of each content?

localauthor commented 5 months ago

Right, yes. The ellipsis is not there because of something that org-side-tree is doing. It is there because there is hidden text in the buffer. For example:

Screenshot 2024-02-07 at 10 42 19

In this shot, see how the line numbers go from 10 (at the ellipsis) to 30 (at the next headline). That means that lines 11-29 are hidden. That is what the ellipsis is there to tell you. This is a feature of org-mode and outline-(minor-)mode, not a feature of org-side-tree.

IceAsteroid commented 5 months ago

Sincerely sorry for this, really doubtful of my recent mental state, which made me neglect this apparent thing in testing the snippet that you posted.

Yes, it's indeed the case, which hid the same level headings & their contents.

Now, the question becomes, is it possible to make the same level headings which are under the same father heading, show up while being collapsed, and also to make the father heading's text content show up?

It's for the sake of providing better convenience to edit things across previous & next headings and their contents.

For example:

Like follows: Fully expanded of the first-level heading for all its content including sub-headings for demonstration of what it looks like originally. org-side-tree-expand-4 jpg

Example 1: Demo of what's intended to be for expanding a second-level heading: org-side-tree-expand-2 jpg

Example 2: Demo of what's intended to be for expanding a third-level heading: org-side-tree-expand-3 jpg

IceAsteroid commented 5 months ago

The above post was just for suggestion, there might be a better option

localauthor commented 5 months ago

I'm not sure how to generalize your suggestion enough to make it part of the the package, but you could always add advice to your own config, to open whichever headings you want after using org-side-tree-jump.

For example:


(defun my/org-side-tree-open-parent (_)
  (save-excursion
    (outline-up-heading 1)
    (outline-show-entry)))

(advice-add 'org-side-tree-jump :after 'my/org-side-tree-open-parent)```
IceAsteroid commented 5 months ago

I have implemented it as it's easy enough and not beyond my pour elisp skills

Here's the code:

  (defun my/org-side-tree-open-parent (_)
    (save-excursion
      (outline-hide-other))
    (save-excursion
      ;;to show all sub-headings & contents of the heading selected in
      ;;org-side-tree, after running "outline-hide-other", since it also
      ;;closes sub-headings
      (outline-show-children))
    (save-excursion
      (while (outline-up-heading 1)
    (outline-show-entry)
    (outline-show-children)))
    )
  (advice-add 'org-side-tree-jump :after 'my/org-side-tree-open-parent)

which shows the sibling headings but not their contents and also shows the father headings' contents respectively.

However, I'm afraid that the part, say part A

    (save-excursion
      (while (outline-up-heading 1)
    (outline-show-entry)
    (outline-show-children)))

will keep running endlessly in the background, since when the part, say part B

    (save-excursion
      ;;to show all sub-headings & contents of the heading selected in
      ;;org-side-tree, after run "outline-hide-other", since it also
      ;;closes sub-headings
      (outline-show-children))

was put after part A, it didn't take effect at all. And Emacs complaints in the echo area like "Already at top level of the outline".

Is there a better way to do this? Sorry for always asking for help :(

Here's what it does:

https://github.com/localauthor/org-side-tree/assets/90975914/a2a2ea1b-2cdc-4970-a3c5-a8df3353811e

IceAsteroid commented 4 months ago

I got ideas to solve it, I'll try them first, sorry for disturbing