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.
This commit is contained in:
Henrik Lissner 2024-07-01 02:02:08 -04:00
parent f9dfb7e92a
commit 481753bd5e
No known key found for this signature in database
GPG key ID: B60957CA074D39A3
5 changed files with 20 additions and 6 deletions

15
lisp/lib/strings.el Normal file
View file

@ -0,0 +1,15 @@
;;; 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

View file

@ -31,7 +31,6 @@
(package! better-jumper :pin "47622213783ece37d5337dc28d33b530540fc319")
(package! dtrt-indent :pin "939c5e374ac0175bb7d561542e22e47a72d04aa8")
(package! helpful :pin "4ba24cac9fb14d5fdc32582cd947572040e82b2c")
(package! pcre2el :pin "380723b2701cceb75c266440fb8db918f3340d50")
(package! smartparens :pin "f7cf316715e5018186c226aab8242c9e5ce131c8")
(package! ws-butler :pin "e3a38d93e01014cd47bf5af4924459bd145fd7c4")

View file

@ -270,7 +270,7 @@ The point of this is to avoid Emacs locking up indexing massive file trees."
((string= substr "|")
"\\\\\\\\|")
((concat "\\\\" substr))))
(rxt-quote-pcre (doom-thing-at-point-or-region)))))
(doom-pcre-quote (doom-thing-at-point-or-region)))))
directory args
(or prompt
(format "Search project [%s]: "

View file

@ -63,7 +63,7 @@ input and search the whole buffer for it."
(consult-line
(replace-regexp-in-string
" " "\\\\ "
(rxt-quote-pcre
(doom-pcre-quote
(buffer-substring-no-properties start end))))
(call-interactively #'consult-line)))))))
@ -98,7 +98,7 @@ If prefix ARG is set, include ignored/hidden files."
"Search current project for symbol at point.
If prefix ARG is set, prompt for a known project to search from."
(interactive
(list (rxt-quote-pcre (or (doom-thing-at-point-or-region) ""))
(list (doom-pcre-quote (or (doom-thing-at-point-or-region) ""))
(let ((projectile-project-root nil))
(if current-prefix-arg
(if-let (projects (projectile-relevant-known-projects))
@ -118,7 +118,7 @@ If prefix ARG is set, prompt for a known project to search from."
"Conduct a text search in the current project for symbol at point. If prefix
ARG is set, prompt for a known project to search from."
(interactive
(list (rxt-quote-pcre (or (doom-thing-at-point-or-region) ""))))
(list (doom-pcre-quote (or (doom-thing-at-point-or-region) ""))))
(require 'org)
(+default/search-project-for-symbol-at-point
symbol org-directory))

View file

@ -238,7 +238,7 @@ This backend prefers \"just working\" over accuracy."
Uses and requires `+ivy-file-search', `+helm-file-search', or `+vertico-file-search'.
Will return nil if neither is available. These require ripgrep to be installed."
(when identifier
(let ((query (rxt-quote-pcre identifier)))
(let ((query (doom-pcre-quote identifier)))
(ignore-errors
(cond ((modulep! :completion ivy)
(+ivy-file-search :query query)