Home Download Buy Blog Forum Support

FileDiff plugin, and an etiquette question.

FileDiff plugin, and an etiquette question.

Postby colinta on Mon Jan 23, 2012 4:41 pm

I'm announcing my plugins in order of their popularity on Package Control. #1 spot goes to zenburn, which I'm glad to see. #2 is FileDiffs. This is not surprising, because I think it offers many of the TextMate "diff" commands, but with the ST2 spin.

Image
Image

The commands it provides are:

  • Diff file with Clipboard
  • Diff Selections
  • Diff file with Saved
  • Diff file with File in Project…
  • Diff file with Open Tab…

If you have selected some text, "Diff file" changes to "Diff selection". "Diff selections" is only available when there are exactly two selections in the current view. "Diff file with Open Tab" will show a picker for the open tabs (unless there are just two open, it will just pick the other tab). Diff file with File in Project uses the fuzzy finder.

The diff is calculated using python's difflib library, using the unified_diff command. I had some headaches getting unicode to diff correctly, so bear with me if your files aren't decoding correctly. AFAIK, it only supports UTF8. If you need to diff two files with different encodings, try using "Diff file with Open Tab". It uses sublime text to fetch the content, so it should deal with the encoding transparently.

Next, my question about etiquette. In writing plugins, my first audience (me!) gets special consideration. I add key mappings that are intuitive to me, and add them to a Defaults (OSX).sublime-keymap file. I also create Windows and Linux versions, just for consistency. The keymap file for FileDiff looks like this:

Code: Select all
[
  { "keys": ["ctrl+shift+d"], "command": "file_diff_menu" }
]


When I publish these plugins, I have very mixed feelings about including these keymap files. What I like is that these files show the commands and options the package provides. What I don't like is that hit all users will agree with my keymappings.

Is there a standard in place for including or excluding keymap files? Or what to name example files?
colinta
 
Posts: 14
Joined: Wed Dec 21, 2011 9:43 pm

Re: FileDiff plugin, and an etiquette question.

Postby bizoo on Tue Jan 24, 2012 8:05 am

colinta wrote:Is there a standard in place for including or excluding keymap files? Or what to name example files?

As I already said in an issue on github,your keybinding hide the standard keybinding for duplicate_line in Windows and Linux.
It's not the first time I hit this issue with installed plugins.

Not including a default keybindings file could be a solution, however if an update of a plugin add new functionality with new keybindings, there a great chance that user completely miss it. And users need some work to update manually their user keybinding files. Quite difficult to manage when you have dozen plugins installed.

The problem is that when a plugin define a keybinding that hide another one, you have only 2 choice:
-Delete the keybinding from the plugin -> update of plugin set it again.
-Redefine the keybinding in the user folder.

None of these solutions look great and they add useless complexity to the management of plugins.

Actually, I prefer the keybinding not included in the plugin, only as example in the readme. But I suppose basic users will not be happy with this solution.

Maybe there is something to do with the Package Control plugin:
Add the keybindings in a special file that is used by Package Control to create or update a user keybindings file. And if the keybinding already exists and is commented, don't do anything.
bizoo
 
Posts: 879
Joined: Wed Dec 08, 2010 6:53 am
Location: Switzerland

Re: FileDiff plugin, and an etiquette question.

Postby jps on Tue Jan 24, 2012 8:21 am

I think your best bet is to include the diff commands on the Command Palette (via a .sublime-commands file, see Packages/Default/Default.sublime-commands for an example), that way you won't need to add any key bindings for it.
jps
Site Admin
 
Posts: 3067
Joined: Wed Mar 19, 2008 12:33 pm

Re: FileDiff plugin, and an etiquette question.

Postby bizoo on Tue Jan 24, 2012 8:38 am

jps wrote:I think your best bet is to include the diff commands on the Command Palette (via a .sublime-commands file, see Packages/Default/Default.sublime-commands for an example), that way you won't need to add any key bindings for it.

Yes, this plugin has already a sublime-commands file.

But for some plugins (actually probably not this one), it doesn't make sense to not have keybindings.
Do you think it could be possible for ST2 to generate a report of all keybindings (even hidden ones) in a standardized form ?
Something like:
keybinding,context,command

This way it would be easy to find conflicts, and it could be useful to make some kind of auto generated keybindings list.
bizoo
 
Posts: 879
Joined: Wed Dec 08, 2010 6:53 am
Location: Switzerland

Re: FileDiff plugin, and an etiquette question.

Postby sublimator on Tue Jan 24, 2012 9:18 am

Maybe there is something to do with the Package Control plugin


If bindings had unique identifiers it would go along way to solving a lot of the pain points. Disable/Override via uuid etc. Disable is an achilles heel of the current system for alt+gr users.

Jon's been back and forth on a GUI for configuration. The current system is relatively useable and you wouldn't want to add much more implementation complexity to it without simplifying the interface somehow.

I'm wondering if it'd be possible to do something with a scratch buffer/add_regions/Region.(meta|xpos)/folding interface?

Do you think it could be possible for ST2 to generate a report of all keybindings (even hidden ones) in a standardized form ?


