1

I'm trying to customize WWW url browsing in one specific mode.

Looking at the documentation for browse-url led me to believe this could be achieved as follows with browse-url-browser-function:

(defun flooose-elfeed-browse-url (url &rest c)
  (interactive)
  (let ((tmp-dir (make-temp-file (buffer-name) t)))
    (message (format "Using %s for ephemeral firefox profile" tmp-dir))
    (setq browse-url-firefox-arguments `("--profile" ,tmp-dir))
    (browse-url-firefox url c)))

(add-hook 'elfeed-show-mode-hook
          (lambda ()
            (message "setting elfeed locals")
            (make-local-variable 'browse-url-browser-function)
            (setq browse-url-browser-function 'flooose-elfeed-browse-url)))

While this sort of works, the problem is that the newly created firefox window doesn't get focus, instead I get a notification from my desktop environment about the new window.

Using browse-url directly doesn't have this effect, the url is opened in a new tab in the default profile of my firefox and firefox gains focus.

I use browse-url-firefox because leaving browse-url-browser-function at it's default (browse-url-default-browser) leaves my browse-url-firefox-arguments ignored.

I also didn't see any options in the firefox cli documentation.

flooose
  • 511
  • 6
  • 14
  • I could be wrong, but I'm not sure you can do anything from the Emacs side. That behavior changed for me with firefox some time ago: I now get the same thing you get, i.e. the URL is opened in firefox but firefox does not gain focus. OTOH, if I change just the browser function to the `chrome` one, the link opens in chrome and chrome *does* get focus. So it seems to me to be a change in firefox behavior. – NickD Jul 24 '23 at 18:56
  • "some time ago"? So you remember it behaving correctly? If you remember approximately when, I might consider a `git bisect` in both repos :) – flooose Jul 24 '23 at 21:57
  • I do remember it, but it's been a while: maybe three months or so but I could be a month off either way: these things blur with time :-) My firefox is version 114.0 (on Fedora 38) currently, but I don't know what it was when it was doing the focus gain correctly. – NickD Jul 25 '23 at 00:58
  • Ok, thanks for the info. I'll go digging around. – flooose Jul 25 '23 at 14:37

0 Answers0