We need this in a few places and while calling Gestalt() isn’t that much code, that function is deprecated in 10.8 and the alternative is a lot more code, so we don’t want to repeat that once we update the code.
This is for attr.project.XXX and attr.scm.XXX, although the latter is also provided by scm::info_t.
With this commit, the file::path_attributes function no longer collect this information.
We didn’t actually use the file itself, only its parent directory, and there are several places we want SCM info for an untitled file’s project directory, so removing the need for a file simplifies things.
There is also a new document_t::encoding_for_save_as_path which returns the encoding that would be used for the document, if saved at the given path. If the document was loaded from disk, it will return the encoding used during load, otherwise it will check tmProperties for which encoding should be used for the path provided. Save dialog for untitled documents will be pre-populated with the result of the above function.
The main reason to avoid this is to give a more predictable API. Encoding should be read (from tmProperties) prior to calling file::save and then given as argument.
This includes a minor improvement to handling of virtual paths (i.e. files opened via rmate).
It also slightly changes the logic related to finding file type. It now prefers an explicit user binding (only when there is a path) falling back on content match, then path match via grammar, then user binding for untitled files, and finally user binding for unrecognized files.