doomemacs/lisp/lib/strings.el
Henrik Lissner 481753bd5e
refactor!: remove pcre2el package
BREAKING CHANGE: This removes the pcre2el package, which Doom was using
solely for one function to escape PCREs. In the interest of thinning out
Doom's core, I've hoisted a simpler version of the function into Doom's
stdlib so I can remove the dependency.
2024-07-01 18:11:34 -04:00

15 lines
407 B
EmacsLisp

;;; lisp/lib/strings.el -*- lexical-binding: t; -*-
;;;###autoload
(defun doom-pcre-quote (str)
"Like `reqexp-quote', but for PCREs."
(let ((special '(?. ?^ ?$ ?* ?+ ?? ?{ ?\\ ?\[ ?\| ?\())
(quoted nil))
(mapc (lambda (c)
(when (memq c special)
(push ?\\ quoted))
(push c quoted))
str)
(concat (nreverse quoted))))
;;; end of strings.el