"browse-url" support for Macintosh

[email protected] Thu, 13 Jun 2002 07:58:48 +0100
Newsgroups gmane.emacs.macintosh.user
Organization none
Message-ID <[email protected]>
Here is a patch to browse-url.el which adds support for a MacOS
browser function.  It uses Applescript to ask the default browser to
open URLs.

The previous patch to persuade do-applescript to work is required.

This is only tested under MacOSX.  It seems as though it should work
under previous versions of MacOS, but I don't have them to test.
What is the value of "system-type" there ?

Index: browse-url.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/net/browse-url.el,v
retrieving revision 1.21
diff -u -r1.21 browse-url.el
--- browse-url.el	18 Mar 2002 04:24:09 -0000	1.21
+++ browse-url.el	13 Jun 2002 06:57:46 -0000
@@ -1,6 +1,6 @@
 ;;; browse-url.el --- pass a URL to a WWW browser
 
-;; Copyright (C) 1995, 96, 97, 98, 99, 2000, 2001
+;; Copyright (C) 1995, 96, 97, 98, 99, 2000, 2001, 2002
 ;;   Free Software Foundation, Inc.
 
 ;; Author: Denis Howe <[email protected]>
@@ -52,6 +52,7 @@
 ;; browse-url-default-windows-browser MS-Windows browser
 ;; browse-url-gnome-moz               GNOME interface to Mozilla
 ;; browse-url-kde                     KDE konqueror (kfm)
+;; browse-url-default-macintosh-browser	Macintosh browser
 
 ;; [A version of the Netscape browser is now free software
 ;; <URL:http://www.mozilla.org/>, albeit not GPLed, so it is
@@ -227,9 +228,13 @@
 
 ;;;###autoload
 (defcustom browse-url-browser-function
-  (if (memq system-type '(windows-nt ms-dos))
-      'browse-url-default-windows-browser
-    'browse-url-default-browser)
+  (cond
+   ((memq system-type '(windows-nt ms-dos))
+    'browse-url-default-windows-browser)
+   ((eq system-type 'darwin)
+    'browse-url-default-macintosh-browser)
+   (t
+    'browse-url-default-browser))
   "*Function to display the current buffer in a WWW browser.
 This is used by the `browse-url-at-point', `browse-url-at-mouse', and
 `browse-url-of-file' commands.
@@ -262,6 +267,8 @@
 			 :value browse-url-default-windows-browser)
 	  (function-item :tag "GNOME invoking Mozilla"
 			 :value browse-url-gnome-moz)
+	  (function-item :tag "Default Macintosh Browser"
+			 :value browse-url-default-macintosh-browser)
 	  (function-item :tag "Default browser"
 			 :value browse-url-default-browser)
 	  (function :tag "Your own function")
@@ -1260,6 +1267,14 @@
   (message "Sending URL to KDE...")
   (apply #'start-process `(,(concat "KDE" url) nil ,browse-url-kde-program
 			   ,@browse-url-kde-args ,url)))
+
+;;;###autoload
+(defun browse-url-default-macintosh-browser (url &optional new-window)
+  "Ask the default browser to load a URL.
+Default to the URL around or before point."
+  (interactive (browse-url-interactive-arg "Macintosh URL: "))
+  (message "Sending URL...")
+  (do-applescript (concat "open location \"" url "\"")))
 
 (provide 'browse-url)
 



_______________________________________________________________

Don't miss the 2002 Sprint PCS Application Developer's Conference
August 25-28 in Las Vegas - http://devcon.sprintpcs.com/adp/index.cfm?source=osdntextlink