aboutsummaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authormarty hiatt <martianhiatus [a t] riseup [d o t] net>2023-05-05 16:53:52 +0200
committermarty hiatt <martianhiatus [a t] riseup [d o t] net>2023-05-05 16:55:35 +0200
commite6359f8459e20a65e7de4c5ad1b1b8ee05ea91b0 (patch)
tree0b54baa981e4bf731cf211017bb6e70fb3f46985 /lisp
parent49750e1081201293ad55598a503a0c137cc060bd (diff)
rx for handle/tag regexes
Diffstat (limited to 'lisp')
-rw-r--r--lisp/mastodon-toot.el18
1 files changed, 7 insertions, 11 deletions
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