/[emacs]/emacs/lisp/net/browse-url.el
ViewVC logotype

Diff of /emacs/lisp/net/browse-url.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.15 by pj, Mon Jul 16 12:22:59 2001 UTC revision 1.16 by rms, Mon Nov 19 19:12:31 2001 UTC
# Line 4  Line 4 
4  ;;   Free Software Foundation, Inc.  ;;   Free Software Foundation, Inc.
5    
6  ;; Author: Denis Howe <dbh@doc.ic.ac.uk>  ;; Author: Denis Howe <dbh@doc.ic.ac.uk>
7  ;; Maintainer: Dave Love <fx@gnu.org>  ;; Maintainer: FSF
8  ;; Created: 03 Apr 1995  ;; Created: 03 Apr 1995
9  ;; Keywords: hypertext, hypermedia, mouse  ;; Keywords: hypertext, hypermedia, mouse
10    
# Line 37  Line 37 
37  ;; some of them probably now obsolete:  ;; some of them probably now obsolete:
38    
39  ;; Function                           Browser     Earliest version  ;; Function                           Browser     Earliest version
40    ;; browse-url-mozilla                 Mozilla     Don't know
41    ;; browse-url-galeon                  Galeon      Don't know
42  ;; browse-url-netscape                Netscape    1.1b1  ;; browse-url-netscape                Netscape    1.1b1
43  ;; browse-url-mosaic                  XMosaic/mMosaic <= 2.4  ;; browse-url-mosaic                  XMosaic/mMosaic <= 2.4
44  ;; browse-url-cci                     XMosaic     2.5  ;; browse-url-cci                     XMosaic     2.5
# Line 66  Line 68 
68  ;; control but which window DO you want to control and how do you  ;; control but which window DO you want to control and how do you
69  ;; discover its id?  ;; discover its id?
70    
 ;; If using XMosaic before version 2.5, check the definition of  
 ;; browse-url-usr1-signal below.  
 ;; <URL:http://www.ncsa.uiuc.edu/SDG/Software/XMosaic/remote-control.html>  
   
 ;; XMosaic version 2.5 introduced Common Client Interface allowing you  
 ;; to control mosaic through Unix sockets.  
 ;; <URL:http://www.ncsa.uiuc.edu/SDG/Software/XMosaic/CCI/cci-spec.html>  
   
71  ;; William M. Perry's excellent "w3" WWW browser for  ;; William M. Perry's excellent "w3" WWW browser for
72  ;; Emacs <URL:ftp://cs.indiana.edu/pub/elisp/w3/>  ;; Emacs <URL:ftp://cs.indiana.edu/pub/elisp/w3/>
73  ;; has a function w3-follow-url-at-point, but that  ;; has a function w3-follow-url-at-point, but that
# Line 90  Line 84 
84  ;; Python see <url:http://www.python.org/>.  Grail support in  ;; Python see <url:http://www.python.org/>.  Grail support in
85  ;; browse-url.el written by Barry Warsaw <bwarsaw@python.org>.  ;; browse-url.el written by Barry Warsaw <bwarsaw@python.org>.
86    
 ;; MMM is a semi-free WWW browser implemented in Objective Caml, an  
 ;; interesting impure functional programming language.  See  
 ;; <URL:http://pauillac.inria.fr/%7Erouaix/mmm/>.  
   
