On 26.10.2007, at 16:33, Thomas Aylott wrote:
On Oct 26, 2007, at 10:15 AM, Hans-Jörg Bibiko wrote:
do saveWithFilename '{name=XXX;overwriteMode;}'
without reopen it AND if the current document is unsaved AND the current document is not a "untitled" document meaning it was already saved before?
Then it could be used like: "$TMTOOLS" do saveWithFilename '{name=$TM_FILEPATH;overwriteMode;}'
<further code>
Yeah, that sounds great. I guess I'd need to throw some logic in there for allowing them to saveas if it is untitled. What's the best way to do that? Or could you work that in there too? ;)
Well, saving is a very sensible task. Ok, I can do the following:
"$TMTOOLS" do saveCurrentDocument This command is the same command like APPLE+S. Fine, but if the document is 'untitled' then this command would invoke the NSSavePanel and TM will freeze.
To avoid this one could do to the following: RETURN=$("$TMTOOLS" do saveCurrentDocument '{avoidPanel;}') This would mean that if the current document is an 'untitled' document it will return '0' without showing the save panel AND without saving, otherwise it'll return '1'; and it is up to you what do you want to do.
An other approach would be: $TMTOOLS" do saveWithFilename '{name=XXX;overwriteMode;}'
This command would also save even an untitled document as XXX. Fine, but TM will not be informed about the saving (that's why I used saveWithFilenameAndReopen). It's possible to mark the current document as saved, and set the window title to XXX, but this would lead to some unstable side-effects, I guess.
Thus I would prefer the first approach. But as I mentioned above, saving is a very sensible issue!
--Hans