Doesn't have hidden ones but:
Image

Image

I've got a plugin but it uses helper libs ported from ST1 that aren't cross platform, not to mention that Sublime doesn't have site-packages support. I plan on sharing it when I got the time to deal with those issues ...
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: FileDiff plugin, and an etiquette question.

Postby bizoo on Tue Jan 24, 2012 10:10 am

castles_made_of_sand wrote:If bindings had unique identifiers it would go along way to solving a lot of the pain points. Disable/Override via uuid etc. Disable is an achilles heel of the current system for alt+gr users.

Jon's been back and forth on a GUI for configuration. The current system is relatively useable and you wouldn't want to add much more implementation complexity to it without simplifying the interface somehow.

Having an unique ID for each keybinding could possibly the best solution, but like you say add complexity to the configuration.
Maybe the unique ID could be calculated with "relative path to the plugin folder"+"keybinding filename"+"complete keybinding":
Ex:
"Default" + "Default (Windows).sublime-keymap" + "{ "keys": ["f2"], "command": "next_bookmark" }"

It doesn't be as flexible as an UID, because you couldn't modify the keybinding or move it to another file without actually create a new UID, but this way you could disable (skip) a specific keybinding.
castles_made_of_sand wrote:I'm wondering if it'd be possible to do something with a scratch buffer/add_regions/Region.(meta|xpos)/folding interface?

Do you mean folding unique IDs in the sublime-keymap json and possibly generate it automatically to hide them from user view ?
castles_made_of_sand wrote:Doesn't have hidden ones but:
Image
I've got a plugin but it uses helper libs ported from ST1 that aren't cross platform, not to mention that Sublime doesn't have site-packages support. I plan on sharing it when I got the time to deal with those issues ...

Look great !!! If hidden ones could be shown, it will make me cry :D
bizoo
 
Posts: 879
Joined: Wed Dec 08, 2010 6:53 am
Location: Switzerland

Re: FileDiff plugin, and an etiquette question.

Postby sublimator on Tue Jan 24, 2012 10:36 am

bizoo wrote:Do you mean folding unique IDs in the sublime-keymap json and possibly generate it automatically to hide them from user view ?


Hiding them yes. Folding them, no. Will get back to you on the details. I had some notes/code from ST1 but I think I may have lost em all in a hard drive crash last year. If sublime was able to report modified regions in the on_modified callback and set specific regions as readonly then there's all sorts of robust view based interfaces you could create, quite easily.

Still, things don't need to be foolproof to be useful. People don't throw their hands up and say "It's hopeless" because you *can* cut off your hand with a power saw. There's always validation if prevention isn't possible to implement. However, there's usually a way if you look long enough.

this way you could disable (skip) a specific keybinding.


Another option would be to just copy/paste some binding to User and any binding, anywhere in the stack below, that matches (bar the "disable" key) would be disabled?

But as well as disabling theres also the issue of inter package conflicts caused by Default/A-Z/User collation of bindings.

Anyway, I really should be doing something else atm :) A.D.D!
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: FileDiff plugin, and an etiquette question.

Postby svenax on Tue Jan 24, 2012 11:14 pm

castles_made_of_sand wrote:I've got a plugin but it uses helper libs ported from ST1 that aren't cross platform, not to mention that Sublime doesn't have site-packages support. I plan on sharing it when I got the time to deal with those issues ...

Ooh! That plugin would be so useful!

On another note, I really like the way TextMate handles this problem, by displaying a pop-up menu with all the commands if multiple commands use the same key binding. Not only does that make it easy for the user to see what's going on and select the correct command, it also simplifies for plug-in developers since you can select logical shortcuts without having to worry about clashes. So, for instance, all plug-ins that provide a Help command can bind it to shift+ctrl+h and the editor will do "the right thing" when that key combination is pressed.
svenax
 
Posts: 150
Joined: Tue Dec 20, 2011 12:47 pm

Re: FileDiff plugin, and an etiquette question.

Postby tanepiper on Wed Jan 25, 2012 12:16 am

In my plugin, I added a double key press for items, for example Ctrl + Shift + t, Ctrl + Shift + l for listing todo's - there is less noise in that space, although I suspect it will fill up quickly. Maybe if sublime keymappings had some kind of include system where you could could request the default key settings or blacklist items
tanepiper
 
Posts: 68
Joined: Sun Nov 06, 2011 6:40 am

Re: FileDiff plugin, and an etiquette question.

Postby sublimator on Wed Jan 25, 2012 12:52 am

svenax wrote:I really like the way TextMate handles this problem


There's definitely merit to that huh. However, there's some properties of having a stack and taking the first matching binding as Sublime does that would be nice to maintain and I suspect crucial even for things like Vintage.

Maybe some bindings could have some metadata attached that meant `continue and collate` like TextMate? Maybe that would be a good default even and instead you'd attach some metadata to indicate searching should stop if that binding matched. You'd have to have a think about a sensible default I guess.

I'm guessing Jon won't be relooking at this stuff until ST3.
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

Next

Return to Plugin Announcements

Who is online

Users browsing this forum: No registered users and 10 guests