87  ;; Lynx is now distributed by the FSF.  See also  ;; Lynx is now distributed by the FSF.  See also
88  ;; <URL:http://lynx.browser.org/>.  ;; <URL:http://lynx.browser.org/>.
89    
# Line 226  Line 216 
216  (eval-when-compile (require 'thingatpt)  (eval-when-compile (require 'thingatpt)
217                     (require 'term)                     (require 'term)
218                     (require 'dired)                     (require 'dired)
219                       (require 'executable)
220                     (require 'w3-auto nil t))                     (require 'w3-auto nil t))
221    
222  (defgroup browse-url nil  (defgroup browse-url nil
# Line 238  Line 229 
229  (defcustom browse-url-browser-function  (defcustom browse-url-browser-function
230    (if (memq system-type '(windows-nt ms-dos))    (if (memq system-type '(windows-nt ms-dos))
231        'browse-url-default-windows-browser        'browse-url-default-windows-browser
232      'browse-url-netscape)      'browse-url-default-browser)
233    "*Function to display the current buffer in a WWW browser.    "*Function to display the current buffer in a WWW browser.
234  This is used by the `browse-url-at-point', `browse-url-at-mouse', and  This is used by the `browse-url-at-point', `browse-url-at-mouse', and
235  `browse-url-of-file' commands.  `browse-url-of-file' commands.
# Line 252  regexp should probably be \".\" to speci Line 243  regexp should probably be \".\" to speci
243            (function-item :tag "Emacs W3" :value  browse-url-w3)            (function-item :tag "Emacs W3" :value  browse-url-w3)
244            (function-item :tag "W3 in another Emacs via `gnudoit'"            (function-item :tag "W3 in another Emacs via `gnudoit'"
245                           :value  browse-url-w3-gnudoit)                           :value  browse-url-w3-gnudoit)
246              (function-item :tag "Mozilla" :value  browse-url-mozilla)
247              (function-item :tag "Galeon" :value  browse-url-galeon)
248            (function-item :tag "Netscape" :value  browse-url-netscape)            (function-item :tag "Netscape" :value  browse-url-netscape)
249            (function-item :tag "Mosaic" :value  browse-url-mosaic)            (function-item :tag "Mosaic" :value  browse-url-mosaic)
250            (function-item :tag "Mosaic using CCI" :value  browse-url-cci)            (function-item :tag "Mosaic using CCI" :value  browse-url-cci)
# Line 269  regexp should probably be \".\" to speci Line 262  regexp should probably be \".\" to speci
262                           :value browse-url-default-windows-browser)                           :value browse-url-default-windows-browser)
263            (function-item :tag "GNOME invoking Mozilla"            (function-item :tag "GNOME invoking Mozilla"
264                           :value browse-url-gnome-moz)                           :value browse-url-gnome-moz)
265              (function-item :tag "Default browser"
266                             :value browse-url-default-browser)
267            (function :tag "Your own function")            (function :tag "Your own function")
268            (alist :tag "Regexp/function association list"            (alist :tag "Regexp/function association list"
269                   :key-type regexp :value-type function))                   :key-type regexp :value-type function))
# Line 300  Defaults to the value of `browse-url-net Line 295  Defaults to the value of `browse-url-net
295    :group 'browse-url)    :group 'browse-url)
296    
297  ;;;###autoload  ;;;###autoload
298    (defcustom browse-url-browser-display nil
299      "*The X display for running the browser, if not same as Emacs'."
300      :type '(choice string (const :tag "Default" nil))
301      :group 'browse-url)
302    
303    (defcustom browse-url-mozilla-program "mozilla"
304      "The name by which to invoke Mozilla."
305      :type 'string
306      :group 'browse-url)
307    
308    (defcustom browse-url-mozilla-arguments nil
309      "A list of strings to pass to Mozilla as arguments."
310      :type '(repeat (string :tag "Argument"))
311      :group 'browse-url)
312    
313    (defcustom browse-url-mozilla-startup-arguments browse-url-mozilla-arguments
314      "A list of strings to pass to Mozilla when it starts up.
315    Defaults to the value of `browse-url-mozilla-arguments' at the time
316    `browse-url' is loaded."
317      :type '(repeat (string :tag "Argument"))
318      :group 'browse-url)
319    
320    ;;;###autoload
321    (defcustom browse-url-galeon-program "galeon"
322      "The name by which to invoke Galeon."
323      :type 'string
324      :group 'browse-url)
325    
326    (defcustom browse-url-galeon-arguments nil
327      "A list of strings to pass to Galeon as arguments."
328      :type '(repeat (string :tag "Argument"))
329      :group 'browse-url)
330    
331    (defcustom browse-url-galeon-startup-arguments browse-url-galeon-arguments
332      "A list of strings to pass to Galeon when it starts up.
333    Defaults to the value of `browse-url-galeon-arguments' at the time
334    `browse-url' is loaded."
335      :type '(repeat (string :tag "Argument"))
336      :group 'browse-url)
337    
338    ;;;###autoload
339  (defcustom browse-url-new-window-flag nil  (defcustom browse-url-new-window-flag nil
340    "*If non-nil, always open a new browser window with appropriate browsers.    "*If non-nil, always open a new browser window with appropriate browsers.
341  Passing an interactive argument to \\[browse-url], or specific browser  Passing an interactive argument to \\[browse-url], or specific browser
# Line 308  commands reverses the effect of this var Line 344  commands reverses the effect of this var
344    :type 'boolean    :type 'boolean
345    :group 'browse-url)    :group 'browse-url)
346    
 ;;;###autoload  
 (defcustom browse-url-netscape-display nil  
   "*The X display for running Netscape, if not same as Emacs'."  
   :type '(choice string (const :tag "Default" nil))  
   :group 'browse-url)  
   
347  (defcustom browse-url-mosaic-program "xmosaic"  (defcustom browse-url-mosaic-program "xmosaic"
348    "The name by which to invoke Mosaic (or mMosaic)."    "The name by which to invoke Mosaic (or mMosaic)."
349    :type 'string    :type 'string
# Line 679  to use." Line 709  to use."
709  ;; --- Netscape ---  ;; --- Netscape ---
710    
711  (defun browse-url-process-environment ()  (defun browse-url-process-environment ()
712    "Set DISPLAY in the environment to the X display Netscape is running on.    "Set DISPLAY in the environment to the X display the browser will use.
713  This is either the value of variable `browse-url-netscape-display' if  This is either the value of variable `browse-url-browser-display' if
714  non-nil, or the same display as Emacs if different from the current  non-nil, or the same display as Emacs if different from the current
715  environment, otherwise just use the current environment."  environment, otherwise just use the current environment."
716    (let ((display (or browse-url-netscape-display (browse-url-emacs-display))))    (let ((display (or browse-url-browser-display (browse-url-emacs-display))))
717      (if display      (if display
718          (cons (concat "DISPLAY=" display) process-environment)          (cons (concat "DISPLAY=" display) process-environment)
719        process-environment)))        process-environment)))
# Line 699  one showing the selected frame." Line 729  one showing the selected frame."
729           display)))           display)))
730    
731  ;;;###autoload  ;;;###autoload
732    (defun browse-url-default-browser (url &rest args)
733      "Find a suitable browser and ask it to load URL.
734    Default to the URL around or before point.
735    
736    When called interactively, if variable `browse-url-new-window-flag' is
737    non-nil, load the document in a new window, if possible, otherwise use
738    a random existing one.  A non-nil interactive prefix argument reverses
739    the effect of `browse-url-new-window-flag'.
740    
741    When called non-interactively, optional second argument NEW-WINDOW is
742    used instead of `browse-url-new-window-flag'.
743    
744    The order attempted is gnome-moz-remote, Mozilla, Galeon, Netscape,
745    Mosaic, IXI Mosaic, Lynx in an xterm, MMM, Konqueror, and then W3."
746      (apply
747        (cond
748         ((executable-find "gnome-moz-remote") 'browse-url-gnome-moz)
749         ((executable-find browse-url-mozilla-program) 'browse-url-mozilla)
750         ((executable-find browse-url-galeon-program) 'browse-url-galeon)
751         ((executable-find browse-url-kde-program) 'browse-url-kde)
752         ((executable-find browse-url-netscape-program) 'browse-url-netscape)
753         ((executable-find browse-url-mosaic-program) 'browse-url-mosaic)
754         ((executable-find "tellw3b") 'browse-url-iximosaic)
755         ((executable-find browse-url-xterm-program) 'browse-url-lynx-xterm)
756         ((executable-find "mmm") 'browse-url-mmm)
757         (t 'browse-url-w3))
758         url args))
759    
760    ;;;###autoload
761  (defun browse-url-netscape (url &optional new-window)  (defun browse-url-netscape (url &optional new-window)
762    "Ask the Netscape WWW browser to load URL.    "Ask the Netscape WWW browser to load URL.
763  Default to the URL around or before point.  The strings in variable  Default to the URL around or before point.  The strings in variable
# Line 765  How depends on `browse-url-netscape-vers Line 824  How depends on `browse-url-netscape-vers
824             (append browse-url-netscape-arguments             (append browse-url-netscape-arguments
825                     (list "-remote" command)))))                     (list "-remote" command)))))
826    
827    ;;;###autoload
828    (defun browse-url-mozilla (url &optional new-window)
829      "Ask the Mozilla WWW browser to load URL.
830    Default to the URL around or before point.  The strings in variable
831    `browse-url-mozilla-arguments' are also passed to Mozilla.
832    
833    When called interactively, if variable `browse-url-new-window-flag' is
834    non-nil, load the document in a new Mozilla window, otherwise use a
835    random existing one.  A non-nil interactive prefix argument reverses
836    the effect of `browse-url-new-window-flag'.
837    
838    When called non-interactively, optional second argument NEW-WINDOW is
839    used instead of `browse-url-new-window-flag'."
840      (interactive (browse-url-interactive-arg "URL: "))
841      ;; URL encode any `confusing' characters in the URL.  This needs to
842      ;; include at least commas; presumably also close parens.
843      (while (string-match "[,)]" url)
844        (setq url (replace-match
845                   (format "%%%x" (string-to-char (match-string 0 url))) t t url)))
846      (let* ((process-environment (browse-url-process-environment))
847             (process (apply 'start-process
848                             (concat "mozilla " url) nil
849                             browse-url-mozilla-program
850                             (append
851                              browse-url-mozilla-arguments
852                              (list "-remote"
853                                    (concat "openURL("
854                                            url
855                                            (if new-window ",new-window")
856                                            ")"))))))
857        (set-process-sentinel process
858                              `(lambda (process change)
859                                 (browse-url-mozilla-sentinel process ,url)))))
860    
861    (defun browse-url-mozilla-sentinel (process url)
862      "Handle a change to the process communicating with Mozilla."
863      (or (eq (process-exit-status process) 0)
864          (let* ((process-environment (browse-url-process-environment)))
865            ;; Mozilla is not running - start it
866            (message "Starting Mozilla...")
867            (apply 'start-process (concat "mozilla " url) nil
868                   browse-url-mozilla-program
869                   (append browse-url-mozilla-startup-arguments (list url))))))
870    
871    ;;;###autoload
872    (defun browse-url-galeon (url &optional new-window)
873      "Ask the Galeon WWW browser to load URL.
874    Default to the URL around or before point.  The strings in variable
875    `browse-url-galeon-arguments' are also passed to Galeon.
876    
877    When called interactively, if variable `browse-url-new-window-flag' is
878    non-nil, load the document in a new Galeon window, otherwise use a
879    random existing one.  A non-nil interactive prefix argument reverses
880    the effect of `browse-url-new-window-flag'.
881    
882    When called non-interactively, optional second argument NEW-WINDOW is
883    used instead of `browse-url-new-window-flag'."
884      (interactive (browse-url-interactive-arg "URL: "))
885      ;; URL encode any `confusing' characters in the URL.  This needs to
886      ;; include at least commas; presumably also close parens.
887      (while (string-match "[,)]" url)
888        (setq url (replace-match
889                   (format "%%%x" (string-to-char (match-string 0 url))) t t url)))
890      (let* ((process-environment (browse-url-process-environment))
891             (process (apply 'start-process
892                             (concat "galeon " url) nil
893                             browse-url-galeon-program
894                             (append
895                              browse-url-galeon-arguments
896                              (if new-window '("-w" "--noraise"))
897                              (list "-x" url)))))
898        (set-process-sentinel process
899                              `(lambda (process change)
900                                 (browse-url-galeon-sentinel process ,url)))))
901    
902    (defun browse-url-galeon-sentinel (process url)
903      "Handle a change to the process communicating with Galeon."
904      (or (eq (process-exit-status process) 0)
905          (let* ((process-environment (browse-url-process-environment)))
906            ;; Galeon is not running - start it
907            (message "Starting Galeon...")
908            (apply 'start-process (concat "galeon " url) nil
909                   browse-url-galeon-program
910                   (append browse-url-galeon-startup-arguments (list url))))))
911    
912  ;; GNOME means of invoking either Mozilla or Netrape.  ;; GNOME means of invoking either Mozilla or Netrape.
913    
914  (defcustom browse-url-gnome-moz-arguments '()  (defcustom browse-url-gnome-moz-arguments '()

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.16

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26