From 46d18b6f8ae8148272c184c15b3aa3315f3a88fd Mon Sep 17 00:00:00 2001 From: MitchMarq42 Date: Wed, 4 Jan 2023 11:56:13 -0900 Subject: [PATCH] expand Howard's RX macro --- lisp/mitch-packages.el | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/lisp/mitch-packages.el b/lisp/mitch-packages.el index 5a29578..37a659f 100644 --- a/lisp/mitch-packages.el +++ b/lisp/mitch-packages.el @@ -963,8 +963,26 @@ Return nil if DIR is not in a hugo project at all." :config (defmacro prx (&rest expressions) "Convert the rx-compatible regular EXPRESSIONS to PCRE. - Most shell applications accept Perl Compatible Regular Expressions." - `(rxt-elisp-to-pcre (rx ,@expressions)))) + Most shell applications accept Perl Compatible Regular Expressions. + +Taken from https://howardism.org/Technical/Emacs/eshell-why.html" + `(rx-let ((integer (1+ digit)) + (float (seq integer "." integer)) + (b256 (seq (optional (or "1" "2")) + (regexp "[0-9]\\{1,2\\}"))) + (ipaddr (seq b256 "." b256 "." b256 "." b256)) + (time (seq + digit (optional digit) + ":" (= 2 digit) (optional ":" (= 2 digit)))) + (email (seq (1+ (regexp "[^,< ]")) "@" + (1+ (seq (1+ (any alnum "-"))) ".") (1+ alnum))) + (date (seq (= 2 digit) (or "/" "-") + (= 2 digit) (or "/" "-") (= 4 digit))) + (ymd (seq (= 4 digit) (or "/" "-") + (= 2 digit) (or "/" "-") (= 2 digit))) + (uuid (seq (= 8 hex) "-" (= 3 (seq (= 4 hex) "-")) (= 12 hex))) + (guid (seq uuid))) + (rxt-elisp-to-pcre (rx ,@expressions))))) (provide 'mitch-packages) ;;; mitch-packages.el ends here