* Making browse-url-firefox more robust?
@ 2022-02-04 22:51 Tim Landscheidt
2022-02-05 1:41 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-04-06 0:50 ` Felix Dietrich
0 siblings, 2 replies; 4+ messages in thread
From: Tim Landscheidt @ 2022-02-04 22:51 UTC (permalink / raw)
To: help-gnu-emacs
Hi,
I have set browse-url-browser-function to
'browse-url-firefox (and browse-url-firefox-arguments to
'("-P" "default")) and it works reasonably fine: I see a
link in Gnus or elsewhere in Emacs, I click on it, the link
opens in a new tab in Firefox.
Where it becomes a nuisance is when I don't need to open one
link, but many, for example generated by some database query
or generator function:
| (dotimes (i 100)
| (browse-url (format "https://some.url/%d" i)))
In this case, each call to browse-url launches a separate,
memory-hungry Firefox instance which tries to connect to the
initial instance and either succeeds or fails after some
time in which my system is essentially unusable.
So for situations where I anticipate a large number of URLs
to be browsed, I replace the calls to browse-url with accu-
mulating the URLs in a list and then executing:
| (apply 'call-process "firefox" nil "*firefox*" nil urls)
This works, but is rather distracting for (mapc #'browse-url
(generate-urls)) oneliners in *scratch* or IELM. So I came
up with:
| (defvar accumulated-browse-url-timer nil
| "Timer used for accumulating browsing URLs.")
| (defvar accumulated-browse-url-urls nil
| "Accumulated URLs to browse.")
| (defun accumulated-browse-url (URL &rest ARGS)
| "Browse URL accumulatedly."
| (if accumulated-browse-url-timer
| (cancel-timer accumulated-browse-url-timer))
| (push URL accumulated-browse-url-urls)
| (setq accumulated-browse-url-timer
| (run-with-idle-timer 5 nil
| (lambda ()
| (apply
| 'call-process
| "firefox"
| nil
| "*firefox*"
| nil
| (reverse accumulated-browse-url-urls))
| (setq accumulated-browse-url-urls nil)))))
which collects all URLs to be browsed until Emacs is idling
for five seconds and then launch a single Firefox instance
that then can communicate with the initial Firefox instance
and open a new window.
This works even better, but it does not solve the underlying
problem in The Right Way™: It just thinks five seconds sure-
ly must be enough instead of letting Firefox open the
link(s) and then waiting for it to sort itself out (or wait-
ing for Firefox to be "ready" and then open the link).
Also, if one just wants to open one link, one has to wait
(at least) those five seconds to look at the URL in Firefox.
Are there other solutions to this problem that are more
robust?
TIA,
Tim
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Making browse-url-firefox more robust?
2022-02-04 22:51 Making browse-url-firefox more robust? Tim Landscheidt
@ 2022-02-05 1:41 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-04-05 23:07 ` TRS-80
2022-04-06 0:50 ` Felix Dietrich
1 sibling, 1 reply; 4+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2022-02-05 1:41 UTC (permalink / raw)
To: help-gnu-emacs
Tim Landscheidt wrote:
> | (dotimes (i 100)
> | (browse-url (format "https://some.url/%d" i)))
OT (off topic): Why the vertical line syntax?
> In this case, each call to browse-url launches a separate,
> memory-hungry Firefox instance
OT (on topic):
(setq browse-url-firefox-new-window-is-tab t)
Do the equivalent of:
$ firefox url1 ... urln
No need for loops or set functions what I can see?
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Making browse-url-firefox more robust?
2022-02-05 1:41 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2022-04-05 23:07 ` TRS-80
0 siblings, 0 replies; 4+ messages in thread
From: TRS-80 @ 2022-04-05 23:07 UTC (permalink / raw)
To: help-gnu-emacs
On 2022-02-04 20:41, Emanuel Berg via Users list for the GNU Emacs text
editor wrote:
> (setq browse-url-firefox-new-window-is-tab t)
>
In my Emacs, this is set to nil, but when I open something it opens in a
tab and not a new 'window'.
However I looked, and I am using instead:
(call-process "xdg-open" nil 0 nil <url>)
I am not sure that's what makes the difference, though. I am starting
to wonder if this is actually a setting in Firefox itself (I typically
set FF to open links in a new tab, not a new 'window', but that's been a
long time now).
Cheers,
TRS-80
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Making browse-url-firefox more robust?
2022-02-04 22:51 Making browse-url-firefox more robust? Tim Landscheidt
2022-02-05 1:41 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2022-04-06 0:50 ` Felix Dietrich
1 sibling, 0 replies; 4+ messages in thread
From: Felix Dietrich @ 2022-04-06 0:50 UTC (permalink / raw)
To: help-gnu-emacs
Tim Landscheidt <tim@tim-landscheidt.de> writes:
> I have set browse-url-browser-function to
> 'browse-url-firefox (and browse-url-firefox-arguments to
> '("-P" "default")) and it works reasonably fine: I see a
> link in Gnus or elsewhere in Emacs, I click on it, the link
> opens in a new tab in Firefox.
>
> Where it becomes a nuisance is when I don't need to open one
> link, but many, for example generated by some database query
> or generator function:
>
> | (dotimes (i 100)
> | (browse-url (format "https://some.url/%d" i)))
>
> In this case, each call to browse-url launches a separate,
> memory-hungry Firefox instance which tries to connect to the
> initial instance and either succeeds or fails after some
> time in which my system is essentially unusable.
If you go to <about:preferences>, what does the option “Open links in tabs
instead of new windows” under General/Tabs say? The corresponding
configuration settings under <about:config> are:
- browser.link.open_newwindow
+ 1 :: Open links in the current tab.
+ 2 :: Open links in a new window.
+ 3 :: Open links in a new tab.
- browser.link.open_newwindow.override.external
+ -1 :: Use the value browser.link.open_newwindow.
+ Other values have the same meaning as for
browser.link.open_newwindow.
For one of calls you can also use the “--new-tab” switch (starting with
a double or a single dash, does not seem to matter) to Firefox:
firefox --new-tab URL
There also is an analogous “--new-window” switch.
Links:
<https://kb.mozillazine.org/Browser.link.open_newwindow>
<https://wiki.mozilla.org/Firefox/CommandLineOptions#-new-tab_URL>
--
Felix Dietrich
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-04-06 0:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-04 22:51 Making browse-url-firefox more robust? Tim Landscheidt
2022-02-05 1:41 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-04-05 23:07 ` TRS-80
2022-04-06 0:50 ` Felix Dietrich
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.