diff options
Diffstat (limited to 'lisp/net/goto-addr.el')
-rw-r--r-- | lisp/net/goto-addr.el | 68 |
1 files changed, 30 insertions, 38 deletions
diff --git a/lisp/net/goto-addr.el b/lisp/net/goto-addr.el index 45627d9b103..40a067e6251 100644 --- a/lisp/net/goto-addr.el +++ b/lisp/net/goto-addr.el @@ -59,19 +59,10 @@ ;;; Code: +(require 'seq) (require 'thingatpt) (autoload 'browse-url-url-at-point "browse-url") -;; XEmacs needs the following definitions. -(unless (fboundp 'overlays-in) - (require 'overlay)) -(unless (fboundp 'line-beginning-position) - (defalias 'line-beginning-position 'point-at-bol)) -(unless (fboundp 'line-end-position) - (defalias 'line-end-position 'point-at-eol)) -(unless (fboundp 'match-string-no-properties) - (defalias 'match-string-no-properties 'match-string)) - (defgroup goto-address nil "Click to browse URL or to send to e-mail address." :group 'mouse @@ -98,32 +89,40 @@ A value of t means there is no limit--fontify regardless of the size." (defvar goto-address-mail-regexp ;; Actually pretty much any char could appear in the username part. -stef - "[-a-zA-Z0-9=._+]+@\\([-a-zA-z0-9_]+\\.\\)+[a-zA-Z0-9]+" + "[-a-zA-Z0-9=._+]+@\\([-a-zA-Z0-9_]+\\.\\)+[a-zA-Z0-9]+" "A regular expression probably matching an e-mail address.") +(defvar goto-address-uri-schemes-ignored + ;; By default we exclude `mailto:' (email addresses are matched + ;; by `goto-address-mail-regexp') and also `data:', as it is not + ;; terribly useful to follow those URIs, and leaving them causes + ;; `use Data::Dumper;' to be fontified oddly in Perl files. + '("mailto:" "data:") + "List of URI schemes to exclude from `goto-address-uri-schemes'. + +Customisations to this variable made after goto-addr is loaded +will have no effect.") + +(defvar goto-address-uri-schemes + ;; We use `thing-at-point-uri-schemes', with a few exclusions, + ;; as listed in `goto-address-uri-schemes-ignored'. + (seq-reduce (lambda (accum elt) (delete elt accum)) + goto-address-uri-schemes-ignored + (copy-sequence thing-at-point-uri-schemes)) + "List of URI schemes matched by `goto-address-url-regexp'. + +Customisations to this variable made after goto-addr is loaded +will have no effect.") + (defvar goto-address-url-regexp - (concat - "\\<\\(" - (mapconcat 'identity - (delete "mailto:" - ;; Remove `data:', as it's not terribly useful to follow - ;; those. Leaving them causes `use Data::Dumper;' to be - ;; fontified oddly in Perl files. - (delete "data:" - (copy-sequence thing-at-point-uri-schemes))) - "\\|") - "\\)" - thing-at-point-url-path-regexp) - ;; (concat "\\b\\(s?https?\\|ftp\\|file\\|gopher\\|news\\|" - ;; "telnet\\|wais\\):\\(//[-a-zA-Z0-9_.]+:" - ;; "[0-9]*\\)?[-a-zA-Z0-9_=?#$@~`%&*+|\\/.,]*" - ;; "[-a-zA-Z0-9_=#$@~`%&*+|\\/]") + (concat "\\<" + (regexp-opt goto-address-uri-schemes t) + thing-at-point-url-path-regexp) "A regular expression probably matching a URL.") (defvar goto-address-highlight-keymap (let ((m (make-sparse-keymap))) - (define-key m (if (featurep 'xemacs) (kbd "<button2>") (kbd "<mouse-2>")) - 'goto-address-at-point) + (define-key m (kbd "<mouse-2>") 'goto-address-at-point) (define-key m (kbd "C-c RET") 'goto-address-at-point) m) "Keymap to hold goto-addr's mouse key defs under highlighted URLs.") @@ -221,10 +220,6 @@ and `goto-address-fontify-p'." ;; snarfed from browse-url.el ;;;###autoload -(define-obsolete-function-alias - 'goto-address-at-mouse 'goto-address-at-point "22.1") - -;;;###autoload (defun goto-address-at-point (&optional event) "Send to the e-mail address or load the URL at point. Send mail to address at point. See documentation for @@ -250,7 +245,7 @@ there, then load the URL at or before point." "Find e-mail address around or before point. Then search backwards to beginning of line for the start of an e-mail address. If no e-mail address found, return nil." - (re-search-backward "[^-_A-z0-9.@]" (line-beginning-position) 'lim) + (re-search-backward "[^-_A-Za-z0-9.@]" (line-beginning-position) 'lim) (if (or (looking-at goto-address-mail-regexp) ; already at start (and (re-search-forward goto-address-mail-regexp (line-end-position) 'lim) @@ -274,10 +269,7 @@ Also fontifies the buffer appropriately (see `goto-address-fontify-p' and ;;;###autoload (define-minor-mode goto-address-mode - "Minor mode to buttonize URLs and e-mail addresses in the current buffer. -With a prefix argument ARG, enable the mode if ARG is positive, -and disable it otherwise. If called from Lisp, enable the mode -if ARG is omitted or nil." + "Minor mode to buttonize URLs and e-mail addresses in the current buffer." nil "" nil |