From: Phil Sainty <psainty@orcon.net.nz>
To: 23343@debbugs.gnu.org
Subject: bug#23343: 25.0.93; [PATCH] URI schemes are not regexp-quoted for `goto-address-url-regexp'
Date: Sun, 24 Apr 2016 02:02:40 +1200 [thread overview]
Message-ID: <571B8080.90009@orcon.net.nz> (raw)
In-Reply-To: <571B7DCC.5090506@orcon.net.nz>
[-- Attachment #1: Type: text/plain, Size: 285 bytes --]
This could be resolved with
- (mapconcat 'identity
+ (mapconcat 'regexp-quote
But on account of
http://stackoverflow.com/questions/36787889/how-to-remove-some-link-type-in-emacs
I thought that making it easier to customise this feature was a useful
improvement to make.
-Phil
[-- Attachment #2: 0001-Fix-goto-address-url-regexp.patch --]
[-- Type: text/x-patch, Size: 2558 bytes --]
From 0d7a39a1c56700020127c01a622d13c27aec498d Mon Sep 17 00:00:00 2001
From: Phil Sainty <psainty@orcon.net.nz>
Date: Sun, 24 Apr 2016 01:40:47 +1200
Subject: [PATCH] Fix `goto-address-url-regexp'
* lisp/net/goto-addr.el: The URI schemes to be recognised by
`goto-address-mode' were not regexp-quoted. (Bug#23343)
---
lisp/net/goto-addr.el | 36 ++++++++++++++++++++----------------
1 file changed, 20 insertions(+), 16 deletions(-)
diff --git a/lisp/net/goto-addr.el b/lisp/net/goto-addr.el
index bc3c403..e4bbf76 100644
--- a/lisp/net/goto-addr.el
+++ b/lisp/net/goto-addr.el
@@ -59,6 +59,7 @@
;;; Code:
+(require 'seq)
(require 'thingatpt)
(autoload 'browse-url-url-at-point "browse-url")
@@ -101,23 +102,26 @@ goto-address-mail-regexp
"[-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'.")
+
+(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'.")
+
(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
--
2.8.0
next prev parent reply other threads:[~2016-04-23 14:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-23 13:51 bug#23343: 25.0.93; URI schemes are not regexp-quoted for `goto-address-url-regexp' Phil Sainty
2016-04-23 14:02 ` Phil Sainty [this message]
2016-04-23 22:48 ` bug#23343: 25.0.93; [PATCH] " Phil Sainty
2016-04-24 11:36 ` Lars Magne Ingebrigtsen
2016-04-24 13:48 ` Phil Sainty
2019-06-25 14:02 ` Lars Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=571B8080.90009@orcon.net.nz \
--to=psainty@orcon.net.nz \
--cc=23343@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).