From: ueno Date: Mon, 15 Jul 2002 02:18:41 +0000 (+0000) Subject: * liece-url.el (liece-url-regexp-alist): New user option. X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=7e35d5a1b33676a6ba2275902277d07ebb0b2784;p=elisp%2Fliece.git * liece-url.el (liece-url-regexp-alist): New user option. (liece-url-add-buttons): Respect liece-url-regexp-alist. This function is the slightly modified version of the implementation by akira yamada . [cf. ] --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index b2f41d3..aa590e3 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2002-07-15 Daiki Ueno + + * liece-url.el (liece-url-regexp-alist): New user option. + (liece-url-add-buttons): Respect liece-url-regexp-alist. This + function is the slightly modified version of the implementation by + akira yamada . [cf. ] + 2002-05-19 Daiki Ueno * liece-xemacs.el (liece-xemacs-modeline-glyph): Check 'xbm. diff --git a/lisp/liece-url.el b/lisp/liece-url.el index bac5ce7..97fe628 100644 --- a/lisp/liece-url.el +++ b/lisp/liece-url.el @@ -58,6 +58,15 @@ :type 'alist :group 'liece-url) +(defcustom liece-url-regexp-alist nil + "Mapping from reegxp to URL. +This alist is used for defining alternate URL abbrevs. +For example: + (setq liece-url-regexp-alist + '((\"\\\\bBug#\\\\([0-9][0-9]*\\\\)\\\\b\" . \"http://bugs.debian.org/\\\\1\")))" + :type 'alist + :group 'liece-url) + (define-widget 'liece-url-link 'link "A link to an www page." :help-echo 'widget-url-link-help-echo @@ -71,15 +80,24 @@ (defun liece-url-add-buttons (start end) (save-excursion - (goto-char start) - (while (re-search-forward liece-url-regexp end t) - (let ((url (match-string 0))) - (if liece-highlight-mode - (liece-widget-convert-button - 'url-link (match-beginning 0)(match-end 0) url)) - (unless (assoc url liece-url-alist) - (push (list url) liece-url-alist) - (run-hook-with-args 'liece-add-url-functions url)))))) + (let ((pairs (cons (cons liece-url-regexp t) + liece-url-regexp-alist))) + (dolist (pair pairs) + (goto-char start) + (while (re-search-forward (car pair) end t) + (let ((url (match-string 0))) + (if (stringp (cdr pair)) + (setq url (save-match-data + (string-match (car pair) url) + (replace-match (cdr pair) nil nil url))) + (if (functionp (cdr pair)) + (setq url (funcall (cdr pair) url)))) + (if liece-highlight-mode + (liece-widget-convert-button + 'url-link (match-beginning 0) (match-end 0) url)) + (unless (assoc url liece-url-alist) + (push (list url) liece-url-alist) + (run-hook-with-args 'liece-add-url-functions url)))))))) (defun liece-command-browse-url (&optional url) (interactive