User: simon
Date: 05/03/09 12:15:00
Modified: packages/xemacs-packages/mail-lib browse-url.el
browse-url-xemacs.el ChangeLog
Log:
2005-03-09 Steve Youngs <steve(a)sxemacs.org>
Support Firefox in browse-url.
* browse-url.el (browse-url-browser-function): Add firefox.
(browse-url-firefox-program): New.
(browse-url-firefox-arguments): New.
(browse-url-firefox-startup-arguments): New.
(browse-url-firefox-new-window-is-tab): New.
(browse-url-default-browser): Add firefox.
(browse-url-firefox): New.
(browse-url-firefox-sentinel): New.
* browse-url-xemacs.el: Add menu item for Firefox.
Revision Changes Path
1.36 +94 -3 XEmacs/packages/xemacs-packages/mail-lib/browse-url.el
Index: browse-url.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/packages/xemacs-packages/mail-lib/browse-url.el,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- browse-url.el 2005/02/26 19:09:55 1.35
+++ browse-url.el 2005/03/09 11:14:56 1.36
@@ -40,6 +40,7 @@
;; Function Browser Earliest version
;; browse-url-mozilla Mozilla Don't know
+;; browse-url-firefox Firefox Don't know (1st tried with
1.0.1)
;; browse-url-galeon Galeon Don't know
;; browse-url-epiphany Epiphany Don't know
;; browse-url-netscape Netscape 1.1b1
@@ -266,6 +267,7 @@
(function-item :tag "W3M in another Emacs via `gnudoit'"
:value browse-url-w3-gnudoit)
(function-item :tag "Mozilla" :value browse-url-mozilla)
+ (function-item :tag "Firefox" :value browse-url-firefox)
(function-item :tag "Galeon" :value browse-url-galeon)
(function-item :tag "Epiphany" :value browse-url-epiphany)
(function-item :tag "Netscape" :value browse-url-netscape)
@@ -348,6 +350,24 @@
:group 'browse-url)
;;;###autoload
+(defcustom browse-url-firefox-program "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)
+
+;;;###autoload
(defcustom browse-url-galeon-program "galeon"
"*The name by which to invoke Galeon."
:type 'string
@@ -389,6 +409,13 @@
:type 'boolean
:group 'browse-url)
+(defcustom browse-url-firefox-new-window-is-tab nil
+ "*Whether to open up new windows in a tab or a new window.
+If non-nil, then open the URL in a new tab rather than a new window if
+`browse-url-firefox' is asked to open it in a new window."
+ :type 'boolean
+ :group 'browse-url)
+
(defcustom browse-url-galeon-new-window-is-tab nil
"*Whether to open up new windows in a tab or a new window.
If non-nil, then open the URL in a new tab rather than a new window if
@@ -840,13 +867,14 @@
When called non-interactively, optional second argument NEW-WINDOW is
used instead of `browse-url-new-window-flag'.
-The order attempted is emacs-w3m, gnome-moz-remote, Mozilla, Galeon,
-Konqueror, Netscape, Opera, Mosaic, IXI Mosaic, Lynx in an xterm, MMM,
-and then W3."
+The order attempted is emacs-w3m, gnome-moz-remote, Mozilla, Firefox,
+Galeon, Konqueror, Netscape, Opera, Mosaic, IXI Mosaic, Lynx in an
+xterm, MMM, and then W3."
(apply
(cond
((executable-find browse-url-gnome-moz-program) 'browse-url-gnome-moz)
((executable-find browse-url-mozilla-program) 'browse-url-mozilla)
+ ((executable-find browse-url-firefox-program) 'browse-url-firefox)
((executable-find browse-url-galeon-program) 'browse-url-galeon)
((executable-find browse-url-kde-program) 'browse-url-kde)
((executable-find browse-url-netscape-program) 'browse-url-netscape)
@@ -995,6 +1023,69 @@
(apply 'start-process (concat "mozilla " url) nil
browse-url-mozilla-program
(append browse-url-mozilla-startup-arguments (list url))))))
+
+;;;###autoload
+(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'.
+
+If `browse-url-firefox-new-window-is-tab' is non-nil, then whenever a
+document would otherwise be loaded in a new window, it is loaded in a
+new tab in an existing window instead.
+
+When called non-interactively, optional second argument NEW-WINDOW is
+used instead of `browse-url-new-window-flag'.
+
+On MS-Windows systems the optional `new-window' parameter is ignored.
+Firefox for Windows does not support the \"-remote\" command line
+parameter. Therefore the `browse-url-new-window-flag',
+`browse-url-new-window-flag' and `browse-url-firefox-new-window-is-tab'
+are ignored as well. Firefox on Windows will always open the
+requested URL in a new window."
+ (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
+ browse-url-firefox-program
+ (append
+ browse-url-firefox-arguments
+ (if (or (featurep 'dos-w32)
+ (string-match "win32" system-configuration))
+ (list url)
+ (list "-remote"
+ (concat "openURL("
+ url
+ (if (browse-url-maybe-new-window
+ new-window)
+ (if browse-url-firefox-new-window-is-tab
+ ",new-tab"
+ ",new-window"))
+ ")")))))))
+ (set-process-sentinel process
+ `(lambda (process change)
+ (browse-url-firefox-sentinel process ,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 is 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))))))
;;;###autoload
(defun browse-url-galeon (url &optional new-window)
1.5 +7 -0 XEmacs/packages/xemacs-packages/mail-lib/browse-url-xemacs.el
Index: browse-url-xemacs.el
===================================================================
RCS file:
/pack/xemacscvs/XEmacs/packages/xemacs-packages/mail-lib/browse-url-xemacs.el,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- browse-url-xemacs.el 2003/01/05 20:58:58 1.4
+++ browse-url-xemacs.el 2005/03/09 11:14:56 1.5
@@ -108,6 +108,13 @@
:selected (eq browse-url-browser-function 'browse-url-mozilla)
:active (and (fboundp 'browse-url-mozilla)
(executable-find browse-url-mozilla-program))]
+ ["%_Firefox"
+ (customize-set-variable 'browse-url-browser-function
+ 'browse-url-firefox)
+ :style radio
+ :selected (eq browse-url-browser-function 'browse-url-firefox)
+ :active (and (fboundp 'browse-url-firefox)
+ (executable-find browse-url-firefox-program))]
["G%_aleon"
(customize-set-variable 'browse-url-browser-function
'browse-url-galeon)
1.156 +15 -0 XEmacs/packages/xemacs-packages/mail-lib/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /pack/xemacscvs/XEmacs/packages/xemacs-packages/mail-lib/ChangeLog,v
retrieving revision 1.155
retrieving revision 1.156
diff -u -r1.155 -r1.156
--- ChangeLog 2005/02/28 21:33:11 1.155
+++ ChangeLog 2005/03/09 11:14:56 1.156
@@ -1,3 +1,18 @@
+2005-03-09 Steve Youngs <steve(a)sxemacs.org>
+
+ Support Firefox in browse-url.
+
+ * browse-url.el (browse-url-browser-function): Add firefox.
+ (browse-url-firefox-program): New.
+ (browse-url-firefox-arguments): New.
+ (browse-url-firefox-startup-arguments): New.
+ (browse-url-firefox-new-window-is-tab): New.
+ (browse-url-default-browser): Add firefox.
+ (browse-url-firefox): New.
+ (browse-url-firefox-sentinel): New.
+
+ * browse-url-xemacs.el: Add menu item for Firefox.
+
2005-02-28 Norbert Koch <viteno(a)xemacs.org>
* Makefile (VERSION): XEmacs package 1.71 released.