The way encoding of file work right now is really not optimal.
What I like:
- Having an API method or a setting to get the actual encoding of a buffer.
- Having the choice to change the encoding of a buffer, at anytime or at least at save time.
- Having an 'encoding' parameter to the open_file API command (and to the 'open' command, but maybe it already there, not tested)
And an idea that just come in my mind:
Create a new Buffer class that is the underlying buffer of a view. So it's a kind of invisible view.
A Buffer could be linked to zero or more view (clone).
The Buffer class implement most of the View class (substr, insert, erase, ...).
This new class could be used to open a file 'the ST2 way' (encoding, indenting settings (indent guess), ...) without showing it in the editor.
This could be used to replace all the open('filename') in the plugins when you need data from another file (Diff command, ...).