aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhil Sainty2019-06-25 16:02:12 +0200
committerLars Ingebrigtsen2019-06-25 16:02:12 +0200
commit9e81b22113de41ba80df9c5a7aaf08a056180785 (patch)
tree0d165c0eec80b6088b4336b7d3c5d2f221bae393
parent0454bfd3313c069ca395f02ab6f377a17ff44965 (diff)
downloademacs-9e81b22113de41ba80df9c5a7aaf08a056180785.tar.gz
emacs-9e81b22113de41ba80df9c5a7aaf08a056180785.zip
Fix `goto-address-url-regexp'
* lisp/net/goto-addr.el (goto-address-uri-schemes-ignored): New variable. (goto-address-uri-schemes): Ditto. (goto-address-url-regexp): Use them to compose the final regexp. * lisp/net/goto-addr.el: The URI schemes to be recognised by `goto-address-mode' were not regexp-quoted (Bug#23343).
-rw-r--r--etc/NEWS5
-rw-r--r--lisp/net/goto-addr.el42
2 files changed, 31 insertions, 16 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 101b7f5b7bb..eac7a7f6947 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -475,6 +475,11 @@ current and the previous or the next line, as before.
475 475
476* Changes in Specialized Modes and Packages in Emacs 27.1 476* Changes in Specialized Modes and Packages in Emacs 27.1
477 477
478** goto-addr
479*** A way to more conveniently specify what URI address schemes that
480should be ignored have been added via the
481`goto-address-uri-schemes-ignored' variable.
482
478** tex-mode 483** tex-mode
479*** 'latex-noindent-commands' stops indenting arguments of \emph and friends 484*** 'latex-noindent-commands' stops indenting arguments of \emph and friends
480 485
diff --git a/lisp/net/goto-addr.el b/lisp/net/goto-addr.el
index af2b83653dd..eaa1356955a 100644
--- a/lisp/net/goto-addr.el
+++ b/lisp/net/goto-addr.el
@@ -59,6 +59,7 @@
59 59
60;;; Code: 60;;; Code:
61 61
62(require 'seq)
62(require 'thingatpt) 63(require 'thingatpt)
63(autoload 'browse-url-url-at-point "browse-url") 64(autoload 'browse-url-url-at-point "browse-url")
64 65
@@ -101,23 +102,32 @@ A value of t means there is no limit--fontify regardless of the size."
101 "[-a-zA-Z0-9=._+]+@\\([-a-zA-Z0-9_]+\\.\\)+[a-zA-Z0-9]+" 102 "[-a-zA-Z0-9=._+]+@\\([-a-zA-Z0-9_]+\\.\\)+[a-zA-Z0-9]+"
102 "A regular expression probably matching an e-mail address.") 103 "A regular expression probably matching an e-mail address.")
103 104
105(defvar goto-address-uri-schemes-ignored
106 ;; By default we exclude `mailto:' (email addresses are matched
107 ;; by `goto-address-mail-regexp') and also `data:', as it is not
108 ;; terribly useful to follow those URIs, and leaving them causes
109 ;; `use Data::Dumper;' to be fontified oddly in Perl files.
110 '("mailto:" "data:")
111 "List of URI schemes to exclude from `goto-address-uri-schemes'.
112
113Customisations to this variable made after goto-addr is loaded
114will have no effect.")
115
116(defvar goto-address-uri-schemes
117 ;; We use `thing-at-point-uri-schemes', with a few exclusions,
118 ;; as listed in `goto-address-uri-schemes-ignored'.
119 (seq-reduce (lambda (accum elt) (delete elt accum))
120 goto-address-uri-schemes-ignored
121 (copy-sequence thing-at-point-uri-schemes))
122 "List of URI schemes matched by `goto-address-url-regexp'.
123
124Customisations to this variable made after goto-addr is loaded
125will have no effect.")
126
104(defvar goto-address-url-regexp 127(defvar goto-address-url-regexp
105 (concat 128 (concat "\\<"
106 "\\<\\(" 129 (regexp-opt goto-address-uri-schemes t)
107 (mapconcat 'identity 130 thing-at-point-url-path-regexp)
108 (delete "mailto:"
109 ;; Remove `data:', as it's not terribly useful to follow
110 ;; those. Leaving them causes `use Data::Dumper;' to be
111 ;; fontified oddly in Perl files.
112 (delete "data:"
113 (copy-sequence thing-at-point-uri-schemes)))
114 "\\|")
115 "\\)"
116 thing-at-point-url-path-regexp)
117 ;; (concat "\\b\\(s?https?\\|ftp\\|file\\|gopher\\|news\\|"
118 ;; "telnet\\|wais\\):\\(//[-a-zA-Z0-9_.]+:"
119 ;; "[0-9]*\\)?[-a-zA-Z0-9_=?#$@~`%&*+|\\/.,]*"
120 ;; "[-a-zA-Z0-9_=#$@~`%&*+|\\/]")
121 "A regular expression probably matching a URL.") 131 "A regular expression probably matching a URL.")
122 132
123(defvar goto-address-highlight-keymap 133(defvar goto-address-highlight-keymap