GNU bug report logs - #30981
Document how to use $BROWSER for external browser

Previous Next

Package: emacs;

Reported by: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>

Date: Thu, 29 Mar 2018 02:23:01 UTC

Severity: wishlist

Done: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
Subject: bug#30981: closed (Re: bug#30981: Document how to use $BROWSER
 for external browser)
Date: Fri, 30 Mar 2018 08:31:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#30981: Document how to use $BROWSER for external browser

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 30981 <at> debbugs.gnu.org.

-- 
30981: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=30981
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
To: Katsumi Yamaoka <yamaoka <at> jpl.org>
Cc: Glenn Morris <rgm <at> gnu.org>, 30981-done <at> debbugs.gnu.org
Subject: Re: bug#30981: Document how to use $BROWSER for external browser
Date: Fri, 30 Mar 2018 16:30:36 +0800
OK I'll close it! Thanks.

>>>>> "KY" == Katsumi Yamaoka <yamaoka <at> jpl.org> writes:
KY> On Thu, 29 Mar 2018 20:31:57 -0400, Glenn Morris wrote:

>> xdg-open respects BROWSER, and xdg-open is the browse-url default on GNU/Linux.
>> browse-url-can-use-xdg-open was overly restrictive prior to 26.1.
>> In Emacs 26.1 it probably Just Works.

KY> Thanks.  Though I'm not on GNU/Linux now, is it ok to close this
KY> bug Jidanni?  You should have xdg-open if you are on GNU/Linux.
KY> Even if (browse-url-can-use-xdg-open) returns nil, you can do:

KY> (setq browse-url-browser-function #'browse-url-xdg-open)


[Message part 3 (message/rfc822, inline)]
From: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
To: bug-gnu-emacs <at> gnu.org
Cc: Katsumi Yamaoka <yamaoka <at> jpl.org>
Subject: Document how to use $BROWSER for external browser
Date: Thu, 29 Mar 2018 10:22:29 +0800
Gentleman, other programs know to just use $BROWSER when calling the
external browser. But for emacs and gnus, one must hire a consultant to
achieve the same effect.

At least one of the manuals should say how.

And in fact, if $BROWSER is good enough for other programs, it should be
the default for emacs/gnus too.

>>>>> "KY" == Katsumi Yamaoka <yamaoka <at> jpl.org> writes:
KY> On Tue, 27 Mar 2018 09:31:34 +0800, 積丹尼さん wrote:
>> RET runs the command shr-browse-url, which is an interactive compiled
>> Lisp function in ‘shr.el’.

KY> `shr-browse-url' runs the Lisp function `browse-url' (unless the
KY> prefix argument is given when invoking `shr-browse-url').
KY> So, in the normal way that browse-url's author supposed, you can
KY> choose a certain ready-made Lisp function as you like as follows:

KY> (setq browse-url-browser-function #'browse-url-firefox)

KY> To see the ready-made functions you can use, do:

KY> M-x customize-option RET browse-url-browser-function RET

KY> ;; You will see browse-url-firefox, browse-url-chromium, etc.

>> I want it to call $BROWSER from the environment.

>> ;;(if (string-equal (getenv "BROWSER") "chromium")
>> ;;    nil (setq browse-url-chromium-program
>> ;;	      (concat "/usr/bin/" (getenv "BROWSER")))) ;I am a dork
>> (setq browse-url-default-browser (getenv "BROWSER"))

KY> `browse-url-default-browser' is a function, not a variable, and
KY> is one of candidates for `browse-url-browser-function'.  So,
KY> this (setq ...) form has no effect.  But you are not a dork. :-)
Wrong.
KY> You can create your own Lisp function that sees "BROWSER".
KY> For example:

KY> (setq browse-url-browser-function #'my-browse-url-default-browser)

KY> (defun my-browse-url-default-browser (url &optional _dummy)
KY>   "Run a browser that the environment variable BROWSER specifies.
KY> BROWSER may be an existing shell command name, or a command name plus
KY> some arguments like: \"firefox\", or \"firefox -new-tab\""
KY>   (interactive (browse-url-interactive-arg "URL: "))
KY>   (let ((process-environment (browse-url-process-environment))
KY> 	(browser (getenv "BROWSER"))
KY> 	args name)
KY>     (setq browser (split-string browser)
KY> 	  args (cdr browser)
KY> 	  browser (car browser)
KY> 	  name (concat (file-name-nondirectory browser)
KY> 		       " " (mapconcat #'identity args " ")
KY> 		       " " url)
KY> 	  url (browse-url-encode-url url))
KY>     (apply 'start-process name nil (executable-find browser)
KY> 	   (append args (list url)))))

Waaa... it actually works! Thanks!



This bug report was last modified 7 years and 116 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.