6

Hi I'm heavily using the feature C-c C-o in org mode to open the links in org mode in my firefox. I have org lists with these links and I want to open a bunch of them and then go through this websites in the end. Currently after opening the links the focus switches to the browser tab and I need to go back to emacs myself. Is there a way to tell emacs not to switch focus to the opened browser tab?

1

I think this is determined by firefox itself and can't be easily fixed by Emacs.

Firefox-side solution

In about:config, toggle browser.tabs.loadDivertedInBackground from false to true.

See also this stackoverflow question

Outline of possible (ugly) alternatives

  1. Tweak your window-manager to make Emacs reclaim focus.

  2. In Emacs, define two new functions (and corresponding keybindings) that will i) add URLs to a queue, and ii) open all the queued URLs in Firefox. This would have the disadvantage of making the process more complicated, so I don't really recommend it.

  3. Write a Firefox webextension that will communicate with Emacs via "Native messaging" and open the tabs in the background. (I think, but I'm not 100 % sure, that it would work — experimenting with the browser console, placing it in a different workspace to Firefox and executing browser.tabs.create({}) does not bring focus back to Firefox.)

  • 1
    I tried the firefox-side solution, the behaviour is not exactly what I want. The switch leads to the tab not coming to the foreground but firefox itself still does. So I still have to switch focus. The other solutions appear a little more complex to me as I'm not experienced in the proposed fields, but it sounds promising. I will put it my todo list ;) – daeda Mar 5 '18 at 19:47
  • Regarding the Firefox solution, that's weird — I had tested it (and just tested it again) and, in my case (Linux with XMonad), neither Firefox nor the tab came to the foreground, but it probably depends precisely on the details of the system. – aplaice Mar 5 '18 at 23:23
  • 1
    Another idea is to use xdotool. It has the ability to bring windows in to focus. – izkon Oct 28 '18 at 7:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.