Firefox: Better Tab Reuse for IDE Help Integration

Suppose you have written a plug-in for your IDE, in which you press F1 and it will open the help utility page for the current function/method in your favorite browser, Firefox. What tab do you want that page to be openned with? A new tab? The current tab?

These are the options firefox provides you out of the box (actually you need tweek about:config to get the open-in-current-tab feature. See Firefox: -new-tab or no -new-tab). But neither is satisfactory if applied blindly. With a new tab each time, you end up with too many; with the current tab, you may ``overload'' a tab visiting reddit/slashdot in which you are composing a very funny story/reply. You don't want that happen, right?

I longed for a way to look if there's an old tab already visiting a help page for the IDE, if yes, open the new help page in that tab, if not, then open in a new tab. For e.g., I want to check python's subprocess.Popen, I could check if there's any tab visiting a URL that matches the regexp*, if yes, I should reuse that tab instead of the current tab (which is visiting reddit, of course) or a blind-brand-new tab.

In Firefox: -new-tab or no -new-tab I put forward a method to make firefox try very hard to open a utility webpage in a new tab only if the current tab is not visiting the same utility.

Now I took one step further (after practicing more with the idea in Simple scripts to record/play keyboard macro (sawfish)), if any tab is visiting the same utility (with a regexp matching), firefox will try to open the URL in that tab.

The scripts are straightforward, just switch all the tabs around with C-f (I'm using Firemacs and this key binds to NextTab), then check the URL it's visiting, if it matches the utility's URL regexp, then we use that tab. Only if we can't find such a tab do we use a new one.

The scripts are located at my-dict (the utility, not for IDE, but for my English dictionary), firefox-search-for-tab and get-firefox-tab-url. Oh, and another script is sawfish-send-window-event.