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

Add a keyboard shortcut for folding completed tasks #29

Closed
mlms13 opened this issue Jun 25, 2015 · 14 comments
Closed

Add a keyboard shortcut for folding completed tasks #29

mlms13 opened this issue Jun 25, 2015 · 14 comments

Comments

@mlms13
Copy link

mlms13 commented Jun 25, 2015

I tend to break tasks down into very small, nested pieces, so I love the ability to fold groups of completed tasks. It would be handy if a keyboard shortcut would exist to make this process a little quicker. Atom has some shortcuts for folding, but these are indentation-level-specific. It would be neat if atom-tasks would add a shortcut to fold everywhere that the line starts with some amount of whitespace followed by a checkmark.

Thanks for the awesome plugin, by the way!

@irrationalistic
Copy link
Owner

Thanks!

So would it be a shortcut that you could hit on a line that would fold all nested (via indentation) lines below until one that is at the same level? Or are you thinking more globally?

@mlms13
Copy link
Author

mlms13 commented Jun 26, 2015

I was thinking more globally. Regardless of cursor position, you hit this shortcut and all completed tasks in the current file become folded.

@irrationalistic
Copy link
Owner

Only if they have child tasks? Just want to make sure I fully understand your goals!

@mlms13
Copy link
Author

mlms13 commented Jun 26, 2015

So here's the start of what I had in mind: mlms13@4f20cbe

The goal is just to find any (non-archived?) completed or cancelled task, and if it has sub-tasks (ie if it can be folded), fold it. Currently my code isn't particularly good because:

  • editor.foldBufferRow(lineNumber) will work its way to the top of the document until it finds something to fold, so my command ends up folding the entire document. 😞 Really, I need something like editor.foldBufferRowIfFoldable(lineNumber). As far as I can tell, Atom doesn't provide something like this (or even an easy way to check if a row is foldable), but I could probably make my own.
  • All of the logic for getting completed tasks is duplicated from taskArchive, so I'll turn that into a utility function that they can both use.
  • The keybinding is Mac-only and completely arbitrary at this point.

I'll probably keep poking around this evening. This is the first I've looked at the Atom API (or really coffeescript, for that matter), so feel free to give me pointers if you have them.

@irrationalistic
Copy link
Owner

That sounds like a good direction! I haven't had a chance to work through it myself, but you might check out the task completion part that reads up looking for all projects that the task is a part of. Reversing the logic slightly by seeking through from the top and finding all tasks with children. If all the children are complete you could select up to the bottom most child and fold that selection. Hopefully that helps a little!

@irrationalistic
Copy link
Owner

How's this going? I may take a crack at solving it as well!

@mlms13
Copy link
Author

mlms13 commented Jun 29, 2015

Don't let me hold you back if you're interested. :) I haven't looked at it much since Friday.

@irrationalistic
Copy link
Owner

Ok, no worries! I want to do some thinking/planning on it to make sure it makes sense, so I'll do that when I get a chance and keep you posted.

@mandel01
Copy link

mandel01 commented Aug 8, 2015

FYI on "Folding Text", which includes both folding and filtering. Code is there but it is not open source as he intends to charge for product in the future. It requires the HTML-based FTML format and not simply text files, so I suspect it has limited utility for a text based list, but I thought I'd pass it along in case it was useful.

http://www.foldingtext.com/foldingtext-for-atom/
http://jessegrosjean.gitbooks.io/foldingtext-for-atom-user-s-guide/content/appendix_b_file_format.html

@irrationalistic
Copy link
Owner

That looks pretty fancy! Seems that he would have had to build an entirely custom view (not using the normal text editor view). Not sure we'd need to do anything that drastic, my hopes are to hook into native atom code folding! But thanks for passing that along, very cool :)

@mandel01
Copy link

I agree that it's overkill. For ideas only...

@irrationalistic
Copy link
Owner

So I just looked back into this and I found that atom has built in commands for collapse and expand parent. It seems to work in my task files, so does this do what you need? Try going to a task in a project and using the hotkeys alt-cmd-[ and alt-cmd-].

If, however, you mean to only fold up the completed/cancelled tasks under a given project, that's a different story and wouldn't be doable in this current structure. I'd have to build my own editor renderer on top of atoms (which relates to a couple of the other issues currently being discussed). For now, you'll just have to take advantage of the task-archiver!

@mlms13
Copy link
Author

mlms13 commented Nov 5, 2015

Yeah my goal was to collapse only the completed/cancelled tasks. I looked into this as well a few months ago, and I wasn't able to find a good way to tell Atom to collapse arbitrary rows. I'm happy to close this and live with archiving, since it's probably not worth the effort with Atom's current folding API.

@mlms13 mlms13 closed this as completed Nov 5, 2015
@irrationalistic
Copy link
Owner

Thanks! I'm slowly exploring a re-write that replaces the text editor with a custom version that would allow us to do all sorts of fancy things, but is going to take a lot of work. We'll see how it goes!

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

No branches or pull requests

3 participants