alphapapa / org-sidebar

A helpful sidebar for Org mode
GNU General Public License v3.0
527 stars 16 forks source link

highlight current org-level #12

Open bibekpokharel opened 4 years ago

bibekpokharel commented 4 years ago

It would be great UX wise if there was a way to do the following: The heading you currently are in your document is highlighted in the tree. This is similar to your org-now package but would be embedded onto this package. This use case is not for everyone so it would probably be an option that can be toggled.

On a related note, is there a way to jump from the current heading in an org-document to its counterpart in the tree? I could not quite figure out how.

bibekpokharel commented 4 years ago

Here is some code that might be helpful https://stackoverflow.com/questions/12890193/how-to-highlight-current-subtree-in-emacs-org-mode

alphapapa commented 4 years ago

It would be great UX wise if there was a way to do the following: The heading you currently are in your document is highlighted in the tree.

That's an interesting idea. It could be done with a minor mode in the source buffer that applies an overlay to the heading in the tree buffer using a function in the source buffer's post-command-hook. It wouldn't be too difficult.

On a related note, is there a way to jump from the current heading in an org-document to its counterpart in the tree? I could not quite figure out how.

There's no existing code to do that, but it could be done fairly easily by writing a command to do so.

By the way:

This is similar to your org-now package but would be embedded onto this package.

That's not what org-now does. Maybe you're thinking of org-sticky-header.

shaund commented 3 years ago

It would be great UX wise if there was a way to do the following: The heading you currently are in your document is highlighted in the tree.

That's an interesting idea. It could be done with a minor mode in the source buffer that applies an overlay to the heading in the tree buffer using a function in the source buffer's post-command-hook. It wouldn't be too difficult.

On a related note, is there a way to jump from the current heading in an org-document to its counterpart in the tree? I could not quite figure out how.

There's no existing code to do that, but it could be done fairly easily by writing a command to do so.

I'm not that familiar with elisp. Any more detailed direction on how I could implement these?

For jumping, would I use org-sidebar-tree-jump-source as a starting point?

For highlighting, org-element-at-point returns something like (paragraph (:begin 1959 :end 1965 :contents-begin 1959 :contents-end 1965 :post-blank 0 :post-affiliated 1959 ...)), but I'm not sure how to use that to highlight the heading in the tree buffer.

alphapapa commented 3 years ago

@shaund All the code needs to do is get (point) in the document buffer, change to the tree-view buffer (actually, its window), and go to the same position in it. Were I to give more details, I would have written the code myself. :)