Function: projectile-todos--rg-quote
projectile-todos--rg-quote is a byte-compiled function defined in
projectile.el.
Signature
(projectile-todos--rg-quote KEYWORD)
Documentation
Quote KEYWORD for ripgrep's regex syntax.
Every character that is not alphanumeric or an underscore is escaped, so
a keyword carrying punctuation (@TODO, TODO?) stays literal in Rust
regex syntax, where more characters are special than in Emacs'.
Source Code
;; Defined in ~/.emacs.d/elpa/projectile-20260820.1509/projectile.el
;;; Project-wide TODO/FIXME annotations
;;
;; `projectile-todos' is a thin command on top of the read-only search
;; reviewer above: it builds one regexp out of `projectile-todo-keywords' and
;; opens the very same `*projectile-search*' buffer, so grouping by file,
;; navigation, the keep/flush filters, re-search, the grep-mode export and the
;; hand-off to the replace reviewer all come for free.
;;
;; The keyword regexp is fenced the way hl-todo and magit-todos fence theirs:
;; the keyword must start at a word boundary and be followed by a colon,
;; whitespace or the end of the line, so `TODO:' and `FIXME ' are hits while
;; `TODOS' and `MASTODON' are not. Requiring a comment character in front is
;; deliberately NOT done: neither scan parses the language, and the comment
;; syntax would have to be guessed per file type, so an annotation in a string
;; or in prose is reported too (cheap to filter out with `d' in the buffer).
;;
;; Because a big repo is exactly where a pure-elisp scan hurts, the command
;; also hands the reviewer a ripgrep-syntax spelling of the same pattern
;; (`projectile-replace--rg-pattern'), which lets the otherwise literal-only
;; ripgrep fast-path run for this non-literal search. The two spellings agree
;; except at underscores (rg's `\b' counts `_' as a word character, Emacs'
;; word boundaries do not), which only shows up for identifiers like
;; `TODO_LIST'.
(defun projectile-todos--rg-quote (keyword)
"Quote KEYWORD for ripgrep's regex syntax.
Every character that is not alphanumeric or an underscore is escaped, so
a keyword carrying punctuation (`@TODO', `TODO?') stays literal in Rust
regex syntax, where more characters are special than in Emacs'."
(replace-regexp-in-string "[^[:alnum:]_]" "\\\\\\&" keyword t))