From e6359f8459e20a65e7de4c5ad1b1b8ee05ea91b0 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Fri, 5 May 2023 16:53:52 +0200 Subject: rx for handle/tag regexes --- lisp/mastodon-toot.el | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'lisp/mastodon-toot.el') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 1138888..1265132 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -224,19 +224,15 @@ to also capture toots that are 'sent' but that don't successfully send.") (defvar mastodon-toot-handle-regex - (concat - ;; preceding bracket, space or bol [boundary doesn't work with @] - "\\([(\n\t ]\\|^\\)" - "\\(?2:@[0-9a-zA-Z._-]+" ; a handle - "\\(@[^ \n\t]*\\)?\\)" ; with poss domain, * = allow only @ - "\\(\\b\\|'\\)")) ; boundary or ' char + (rx (| (any ?\( "\n" "\t "" ") bol) ; preceding things + (group-n 2 (+ ?@ (* (any ?- ?_ ?. "A-Z" "a-z" "0-9" ))) ; handle + (? ?@ (* (not (any "\n" "\t" " "))))) ; optional domain + (| "'" word-boundary))) ; boundary or possessive (defvar mastodon-toot-tag-regex - (concat - ;; preceding bracket, space or bol [boundary doesn't work with #] - "\\([(\n\t ]\\|^\\)" - "\\(?2:#[0-9a-zA-Z_]+\\)" ; tag - "\\(\\b\\|'\\)")) ; boundary or ' char + (rx (| (any ?\( "\n" "\t" " ") bol) + (group-n 2 ?# (+ (any "A-Z" "a-z" "0-9"))) + (| "'" word-boundary))) ; boundary or possessive (defvar mastodon-toot-url-regex ;; adapted from ffap-url-regexp -- cgit v1.2.3