From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Hugh Lawson Newsgroups: gmane.emacs.help Subject: Re: browse-url Date: Tue, 05 Apr 2005 00:36:07 GMT Organization: RoadRunner - Triad Message-ID: <87r7hqktbr.fsf@desktop.xx.yy> References: <877jjn742a.fsf@desktop.xx.yy> <877jjjsbub.fsf@desktop.xx.yy> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1112661553 13494 80.91.229.2 (5 Apr 2005 00:39:13 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 5 Apr 2005 00:39:13 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Apr 05 02:39:11 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DIc5S-0006AL-8V for geh-help-gnu-emacs@m.gmane.org; Tue, 05 Apr 2005 02:38:34 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DIbeF-0001Bt-Ds for geh-help-gnu-emacs@m.gmane.org; Mon, 04 Apr 2005 20:10:27 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!elnk-nf2-pas!elnk-pas-nf1!newsfeed.earthlink.net!cyclone.socal.rr.com!cyclone2.kc.rr.com!news2.kc.rr.com!news-post.tampabay.rr.com!twister.southeast.rr.com.POSTED!53ab2750!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 78 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 Original-NNTP-Posting-Host: 65.190.8.206 Original-X-Complaints-To: abuse@rr.com Original-X-Trace: twister.southeast.rr.com 1112661367 65.190.8.206 (Mon, 04 Apr 2005 20:36:07 EDT) Original-NNTP-Posting-Date: Mon, 04 Apr 2005 20:36:07 EDT Original-Xref: shelby.stanford.edu gnu.emacs.help:129826 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:25384 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:25384 David Kastrup writes: > Hugh Lawson writes: > > > David Kastrup writes: > > > >> Hugh Lawson writes: > >> > >> > Debian sarge > >> > Emacs 21.4.1 > >> > > >> > browse-url works fine if firefox is already running. > >> > > >> > But suppose firefox isn't running. > >> > > >> > If I do 'M-x browse-url' and fill in the url, then firefox pops up for > >> > a second and then disappears. The same thing happens with links I > >> > click on in Emacs. > >> > > >> > I think I can imagine a shell script to deal with this, but surely > >> > there is something alread in Emacs. > >> > >> The definition of browse-url-generic in browse-url.el needs to get > >> replaced with: > >> > >> (defun browse-url-generic (url &optional new-window) > >> ;; new-window ignored > >> "Ask the WWW browser defined by `browse-url-generic-program' to load URL. > >> Default to the URL around or before point. A fresh copy of the > >> browser is started up in a new process with possible additional arguments > >> `browse-url-generic-args'. This is appropriate for browsers which > >> don't offer a form of remote control." > >> (interactive (browse-url-interactive-arg "URL: ")) > >> (if (not browse-url-generic-program) > >> (error "No browser defined (`browse-url-generic-program')")) > >> (apply 'call-process browse-url-generic-program nil > >> 0 nil > >> (append browse-url-generic-args (list url)))) > > > > > > I don't understand how this solves my problem. If mozilla-firefox > > is open and running. all is well. If it isn't then there is a > > problem. > > Emacs has several possibilities to start processes. Starting with > call-process and 0 as third argument detaches the process completely > from Emacs. > > Starting the process with start-process, in contrast, leaves the > process associated with Emacs. If the process detaches itself from > the tty, Emacs assumes that it is finished and kills the process > group. This is what happens with new Firefoxes that try to escape the > Emacs tty. > > This is why you need an Elisp function that will use call-process > instead of start-process for starting Firefox if it is supposed to > survive detaching. Thanks for the explanation, David. I had trouble making it work, so as a trial, I added the following two functions to my ~/.emacs file. Please critique. I did this purely empirically, with no real understanding. (defun browse-url-firefox (url &optional new-window ) ;;new-window ignored "Ask the firefox browser to load URL." (apply 'call-process "firefox" nil 0 nil (list url))) (setq browse-url-browser-function 'browse-url-firefox) -- Hugh Lawson hlawson@triad.rr.com