* liece-url.el: Don't require browse-url when compiling.
authorueno <ueno>
Wed, 12 Apr 2000 13:39:28 +0000 (13:39 +0000)
committerueno <ueno>
Wed, 12 Apr 2000 13:39:28 +0000 (13:39 +0000)
(liece-url-browser-name): Abolish.
(liece-url-prepare-browser-function): Abolish.
(liece-url-mail-regexp): Abolish.
(liece-url-browser-function): Abolish.
(liece-url-link-action): Use browse-url directly.
(liece-command-browse-url): Ditto.
(liece-url-add-buttons): Remove local variable `url-start',
`url-end' and `url'.
Suggested by: Kenichi OKADA <okada@opaopa.org>

lisp/liece-url.el

index 11568c6..c02065b 100644 (file)
 (eval-when-compile
   (require 'liece-inlines)
   (require 'liece-intl)
-  (require 'browse-url)
   (require 'liece-menu))
 
-(defvar-maybe browse-url-browser-function nil)
+(defvar browse-url-browser-function)
 
 (defgroup liece-url nil
   "URL Browsing in IRC buffer."
   :group 'liece-url
   :type 'regexp)
 
-(defcustom liece-url-mail-regexp "\\bmailto:\\([-a-zA-Z0-9_=?#$@~`%&*+|\\/.,]*[-a-zA-Z0-9_=#$@~`%&*+|\\/]\\)"
-  "Regular expression that matches mailto:."
-  :group 'liece-url
-  :type 'regexp)
-
-(defcustom liece-url-browser-name
-  (let (url-func url-prog len)
-    (if (featurep 'browse-url)
-       (and (setq url-func browse-url-browser-function)
-            (setq url-prog (symbol-name url-func))
-            (stringp url-prog)
-            (setq len (length url-prog))
-            (setq url-prog (substring url-prog 11 len)))
-      "netscape"))
-  "Default URL Browser Name.
-netscape   Netscape    1.1b1
-mosaic     XMosaic     <= 2.4
-cci        XMosaic     2.5
-w3         w3          0
-iximosaic  IXI Mosaic  ?
-lynx-*     Lynx        0
-grail      Grail       0.3b1"
-  :type 'string
-  :group 'liece-url)
-
-(defvar liece-url-add-hook nil)
-
-(defmacro liece-url-prepare-browser-function ()
-  (if (featurep 'browse-url)
-      '(intern (concat "browse-url-" liece-url-browser-name))
-    '(intern (concat "liece-url-browser-" liece-url-browser-name))))
-
-(defcustom liece-url-browser-function
-  (liece-url-prepare-browser-function)
+(defcustom liece-url-browser-function browse-url-browser-function
   "Default URL Browser."
-  :type 'function
   :group 'liece-url)
 
 (defcustom liece-url-alist nil
@@ -95,24 +60,22 @@ grail      Grail       0.3b1"
   :action 'liece-url-link-action)
 
 (defun liece-url-link-action (widget &optional event)
-  (let ((func (liece-url-prepare-browser-function)))
-    (if (fboundp func)
-        (setq liece-url-browser-function func)
-      (setq func liece-url-browser-function))
-    (funcall func (widget-value widget))))
+  (let ((browse-url-browser-function liece-url-browser-function))
+    (browse-url (widget-value widget))))
+
+(defvar liece-url-add-hook nil)
 
 (defun liece-url-add-buttons (start end)
   (save-excursion
     (goto-char start)
     (while (re-search-forward liece-url-regexp end t)
-      (let* ((url-start (match-beginning 0))
-            (url-end (match-end 0))
-            (url (buffer-substring url-start url-end)))
-       (if liece-highlight-mode
-           (liece-widget-convert-button 'url-link url-start url-end url))
-       (unless (assoc url liece-url-alist)
-         (push (list url) liece-url-alist)
-         (run-hook-with-args 'liece-url-add-hook url))))))
+      (if liece-highlight-mode
+         (liece-widget-convert-button 'url-link
+                                      (match-beginning 0)(match-end 0)
+                                      (match-string 0)))
+      (unless (assoc url liece-url-alist)
+       (push (list url) liece-url-alist)
+       (run-hook-with-args 'liece-url-add-hook url)))))
 
 (defun liece-command-browse-url (&optional url)
   (interactive
@@ -122,11 +85,8 @@ grail      Grail       0.3b1"
        (setq url (liece-minibuffer-completing-default-read
                  (_ "Open URL:") liece-url-alist)))
      (list url)))
-  (let ((func (liece-url-prepare-browser-function)))
-    (if (fboundp func)
-       (setq liece-url-browser-function func)
-      (setq func liece-url-browser-function))
-    (funcall func url)))
+  (let ((browse-url-browser-function liece-url-browser-function))
+    (browse-url url)))
 
 (defun url-irc-liece (host port channel user password)
   (let ((liece-server