Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request]: how to narrow view to the subtree #35

Open
ghost opened this issue Dec 1, 2017 · 5 comments
Open

[Feature request]: how to narrow view to the subtree #35

ghost opened this issue Dec 1, 2017 · 5 comments
Labels

Comments

@ghost
Copy link

ghost commented Dec 1, 2017

  1. In the org-mode, is there any way to show contents of only the clicked entry (in the main window) by the narrow view (In org-mode itself, this can be down by org-narrow-to-subtree or C-x n s)? The narrow-view may help to focus on the clicked entry.

  2. Now, imenu-list afford imenu-list-after-jump-hook to make the headline of the entry at the center or top of the window, which can partly help to focus on the clicked entry. Here, I want it to be at the top, so I use the following setting. This setting need set recenter-positions. Is there any simple way to directly set headline (cussor) position just for imenu-list?

(setq imenu-list-after-jump-hook 'recenter-top-bottom)
(setq recenter-positions '(top middle bottom))
  1. Maybe Bugs: While all the entries are folded in the Ilist buffer, when I click one entry to see the content in the mainbuffer, all the folded entries in the Ilist buffer are unfolding immediately. How can I remove this effect? Take the file structures in the end for example.
    • In Ilist, we may show only level-1 sections ('section 1' and 'section2') by folding them;
    • Then I want to see the subsection list of 'section 1'. I click it , and get the list-show of subsection A and B. Of course now, the subsections of section 2 is still folded.
    • However, if I want to check the content of 'subsection A' by clicking it, I find beside the content of 'subsection A' is shown in the main window, the 'section 2' in Ilist window is also unfolded - I can not see subsection C and D.
* section 1
** subsection A
** subsection B
* section 2
** subsection C
** subsection D
@ghost
Copy link
Author

ghost commented Dec 2, 2017

After some research,
Prob. 1 can be easy solved. To get narrow view, Just use (setq imenu-list-after-jump-hook 'org-narrow-to-subtree);
Prob. 2 is no more necessary while Prob. 1 is solved.
Prob 3. is still unsolved. However, I have more details:

  1. <RET> (or imenu-list-goto-entry) is good to show subsections. While want use it to the last step to see content of subsections, it unfold everything!
  2. <SPC> (or imenu-list-display-entry) can well finish the last step work - to show the content without affect the Ilist menu. However, it can not be used for the low level headlines like 'section 1' in above example. It will give errors as follows

Invalid function: (#("subsection A" 0 7 (org-imenu-marker #<marker at 357 in test.org> org-imenu t)) . #<marker at 357 in test.org>)

So, is there any way to combine this two functions?

@bmag
Copy link
Owner

bmag commented Dec 2, 2017

Is there any simple way to directly set headline (cussor) position just for imenu-list?

Regarding Prob. 2 you could have done this:

(setq imenu-list-after-jump-hook nil)
(add-hook 'imenu-list-after-jump-hook (lambda () (recenter 0)))

Invalid function: (#("subsection A" 0 7 (org-imenu-marker #<marker at 357 in test.org> org-imenu t)) . #<marker at 357 in test.org>)

That's indeed a bug. Imenu doesn't support jumping to non-low-level nodes. RET works because it calls push-button when point is on such nodes. When calling imenu-list-display-entry, it tries to jump to the header with imenu, but because imenu doesn't support this it throws the error above. One solution is to do nothing when imenu-list-display-entry is invoked on headers - it will eliminate the error, but won't change anything else. Another solution is to invoke imenu on the first low-level node under the header when imenu-list-display-entry is invoked on a header - I think this is what you wanted. I think it's doable but will need to research.

Prob. 3 happens because of how imenu-list updates the index buffer. When the index of the main buffer changed, it just rewrites the index entirely. No information about folds is retained and that's why everything unfolds. I need to research how to fix this, but I don't know when I'll have the time to do so.

However, in your case you don't change the contents of the main buffer, so I don't know why imenu-list decides to update the index buffer. This might be another bug. Does it happen only for org-mode buffers?

@bmag bmag added the bug label Dec 2, 2017
@bmag
Copy link
Owner

bmag commented Dec 2, 2017

@phyliu79 new branch named outline should fix this problem:

Invalid function: (#("subsection A" 0 7 (org-imenu-marker #<marker at 357 in test.org> org-imenu t)) . #<marker at 357 in test.org>)

Relevant commits are f188f06 and 42f983d. Can you verify that this problem is fixed, and doesn't cause other issues? (Prob. 3 not fixed yet)

@ghost
Copy link
Author

ghost commented Dec 3, 2017

Hi, I re-checked *.org *.tex and *.el:

  1. the headlines of *.tex can never be folded. So We don't have Prob.3 above;
  2. *.el afford variable and Types headlines group. However, the functions are not summoned as a group. Whatever, Prob.3 does not exist for *.el.
  3. Seems that the Prob only exist for *.org.

I also try the new branches. I found your corresponding to both f188f06 and 42f983d are included into one file. I download it from the outline branch. I get the follow result:

  • Still no problem with *.tex, *.el;
  • Prob.3 is not solved for org-mode- The invalid function problem of <SPC> still exists; The expand all list still exists. Also, the problem of 42f983d still exists. <RET> can not get the content of the headlines in the main window, instead it fold/unfold the menu list.

However, there are no more issues. At least outline mode is as good as the original one.

There are some clues about expanding: The cursor of go-to jump to the main window, even I set (setq imenu-list-focus-after-activation t). While the cursor occurs in the main window, every thing of the menu expanded.

@bmag
Copy link
Owner

bmag commented Dec 11, 2017

@phyliu79 thanks for testing, I was 99% percent sure that it would fix the invalid function bug, so it's weird it didn't work for you. I'm going to merge the outline branch soon, despite that.

I know why the expansion happens, it's just that implementing the fix isn't obvious. As I wrote, I don't know when I'll have time to fix it, sadly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant