expand Howard's RX macro

This commit is contained in:
MitchMarq42 2023-01-04 11:56:13 -09:00
parent ef668dfc80
commit 46d18b6f8a

View File

@ -963,8 +963,26 @@ Return nil if DIR is not in a hugo project at all."
:config :config
(defmacro prx (&rest expressions) (defmacro prx (&rest expressions)
"Convert the rx-compatible regular EXPRESSIONS to PCRE. "Convert the rx-compatible regular EXPRESSIONS to PCRE.
Most shell applications accept Perl Compatible Regular Expressions." Most shell applications accept Perl Compatible Regular Expressions.
`(rxt-elisp-to-pcre (rx ,@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) (provide 'mitch-packages)
;;; mitch-packages.el ends here ;;; mitch-packages.el ends here