Anyone can help here?
Sorry if this has been asked before, I searched and didn't find anything related.
I have the habit of keeping several untitled windows open with bits of text or notes. Right now I have 3 untitled windows, all minimized in the Dock. If I open an arbitrary file, it will open it as a tab in one of these untitled windows. This includes files that belong to a project in a folder containing a .tm_properties file. I find this pretty annoying, because these files end up grouped with the untitled document that contains something totally unrelated. When I close the tab that opens, I have to minimize the untitled document again.
Is there a way to force Textmate to always open files in either a window corresponding to their project, or otherwise just a new window?
Thanks!
Quinn
I've been trying to solve my issue on my own (see original post at bottom). I found the "Creating Tabs" section of the TM2 manual [1], wherein it states:
“Files opened from outside TextMate will open as a new tab, if the file is a descendent of an existing window’s project folder, or if a project has been explicitly requested for the file being opened.”
The problem I'm experiencing is that opening a file from outside TM opens as a new tab inside an untitled, unsaved window, which is not one of the two conditions when it should open as a tab mentioned above.
I noticed something else: before opening file from outside TM, the untitled window has no title or project in its window title area (not even "Untitled"). After opening the file from outside TM, the title area of the window of the untitled window becomes "untitled 1 — src". In this case, "src" is the location of the file from outside TM that I opened (e.g., ~/src/this-should-open-in-its-own-window.txt). I understand this indicates that the untitled window was assigned the Project Folder of "src" after opening the file from outside TM, but previously, it didn't have a Project Folder assigned (or wasn't indicated in the window title area).
This behavior would be explained if untitled windows have a default Project Folder of ~/src/ (without showing this in the window's title area). If that's true, the question is: how to unset the Project Folder for untitled windows?
On the same section of the manual, it says:
“If you want to force mate to open a file in a new window, you can set an all-zero TM_PROJECT_UUID […]”
Indeed, doing so does force the file to open in its own window (when using `mate`):
TM_PROJECT_UUID=00000000-0000-0000-0000-000000000000 \ mate ~/src/this-should-open-in-its-own-window.txt
But I want this behavior when opening files by other means, e.g., `open`:
TM_PROJECT_UUID=00000000-0000-0000-0000-000000000000 \ open ~/src/this-should-open-in-its-own-window.txt
That command opens as a tab attached to an untitled window. :(
Thanks for reading so far.
Quinn
[1] https://macromates.com/textmate/manual/projects#creating-tabs
On 06 Feb 2021 20:06:39, Quinn Comendant wrote:
Anyone can help here?
Sorry if this has been asked before, I searched and didn't find anything related.
I have the habit of keeping several untitled windows open with bits of text or notes. Right now I have 3 untitled windows, all minimized in the Dock. If I open an arbitrary file, it will open it as a tab in one of these untitled windows. This includes files that belong to a project in a folder containing a .tm_properties file. I find this pretty annoying, because these files end up grouped with the untitled document that contains something totally unrelated. When I close the tab that opens, I have to minimize the untitled document again.
Is there a way to force Textmate to always open files in either a window corresponding to their project, or otherwise just a new window?
Thanks!
Quinn
On 7 Mar 2021, at 20:10, Quinn Comendant via TextMate wrote:
This behavior would be explained if untitled windows have a default Project Folder of ~/src/ (without showing this in the window's title area). If that's true, the question is: how to unset the Project Folder for untitled windows?
The default is the setting of Preferencs → Projects → File browser location.
So in your case, you should set this to a folder in which there are no files (even in sub-folders) that you would normally open with `mate`.
For me, when I open a new untitled window, it *does* show this location in the window title. Perhaps you have set `windowTitle` somewhere? You can check this with Bundles → Select Bundle Item… switch to Settings (⌘}) and then enter `windowTitle`.
As for why untitled windows have a default project folder: Internally there is no distinction, i.e. each window is a project, it can have the file browser shown or hidden, and it can have one or more tabs, either of them being “untitled”.
Though the behavior you experienced is unexpected, so I will reconsider if there should be exceptions.
Hi Allan,
Thanks for the help, I've made some progress:
On 12 Mar 2021 20:25:52, Allan Odgaard via TextMate wrote:
The default is the setting of Preferencs → Projects → File browser location.
Yes! That solved the problem with untitled windows (but not not all windows, see below). I set the default file browser location to ~/tmp/ and now opening random files now does not open in untitled windows.
For me, when I open a new untitled window, it does show this location in the window title. Perhaps you have set windowTitle somewhere?
Oh yes, indeed, I had set windowTitle = '$TM_FILEPATH' in my ~/.tm_properties file.
As for why untitled windows have a default project folder: Internally there is no distinction, i.e. each window is a project
That makes sense. Now that I've removed my custom windowTitle variable, I can see that untitled windows are using the project folder of ~/tmp/, as it is my default.
Though the behavior you experienced is unexpected, so I will reconsider if there should be exceptions.
Thanks, I think this is worth reconsidering because the expected behavior can still be bothersome: Although opening random files no longer creates tabs in untitled windows, they still do become tabs in open windows which have a file browser location set to an ancestor of the newly opened file. For example, I had my ~/.tm_properties file open (which has a file browser location of /Users/me/). Then I opened the file ~/src/projectX/randomfile and it opened as a tab attached to the ~/.tm_properties window. That is unexpected, because ~/src/projectX/ is a project with its own .tm_properties file; I would expect any files open from inside projectX to open in its own window, with a file browser location set to ~/src/projectX/.
Can we have a setting where opening a file always spawns a new window, unless a .tm_properties file exists in a directory ancestor to the location of the opened file (ignoring ~/.tm_properties because it is an ancestor to virtual all files)? That would solve this for me.
Thanks again! Quinn