From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Denis Howe Newsgroups: gmane.emacs.bugs Subject: browse-url.el extras Date: Thu, 15 Sep 2005 00:30:54 +0100 Message-ID: NNTP-Posting-Host: main.gmane.org X-Trace: sea.gmane.org 1126740916 26613 80.91.229.2 (14 Sep 2005 23:35:16 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 14 Sep 2005 23:35:16 +0000 (UTC) Cc: Eric Moss Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Sep 15 01:35:14 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1EFgmQ-0008GH-Vg for geb-bug-gnu-emacs@m.gmane.org; Thu, 15 Sep 2005 01:35:07 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EFgmO-0008Sy-E5 for geb-bug-gnu-emacs@m.gmane.org; Wed, 14 Sep 2005 19:35:04 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EFgkL-0007j3-PT for bug-gnu-emacs@gnu.org; Wed, 14 Sep 2005 19:32:58 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EFgkJ-0007iU-5e for bug-gnu-emacs@gnu.org; Wed, 14 Sep 2005 19:32:56 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EFgkG-0007gx-Oq for bug-gnu-emacs@gnu.org; Wed, 14 Sep 2005 19:32:52 -0400 Original-Received: from [146.169.1.193] (helo=roadrunner.doc.ic.ac.uk) by monty-python.gnu.org with esmtp (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA:24) (Exim 4.34) id 1EFgiP-0002vB-2P for bug-gnu-emacs@gnu.org; Wed, 14 Sep 2005 19:30:57 -0400 Original-Received: from medusa-s10.doc.ic.ac.uk ([146.169.10.18]) by roadrunner.doc.ic.ac.uk with esmtps (TLSv1:AES256-SHA:256) (Exim 4.43) id 1EFgiM-0002Ix-ER; Thu, 15 Sep 2005 00:30:54 +0100 Original-Received: from dbh by medusa-s10.doc.ic.ac.uk with local (Exim 4.20) id 1EFgiM-0003b9-D7; Thu, 15 Sep 2005 00:30:54 +0100 Original-To: browse-url maintainer X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:13012 Archived-At: From: Eric Moss To: dbh@doc.ic.ac.uk Subject: browse-url.el extras Date: Wed, 31 Aug 2005 22:27:31 -0500 (CDT) I wrote some patches (actually just additions) that get it working with the latest Firefox, and Mozilla (at least 1.2.1). For reasons I don't understand (I'm not a great emacs hacker), it's not finding firefox, even though I put the install directory in my PATH. It works just fine when I specify the entire path explicitly. I hope this is of use. Eric ;;; additional functions to put in browse-url.el to help with mozilla ;;; and firefox. I'm not sure why I ahve to put entire path in for ;;; firefox, but don't have to for Mozilla 1.2.x and newer. ;;; Create this function as per /usr/share/emacs/21.2/lisp/net/browse-url.el ;;; so that we open an existing Mozilla window (NOT like with gnome-moz), and ;;; open a new tab inside. ;;; ;;; Load this file AFTER loading/require-ing browse-url.el! (defcustom browse-url-new-mozilla-program "mozilla" ;; Info about netscape-remote from Karl Berry. "The name by which to invoke Mozilla." :type 'string :group 'browse-url) (defcustom browse-url-new-mozilla-arguments nil "A list of strings to pass to Mozilla as arguments." :type '(repeat (string :tag "Argument")) :group 'browse-url) (defcustom browse-url-new-mozilla-startup-arguments browse-url-new-mozilla-arguments "A list of strings to pass to Mozilla when it starts up. Defaults to the value of `browse-url-new-mozilla-arguments' at the time `browse-url' is loaded." :type '(repeat (string :tag "Argument")) :group 'browse-url) (defun browse-url-new-mozilla-sentinel (process url) "Handle a change to the process communicating with Mozilla." (or (eq (process-exit-status process) 0) (let* ((process-environment (browse-url-process-environment))) ;; Mozilla not running - start it (message "Starting Mozilla...") (apply 'start-process (concat "mozilla" url) nil browse-url-new-mozilla-program (append browse-url-new-mozilla-startup-arguments (list url)))))) (defun browse-url-new-mozilla (url &optional new-window) "Ask the Mozilla WWW browser to load URL. Default to the URL around or before point. The strings in variable `browse-url-new-mozilla-arguments' are also passed to Mozilla. When called interactively, if variable `browse-url-new-window-flag' is non-nil, load the document in a new Mozilla window, otherwise use a random existing one. A non-nil interactive prefix argument reverses the effect of `browse-url-new-window-flag'. When called non-interactively, optional second argument NEW-WINDOW is used instead of `browse-url-new-window-flag'." (interactive (browse-url-interactive-arg "URL: ")) ;; URL encode any `confusing' characters in the URL. This needs to ;; include at least commas; presumably also close parens. (while (string-match "[,)]" url) (setq url (replace-match (format "%%%x" (string-to-char (match-string 0 url))) t t url))) (let* ((process-environment (browse-url-process-environment)) (process (apply 'start-process (concat "mozilla " url) nil "mozilla" (append browse-url-new-mozilla-arguments (if (eq window-system 'w32) (list url) (append (if new-window '("-noraise")) (list "-remote" (concat "openURL(" url (if (browse-url-maybe-new-window new-window) ",new-window" ",new-tab") ")")))))))) (set-process-sentinel process `(lambda (process change) (browse-url-new-mozilla-sentinel process ,url))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Now for Firefox (defcustom browse-url-firefox-program "mozilla-xremote-client -a firefox" "The name by which to invoke Firefox." :type 'string :group 'browse-url) (defcustom browse-url-firefox-arguments nil "A list of strings to pass to Firefox as arguments." :type '(repeat (string :tag "Argument")) :group 'browse-url) (defcustom browse-url-firefox-startup-arguments browse-url-firefox-arguments "A list of strings to pass to Firefox when it starts up. Defaults to the value of `browse-url-firefox-arguments' at the time `browse-url' is loaded." :type '(repeat (string :tag "Argument")) :group 'browse-url) (defun browse-url-firefox-sentinel (process url) "Handle a change to the process communicating with Firefox." (or (eq (process-exit-status process) 0) (let* ((process-environment (browse-url-process-environment))) ;; Firefox not running - start it (message "Starting Firefox...") (apply 'start-process (concat "firefox" url) nil browse-url-firefox-program (append browse-url-firefox-startup-arguments (list url)))))) (defun browse-url-firefox (url &optional new-window) "Ask the Firefox WWW browser to load URL. Default to the URL around or before point. The strings in variable `browse-url-firefox-arguments' are also passed to Firefox. When called interactively, if variable `browse-url-new-window-flag' is non-nil, load the document in a new Firefox window, otherwise use a random existing one. A non-nil interactive prefix argument reverses the effect of `browse-url-new-window-flag'. When called non-interactively, optional second argument NEW-WINDOW is used instead of `browse-url-new-window-flag'." (interactive (browse-url-interactive-arg "URL: ")) ;; URL encode any `confusing' characters in the URL. This needs to ;; include at least commas; presumably also close parens. (while (string-match "[,)]" url) (setq url (replace-match (format "%%%x" (string-to-char (match-string 0 url))) t t url))) (let* ((process-environment (browse-url-process-environment)) (process (apply 'start-process (concat "firefox " url) nil "firefox" (append browse-url-firefox-arguments (if (eq window-system 'w32) (list url) (append (if new-window '("-noraise")) (list "-remote" (concat "openURL(" url (if (browse-url-maybe-new-window new-window) ",new-window" ",new-tab") ")")))))))) (set-process-sentinel process `(lambda (process change) (browse-url-firefox-sentinel process ,url))))) ------- End of forwarded message -------