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

tab cycling inserts tab itself #1

Closed
basaran opened this issue Sep 5, 2020 · 9 comments
Closed

tab cycling inserts tab itself #1

basaran opened this issue Sep 5, 2020 · 9 comments
Labels
bug Something isn't working need details More information is required

Comments

@basaran
Copy link

basaran commented Sep 5, 2020

Hello,

This could be related to my config but when in a heading, at the beginning of line, if you hit tab, it sometimes renders a TAB instead of changing visibility.

image

and if you are not in the beginning but within a string, it will always insert a tab:

image

@integral-dw
Copy link
Contributor

integral-dw commented Sep 5, 2020

Hello @basaran, I couldn't reproduce your issue. I would recommend to try and reproduce it starting from emacs -q.
My setup was emacs -q -l org-starless.el. Opening an org file and manually starting the mode with M-x org-starless-mode I could TAB-cycle perfectly fine.

@TonCherAmi TonCherAmi added bug Something isn't working need details More information is required labels Sep 8, 2020
@marlinstrub
Copy link

Such a simple but neat idea! I can confirm the behaviour reported by @basaran with emacs -q -l org-starless.el with Emacs v26.3 and my current build (v28.0.5) on macOS.

In the following test file

* Heading 1
** Heading 2
*** Heading 3

after M-x org-starless-mode, I can cycle on heading 1 just fine but on headings 2 and 3 pressing tab inserts a tab instead of cycling.

@integral-dw
Copy link
Contributor

integral-dw commented Sep 10, 2020

Thanks, @marlinstrub! I managed to reproduce the bug given your specifications.
I find this actually quite interesting, since my own package uses some similar code.. I am currently cannibalizing my own mode to see if I can pinpoint the issue.
Edit: I noticed something peculiar: the bug only appears when the very last star is hidden. Until then no issue occurs. This means that the issue is rooted in org-cycle itself. It's a pretty big piece of code, but given I managed to reproduce this issue with an independent piece of code doing the same thing a bit differently there is no way around dissecting org-cycle I'm afraid, or asking the Org mailing list for help. My personal recommendation would be to try and mess with that function to try and track down what causes the problem before it becomes clear whether that is a bug or feature of cycle.

@marlinstrub
Copy link

Thanks for taking the time to look into it @integral-dw! I like the starless look a lot and will play around with org-cycle a bit to try and figure out what's really going on there. Given your comment about the bug only appearing when the last star is hidden, I think I'll also want to look at how org implements handling the org-hide-leading-stars option.

@marlinstrub
Copy link

I looked into this a bit and found that org-cycle uses move-beginning-of-line in combination with a regexp to detect headings. The problem is that move-beginning-of-line explicitly ignores invisible text which means that the regexp can fail to detect headings when the stars are hidden. Changing move-beginning-of-line to beginning-of-line solves the issue as far as I can tell (it'd be great if someone could confirm).

I'm not sure if this negatively affects some other usecase of org-cycle, but it doesn't affect the success of org's tests and I asked the mailing list if the attached patch could be applied. I can update here if you want.

org-cycle_with_org-starless-mode.txt

@basaran
Copy link
Author

basaran commented Sep 11, 2020

and that did work 👍
Thank you very much for your time.

@marlinstrub
Copy link

Sure thing, I wanted to get it working myself. The patch has just been accepted, so no need to keep it around. I think this issue can be closed @TonCherAmi 👍

@TonCherAmi
Copy link
Owner

@marlinstrub awesome work!

@marlinstrub
Copy link

Glad to contribute!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working need details More information is required
Projects
None yet
Development

No branches or pull requests

4 participants