This allows the commit command line tool to open a window as “native”.
We use distributed objects for talking to TextMate and getting a response. For the response, we release the connection in the next iteration of the event loop and then gracefully exit the program. Though it’s not clear if this is enough time for distributed objects to reply the client (if not, an exception is thrown in the client about “connection disappeared while waiting for a reply”).
The standard doesn’t care which side the keyword is placed on, but placing it on the right makes it easier to read types.
E.g. reading “int const* const” from right to left we get “const pointer to const integer”.
Since Mercurial is not using a unique “path suffix” we need to handle this via the default properties (instead of in the grammar’s file type extension array).
This is mainly because the SOMAXCONN constant looks better (in the source) than some arbitrarily chosen number. The constant is presently defined as 128 so it doesn’t seem wasteful, and presumably the queue will only take up space if we are not actually responding to socket connections.
Previously if TextMate had expired, we would terminate, which would cause the current session state to be saved, and since it hadn’t yet been restored, we would write out empty session state (and overwrite the user’s previous session state).
This is a minor change of the behavior introduced in 18d9aa030, which made it default to the new --uuid mode when TM_DOCUMENT_UUID was set, and no files were given. This meant that commands (executed from TextMate) could not do something like:
echo foo|"$TM_MATE"
Since there is no way to know if data is actively being sent to mate, we check if the length of data read is zero, and treat that as “no data was sent to mate”, but in theory a command could pipe potential empty user data to mate, which would lead to the wrong behavior. A command that may do this, should unset the TM_DOCUMENT_UUID environment variable.
Instead we return one of the constants from sysexits.h — the problem with abort() is that, for users with the feature enabled, it will trigger a core dump. That is a bit extreme for somewhat expected problems (like empty input file).
If no files are specified, the -w flag is not used, and TM_DOCUMENT_UUID is set, then this argument defaults to the value of the TM_DOCUMENT_UUID environment value.