6

When editing a html file (in an Emacs buffer in HTML mode), I often review the file in my default browser (Firefox) by C-c C-v (ie, running browse-url-of-buffer). But every time I run C-c C-v, Firefox opens the file in a new tab so that after making several revisions, there are several tabs for the same file. But what I want is that Firefox reloads the file in the same tab, which is exactly what Safari does. Is there a way to make Firefox behave the way I want? The Emacs customization group `browse-url' does not seem to have an item for this. Neither can I find any suitable item in Firefox preferences (under General/Tabs). (I run Emacs 24.4 in Mac Yosemite, Firefox is 40.0.3.)

KS Leung
  • 103
  • 4
  • Instead of a `new-tab` option (if that is what is being used), perhaps there is something like a *same*-tab option: https://lists.gnu.org/archive/html/bug-gnu-emacs/2012-03/msg00849.html Unfortunately, I don't use any of that stuff so I have no current set-up to test with -- but I would definitely look for a *same*-tab option as part of the command. My other idea, without knowing the slightest thing of what I am talking about, would be to eliminate the `new-tab` option to see if the default ends up being the *same*-tab without necessarily specifying the *same*-tab. – lawlist Sep 05 '15 at 05:06
  • Did you try: https://github.com/skeeto/impatient-mode? Also, I'd suggest using an HTTP server to test your code locally (due to weird security restrictions imposed on locally loaded files). A Python `BaseHTTPRequestHandler` is a nobrainer to write. – wvxvw Sep 05 '15 at 08:38
  • Thanks for your suggestions. Using a server (instead of using `browse-url-of-buffer' in Emacs) is a good alternative way to preview web pages, and it avoids the problem of multiple tabs I have had with Firefox. Even though two more key-strokes (comapared with the Emacs way) are required for each revising/viewing cycle, I am fine with that. Thanks also for mentioning the impatient-mode. I will look into that later. – KS Leung Sep 06 '15 at 01:52

1 Answers1

3

As far as I know the only solution is to adjust the settings in Firefox:

Enter about:config in your address bar, confirm and search for browser.link.open_newwindow.override.external and set it to 1.

After that it should work like you want.

clemera
  • 3,401
  • 13
  • 40
  • The suggestion works fine. Setting 'browser.link.open_newwindow.override.external' to '1' makes the browser use the current tab to load the page sent from Emacs. This solves the problem of Firefox opening a new tab each time I load the file from Emacs. The only concern is that the content in the current tab is replaced by the content sent from Emacs, so I have to be careful if I don't want losing whatever there is in the current tab. In this respect, Safari works exactly the way I want: load the page in a new tab if it hasn't been loaded, and reuse the tab if the page has already been loaded. – KS Leung Sep 06 '15 at 01:59