* browse-url.el extras
@ 2005-09-14 23:30 Denis Howe
0 siblings, 0 replies; only message in thread
From: Denis Howe @ 2005-09-14 23:30 UTC (permalink / raw)
Cc: Eric Moss
From: Eric Moss <ericmoss@inebraska.com>
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 -------
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2005-09-14 23:30 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-14 23:30 browse-url.el extras Denis Howe
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).