Home Download Buy Blog Forum Support

Plugin Idea: Would This Be Useful?

Re: Plugin Idea: Would This Be Useful?

Postby sublimator on Sun Jan 08, 2012 12:25 pm

facelessuser wrote:Hope you get it :)


Cheers!

A layout splitting plugin is what I want it for. Messed around on one around xmas time but got `API stuck` :(
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: Plugin Idea: Would This Be Useful?

Postby sublimator on Sun Jan 08, 2012 12:29 pm

Currently when you set a layout from a 1+n size (in terms of cells) layout to a 2+n layout the views will just be placed in the cell via their index position in the cells array you pass to set_layout. It make more sense to regroup geometrically with more elaborate layouts (splits and merges)
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: Plugin Idea: Would This Be Useful?

Postby facelessuser on Sun Jan 08, 2012 3:46 pm

castles_made_of_sand wrote:A layout splitting plugin is what I want it for. Messed around on one around xmas time but got `API stuck` :(


Looks cool. I personally know a number of people who would love to see something like that.
facelessuser
 
Posts: 1575
Joined: Tue Apr 05, 2011 7:38 pm

Re: Plugin Idea: Would This Be Useful?

Postby facelessuser on Sun Jan 08, 2012 9:22 pm

Okay, reworked the code. I am now taking full use of the find_all command. This means you can do some more complicated substitutions. I went ahead and committed as an example the replacements requested on the opening page.

Code: Select all
{
   "replacements": {
      // Example replacements
      "html5_remove_deprecated_type_attr": {
            "find": "(<(style|script)[^>]*)\\stype=(\"|')text/(css|javascript)(\"|')([^>]*>)",
            "replace": "\\1\\6",
            "greedy": true,
            "case": false
      },
      "remove_html_comments": {
            "find": "<!--[\\s\\S]+?-->",
            "replace": "",
            "greedy": true,
            "case": true
      }
   }
}


To access the commands, you simply define a command in the command palette. I have provided an example, and you can chain the replacements.

Code: Select all
[
   {
      "caption": "Reg Replace: Example - Cleanup HTML",
      "command": "reg_replace",
      "args": {"replacements": ["html5_remove_deprecated_type_attr", "remove_html_comments"]}
   }
]


So the quick_panel is removed now.

Non-greedy searches are still limited to the first in the entire file. I plan on applying non-greedy changes from the cursor forward and allow wrapping, but not today.

As always, feedback, bug reports, and suggestions are appreciated.
facelessuser
 
Posts: 1575
Joined: Tue Apr 05, 2011 7:38 pm

Re: Plugin Idea: Would This Be Useful?

Postby C0D312 on Sun Jan 08, 2012 10:44 pm

For people looking for a link (like me :) ):https://github.com/facelessuser/RegReplace
C0D312
 
Posts: 1063
Joined: Sun Jul 10, 2011 3:23 am

Re: Plugin Idea: Would This Be Useful?

Postby sublimator on Sun Jan 08, 2012 11:16 pm

You could probably even put a scope selector restriction in.

I've always wished you could optionally pass a list of regions and/or a scope selector to the find_all api to further restrict the finds. If find_all returned regions in the ordering of the regions you passed it, eg (`[R(caret_pos, view.size()), R(0, caret_pos)]` seems like you could easily enough implement wrapped search that way. To restrict your search to a bunch of particular regions currently isn't as easy as it could be.

Some feedback of which regions were replaced would likely come in handy.
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: Plugin Idea: Would This Be Useful?

Postby facelessuser on Mon Jan 09, 2012 2:52 am

castles_made_of_sand wrote:You could probably even put a scope selector restriction in.

I've always wished you could optionally pass a list of regions and/or a scope selector to the find_all api to further restrict the finds. If find_all returned regions in the ordering of the regions you passed it, eg (`[R(caret_pos, view.size()), R(0, caret_pos)]` seems like you could easily enough implement wrapped search that way. To restrict your search to a bunch of particular regions currently isn't as easy as it could be.

Some feedback of which regions were replaced would likely come in handy.


The regions are returned in order and caret position is easy to calculate, so it is easy enough to at least filter the results. Not really worried about the calculating after the cursor, more just need to get around to it.

In what way would you use the scope selector? I am just curious in what context you would use this. I have no problem adding it, but I would like to better understand it so I can test the scenario.

C0D312 wrote:For people looking for a link (like me :) ):https://github.com/facelessuser/RegReplace

Added the link in an earlier post, but yeah, I probably need to open up a specific thread for this sometime soon.
facelessuser
 
Posts: 1575
Joined: Tue Apr 05, 2011 7:38 pm

Re: Plugin Idea: Would This Be Useful?

Postby sublimator on Mon Jan 09, 2012 10:02 am

>>> easy enough to at least filter the results

Yeah, it's just tedious. It's just such a common task that it'd be nicer (and likely a lot more efficient) if there was a more direct api for it. You'll probably end up implementing replace restricted to selections for example.

>>> In what way would you use the scope selector?

The scope selector would be used most commonly for restricting to, or filtering, string and comment scopes I'd imagine.
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: Plugin Idea: Would This Be Useful?

Postby facelessuser on Mon Jan 09, 2012 4:35 pm

castles_made_of_sand wrote:Yeah, it's just tedious. It's just such a common task that it'd be nicer (and likely a lot more efficient) if there was a more direct api for it. You'll probably end up implementing replace restricted to selections for example.


I agree.

castles_made_of_sand wrote:The scope selector would be used most commonly for restricting to, or filtering, string and comment scopes I'd imagine.


Ahh. That makes sense. I will add a simplistic filtering based on scope. Initially I will make it include or exclude filtering based on any part of the target exhibiting the scope; it will also be optional parameter that can be left out if not desired. If needed later, I can add options for "absolute filter" (meaning that the entire selection must be completely contained within the specified scope type). I am going to start out as simple as possible and only ramp it up to more complicated rule sets if it becomes needed. Even then, I will probably have to draw a line somewhere so I am not implementing some kind of regex for scopes. I surely see why you desire this feature now; I do hate it when a regex find targets inside comments and/or strings that I just don't care about.
facelessuser
 
Posts: 1575
Joined: Tue Apr 05, 2011 7:38 pm

Re: Plugin Idea: Would This Be Useful?

Postby facelessuser on Mon Jan 09, 2012 4:39 pm

So, as I get time, these are the current tasks on my plate:

-Feedback on replaced regions
-Non-greedy searches relative to the cursor
-Scope filtering of results

If you don't see a feature you really want, run it by me, and I will evaluate the request and possibly add it to my todo list.
facelessuser
 
Posts: 1575
Joined: Tue Apr 05, 2011 7:38 pm

PreviousNext

Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 3 guests