Here’s a summary of all the noteworthy stuff that has come up so far. You may 
still want to read the other email chain for more depth.

I would like a plugin that automatically updates NetBeans’ indentation settings 
when a file is opened for editing, based on the existing indentation in the 
file. I’m willing to pay for this! The plugin does not have to do any indenting 
itself (in fact, it should not). It just needs to update NetBeans’ indentation 
settings based on the file’s contents.

    creating the plugin: $100
    adding status to the status bar: $50
    donating it and getting it accepted into NetBeans itself: $100


-operation-

When a file is made active for editing (it is opened, reloaded, or switched 
to), the plugin should examine the contents of the file to figure out what the 
appropriate indentation settings should be. The plugin should then dynamically 
update NetBeans’ indentation settings once it figures out the new settings. The 
settings it should try to detect are listed below. Detecting any other settings 
or doing anything else is beyond the scope of this plugin request:
expand tabs to spaces
spaces per indent
continuation indentation
label indentation
absolute label indentation

If the plugin can’t figure out any indentation settings from the contents of 
the file, it should make a reasonable guess based on the settings it can figure 
out and NetBeans’ current preferences. For example:

package foo;
public class Bar {
        public int wazoo;
}

For the code above, there is enough Information to know that the standard 
indentation is 1 tab, but you don’t have enough information to know what the 
label indentation or continuation indentation should be. The plugin would need 
to use what it does know and the NetBeans prefs to "figure out" sensible values 
for these.

While not rocket science, this isn’t entirely straightforward because you can’t 
just copy the NetBeans prefs. Continuing the example above, if NetBeans 
specifies that the standard indentation is 2 spaces and the continuation 
indentation is also 2 spaces, you can figure out that the continuation 
indentation for this file should be one tab. If in NetBeans the continuation 
indentation was 4 spaces (twice the standard indentation), the continuation 
indentation for this file should be 2 tabs. 

If the file has inconsistent indentation, the plugin should just pick 
one—preferably (but not required) the most common indentation. Bonus points for 
detecting the inconsistency and letting the user know (see the status bar stuff 
below).


-status bar-

Another bonus of $50 for showing the status of the plugin in the status bar, 
for example:
the plugin successfully detected the indentation settings
the plugin successfully detected at least the big two settings (expand tabs and 
spaces per indent), and guessed at one or more of the remaining settings
the indentation of the file is inconsistent; the plugin picked one
the plugin just used the current NetBeans indentation settings (for example the 
file is empty and has no indentation yet)


-summary-

I haven’t looked at the code, but I assume NetBeans has an event for when a 
file is activated for editing (that is, the file is opened or switched to). I 
imagine that this plugin could just listen for that event, and in the handler:
look at the existing code to figure out what the indentation rules should be
override NetBeans’ own preferences to those new values

The plugin can optionally provide feedback in the status bar, for bonus bucks.


Good luck!

Reply via email to