awth13 / org-appear

Toggle visibility of hidden Org mode element parts upon entering and leaving an element
MIT License
364 stars 19 forks source link

Feature request? Add support for hiding properties like #+title and #+author #22

Closed powerverwirrt closed 3 years ago

powerverwirrt commented 3 years ago

Hiya, thanks for this awesome little package! Makes my notes much tidier and nicer to look at!

I was wondering whether org-appear could support hiding/unhiding properties that are set at the beginning of the file, like #+TITLE and #+AUTHOR.

Since I don't know a lot of Elisp, I'm not sure if I could build this myself and open a PR... Are those properties accessible via the org-element API?

Kind regards Luke

awth13 commented 3 years ago

Hey, @powerverwirrt!

Thanks for your interest! There is an org-hidden-keywords custom variable that you can set to hide, e.g., the #+TITLE part of a property. If you do that, only the value of #+TITLE will be visible. I don't think that Org supports hiding both the keyword and its value.

From a brief experiment, Org hides the#+TITLE part using the same mechanism it uses to hide emphasis markers. Also, org-element can detect keywords in a document. This means that it should be possible to make org-appear unhide the #+TITLE part in a document where it is hidden (and hide it again once the cursor leaves).

If you want to add this functionality yourself, I suggest looking at commits by @SPFabGerman, e.g., this one. They added a bunch of new elements to org-appear and you can learn how to do this from their commits.

SPFabGerman commented 3 years ago

Huh, I didn't even know that org-mode had support for hiding keywords. You learn something new every day, I guess. So yeah I implemented a quick PR, that implements keyword-toggling and I think it already works decently well.

powerverwirrt commented 3 years ago

Thanks so much to both of you! It's amazing that you got back to me so quickly! I'll test the code and report back/close the issue. :+1:

awth13 commented 3 years ago

@SPFabGerman to the rescue :D

Huh, I didn't even know that org-mode had support for hiding keywords.

Me too. Thanks to @powerverwirrt for suggesting it!

powerverwirrt commented 3 years ago

Tested it yesterday and today and it works nicely! Thanks @SPFabGerman! This community is awesome. Should this stay open until the PR is merged?

awth13 commented 3 years ago

Thanks again, @powerverwirrt!

The issue has been closed automatically since the PR was marked as closing it.