1 ;;; liece-url.el --- URL browsing.
2 ;; Copyright (C) 1998-2000 Daiki Ueno
4 ;; Author: Daiki Ueno <ueno@unixuser.org>
7 ;; Keywords: IRC, liece
9 ;; This file is part of Liece.
11 ;; This program is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; This program is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
33 (require 'liece-inlines)
35 (require 'liece-menu))
37 (defvar browse-url-browser-function)
39 (defgroup liece-url nil
40 "URL Browsing in IRC buffer."
43 (defcustom liece-url-regexp "\\b\\(s?https?\\|ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\):\\(//[-a-zA-Z0-9_.]+:[0-9]*\\)?[-a-zA-Z0-9_=?#$@~`%&*+|\\/.,]*[-a-zA-Z0-9_=#$@~`%&*+|\\/]"
44 "Regular expression that matches URLs."
48 (defcustom liece-url-browser-function browse-url-browser-function
49 "Default URL Browser."
52 (defcustom liece-url-alist nil
53 "Alist for URL completion."
57 (define-widget 'liece-url-link 'link
58 "A link to an www page."
59 :help-echo 'widget-url-link-help-echo
60 :action 'liece-url-link-action)
62 (defun liece-url-link-action (widget &optional event)
63 (let ((browse-url-browser-function liece-url-browser-function))
64 (browse-url (widget-value widget))))
66 (defvar liece-url-add-hook nil)
68 (defun liece-url-add-buttons (start end)
71 (while (re-search-forward liece-url-regexp end t)
72 (let ((url (match-string 0)))
73 (if liece-highlight-mode
74 (liece-widget-convert-button
75 'url-link (match-beginning 0)(match-end 0) url))
76 (unless (assoc url liece-url-alist)
77 (push (list url) liece-url-alist)
78 (run-hook-with-args 'liece-url-add-hook url))))))
80 (defun liece-command-browse-url (&optional url)
83 (if (and current-prefix-arg (eq current-prefix-arg '-))
84 (setq url (caar liece-url-alist))
85 (setq url (liece-minibuffer-completing-default-read
86 (_ "Open URL:") liece-url-alist)))
88 (let ((browse-url-browser-function liece-url-browser-function))
91 (defun url-irc-liece (host port channel user password)
93 `(:host ,host :service ,port :password ,password))
94 (liece-startup-channel channel))
99 ;;; liece-url.el ends here