Home Download Buy Blog Forum Support

Fold Away Lines Not Matching A Pattern

Re: Fold Away Lines Not Matching A Pattern

Postby jps on Wed Feb 27, 2013 11:09 pm

FWIW you can do ad-hoc folding without any plugins by selecting all the text of interest (e.g., via Find All), and then using the Edit/Code Folding menu. In S1 there was an invert_selection command, which would enable selecting all the non-matching bits of text, I'll have to add it back in for S3.
jps
Site Admin
 
Posts: 3062
Joined: Wed Mar 19, 2008 12:33 pm

Re: Fold Away Lines Not Matching A Pattern

Postby quodlibet on Sat Mar 02, 2013 11:01 pm

lmedinas wrote:Does it support multiple pattern or single matching ?


Not sure what you mean. It matches all lines based on one pattern (string, actually; I failed to rewrite this as a regex).

jps wrote:FWIW you can do ad-hoc folding without any plugins by selecting all the text of interest (e.g., via Find All), and then using the Edit/Code Folding menu. In S1 there was an invert_selection command, which would enable selecting all the non-matching bits of text, I'll have to add it back in for S3.


What I would like to do is to automate precisely this. I think the ideal command would be folding (as well as inverted folding) based on a regex. This is very useful for logfiles, todo lists and other files where lines are standalone. (Some kind of hook between Goto Symbol and this command would also be useful....)

Alex
quodlibet
 
Posts: 499
Joined: Sat Jun 18, 2011 5:53 pm

Re: Fold Away Lines Not Matching A Pattern

Postby sublimator on Tue Mar 05, 2013 3:40 am

quodlibet wrote: I think the ideal command would be folding (as well as inverted folding) based on a regex.

Image

I wrote a command back in the day for someone on the forum along them lines. The command would use folding to preview lines matching a pattern to filter from the document.

I'll see if I can dig up the code.
It is better to remain silent and be thought a fool, than to speak out and remove all doubt
sublimator
 
Posts: 649
Joined: Thu Mar 20, 2008 5:41 am

Re: Fold Away Lines Not Matching A Pattern

Postby quodlibet on Tue Mar 05, 2013 10:51 am

That looks interesting -- and more sophisticated (i.e., more moving parts) than what I described, but I'd have to use it to be sure -- please share your code if you can dig it up!

Incidentally, I see you have a TODO.txt file open. Do you use anything to parse it, or do you use a long static file that you just scroll through?

Alex
quodlibet
 
Posts: 499
Joined: Sat Jun 18, 2011 5:53 pm

Re: Fold Away Lines Not Matching A Pattern

Postby sublimator on Wed Mar 06, 2013 2:49 am

TODO.txt is just one big text file I've been using since 2009 or so

New entries go at the top of the file

Don't really use any special plugins

I always was annoyed that I hadn't gotten around to making it show the whole current function/class/node/etc of a match, rather than a simplistic 2 lines above/below

More so, when using a similar technique for debugging / writing tmLanguage files

I might just try writing it again because I can't find the code for that plugin
It is better to remain silent and be thought a fool, than to speak out and remove all doubt
sublimator
 
Posts: 649
Joined: Thu Mar 20, 2008 5:41 am

Re: Fold Away Lines Not Matching A Pattern

Postby quodlibet on Wed Mar 06, 2013 11:12 am

castles_made_of_sand wrote:I always was annoyed that I hadn't gotten around to making it show the whole current function/class/node/etc of a match, rather than a simplistic 2 lines above/below


Ah, I see. I thought it parsed the indentation or the scope, which would have been quite a bit more ambitious.

castles_made_of_sand wrote:I might just try writing it again because I can't find the code for that plugin


You're such a tease, I'm still waiting for those keybindings... :roll:
quodlibet
 
Posts: 499
Joined: Sat Jun 18, 2011 5:53 pm

Re: Fold Away Lines Not Matching A Pattern

Postby sublimator on Wed Mar 06, 2013 1:54 pm

Soz, busy as shit atm :)

My old man's coming to visit in me (overseas for him) and got an event need to have a new website up for.

Trying to smash it out so I can spend some time with him

FFFFFF. deadlines :/
It is better to remain silent and be thought a fool, than to speak out and remove all doubt
sublimator
 
Posts: 649
Joined: Thu Mar 20, 2008 5:41 am

Re: Fold Away Lines Not Matching A Pattern

Postby quodlibet on Wed Mar 06, 2013 2:21 pm

Pft! Excuses, excuses ;)
quodlibet
 
Posts: 499
Joined: Sat Jun 18, 2011 5:53 pm

Re: Fold Away Lines Not Matching A Pattern

Postby sublimator on Wed Mar 06, 2013 3:38 pm

quodlibet wrote:Pft! Excuses, excuses


FFFFF. Now you gone and called me on my BS.

Ok, you got me, it's trick screencast photography. It's not a real plugin.
It is better to remain silent and be thought a fool, than to speak out and remove all doubt
sublimator
 
Posts: 649
Joined: Thu Mar 20, 2008 5:41 am

Re: Fold Away Lines Not Matching A Pattern

Postby quodlibet on Sun Mar 24, 2013 5:48 pm

If anyone is playing along, I have a slightly improved version of this plugin here:
https://raw.github.com/alehandrof/MarkD ... Folding.py

It's part of a bigger mess called MarkDo that I will clean up and describe soonish*.

What it does

Trigger the plugin with a binding such as this:
Code: Select all
{ "keys": ["ctrl+'"], "command": "all_toggle", "args": { "foldstr": ""  } },


If there is nothing folded, it will fold all lines NOT matching (in order of preference):

1. the selection
2. the "foldstr" argument
3. user input

When there are folded sections, triggering the plugin will unfold everything. (It's a toggle, you see.)

Sorry for the very sloppy instructions :) Let me know if you need any help using this.

* One hopes.

Alex
quodlibet
 
Posts: 499
Joined: Sat Jun 18, 2011 5:53 pm

Previous

Return to Ideas and Feature Requests

Who is online

Users browsing this forum: No registered users and 8 guests