X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/1c66d9fb23c8dd7618d38853cfde9d4e3616ccd5..937640a621a4ce2e5e56eaecca37a2a28a584318:/lisp/net/goto-addr.el?ds=sidebyside diff --git a/lisp/net/goto-addr.el b/lisp/net/goto-addr.el index bb75508935..428da8cbe8 100644 --- a/lisp/net/goto-addr.el +++ b/lisp/net/goto-addr.el @@ -80,7 +80,7 @@ :group 'hypermedia) -;;; I don't expect users to want fontify'ing without highlighting. +;; I don't expect users to want fontify'ing without highlighting. (defcustom goto-address-fontify-p t "*Non-nil means URLs and e-mail addresses in buffer are fontified. But only if `goto-address-highlight-p' is also non-nil." @@ -93,19 +93,27 @@ But only if `goto-address-highlight-p' is also non-nil." :group 'goto-address) (defcustom goto-address-fontify-maximum-size 30000 - "*Maximum size of file in which to fontify and/or highlight URLs." - :type 'integer + "*Maximum size of file in which to fontify and/or highlight URLs. +A value of t means there is no limit--fontify regardless of the size." + :type '(choice (integer :tag "Maximum size") (const :tag "No limit" t)) :group 'goto-address) (defvar goto-address-mail-regexp - "[-a-zA-Z0-9._]+@\\([-a-zA-z0-9_]+\\.\\)+[a-zA-Z0-9]+" + ;; 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 regular expression probably matching an e-mail address.") -(defvar goto-address-url-regexp thing-at-point-url-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_=#$@~`%&*+|\\/]") +(defvar goto-address-url-regexp + (concat "\\<\\(" + (mapconcat 'identity + (delete "mailto:" (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_=#$@~`%&*+|\\/]") "A regular expression probably matching a URL.") (defvar goto-address-highlight-keymap @@ -148,7 +156,8 @@ and `goto-address-fontify-p'." (save-excursion (let ((inhibit-point-motion-hooks t)) (goto-char (point-min)) - (if (< (- (point-max) (point)) goto-address-fontify-maximum-size) + (if (or (eq t goto-address-fontify-maximum-size) + (< (- (point-max) (point)) goto-address-fontify-maximum-size)) (progn (while (re-search-forward goto-address-url-regexp nil t) (let* ((s (match-beginning 0)) @@ -159,7 +168,7 @@ and `goto-address-fontify-p'." (overlay-put this-overlay 'mouse-face goto-address-url-mouse-face) (overlay-put this-overlay - 'help-echo "mouse-2: follow URL") + 'help-echo "mouse-2, C-c RET: follow URL") (overlay-put this-overlay 'keymap goto-address-highlight-keymap) (overlay-put this-overlay 'goto-address t))) @@ -173,13 +182,13 @@ and `goto-address-fontify-p'." (overlay-put this-overlay 'mouse-face goto-address-mail-mouse-face) (overlay-put this-overlay - 'help-echo "mouse-2: mail this address") + 'help-echo "mouse-2, C-c RET: mail this address") (overlay-put this-overlay 'keymap goto-address-highlight-keymap) (overlay-put this-overlay 'goto-address t)))))))) -;;; code to find and goto addresses; much of this has been blatantly -;;; snarfed from browse-url.el +;; code to find and goto addresses; much of this has been blatantly +;; snarfed from browse-url.el ;;;###autoload (defun goto-address-at-mouse (event) @@ -201,7 +210,7 @@ there, then load the URL at or before point." (interactive) (save-excursion (let ((address (save-excursion (goto-address-find-address-at-point)))) - (if (and address + (if (and address (save-excursion (goto-char (previous-single-char-property-change (point) 'goto-address nil @@ -239,4 +248,5 @@ Also fontifies the buffer appropriately (see `goto-address-fontify-p' and (provide 'goto-addr) -;;; goto-addr.el ends here. +;;; arch-tag: ca47c505-5661-425d-a471-62bc6e75cf0a +;;; goto-addr.el ends here