Fix `acdw/build-button-url-regexp' to rebuild on call

`rx' builds the regexp at compile time -- I need it to be built at runtime.
`rx-to-string' takes care of that for me.
This commit is contained in:
Case Duckworth 2021-05-25 17:35:40 -05:00
parent 817277405a
commit bba5214c34
1 changed files with 31 additions and 32 deletions

View File

@ -433,47 +433,46 @@ Prompt only if there are unsaved changes."
I used `xr' (not included in Emacs) to get the RX form of the
default, so I can easily splice the list into it. THIS IS
BRITTLE AF!!!"
(rx
(seq word-boundary
(group
(rx-to-string ; thanks wgreenhouse!
`(seq word-boundary
(group
(or "www."
(seq
(group
(eval (cons 'or acdw/button-protocols)))
":")))
(opt
(group "//"
(one-or-more
(any "0-9a-z" "._-"))
":"
(zero-or-more
(any "0-9"))))
(or
(seq
(one-or-more
(any "0-9a-z" "!#$%&*+,./:;=?@\\_~-" word))
"("
(one-or-more
(any "0-9a-z" "!#$%&*+,./:;=?@\\_~-" word))
(zero-or-more
(any "0-9a-z" "#$%&*+/=@\\_~-" word))
")"
(opt
(group
(or "www."
(seq
(group (or ,@acdw/button-protocols))
":")))
(opt
(group "//"
(one-or-more
(any "0-9a-z" "._-"))
":"
(zero-or-more
(any "0-9"))))
(or
(seq
(one-or-more
(any "0-9a-z" "!#$%&*+,./:;=?@\\_~-" word))
(any "0-9a-z" "#$%&*+/=@\\_~-" word)))
(seq
(one-or-more
(any "0-9a-z" "!#$%&*+,./:;=?@\\_~-" word))
(any "0-9a-z" "#$%&*+/=@\\_~-" word)))))))
"("
(one-or-more
(any "0-9a-z" "!#$%&*+,./:;=?@\\_~-" word))
(zero-or-more
(any "0-9a-z" "#$%&*+/=@\\_~-" word))
")"
(opt
(one-or-more
(any "0-9a-z" "!#$%&*+,./:;=?@\\_~-" word))
(any "0-9a-z" "#$%&*+/=@\\_~-" word)))
(seq
(one-or-more
(any "0-9a-z" "!#$%&*+,./:;=?@\\_~-" word))
(any "0-9a-z" "#$%&*+/=@\\_~-" word)))))))
(defun acdw/add-button-url-regexp-protocol (proto)
"Add PROTO to `browse-url-button-regexp'
First, add PROTO to `acdw/button-protocols'.
Then, build `browse-url-button-regexp' with the new protocol."
(add-to-list 'acdw/button-protocols proto)
(setq browse-url-button-regexp (acdw/build-button-url-regexp)))
(setq-default browse-url-button-regexp (acdw/build-button-url-regexp)))