Function: projectile--glob-to-regexp
projectile--glob-to-regexp is a byte-compiled function defined in
projectile.el.
Signature
(projectile--glob-to-regexp GLOB)
Documentation
Translate the dirconfig GLOB into a regexp fragment.
* matches within a path segment, ** spans segments, ? matches
a single non-slash character and [...]/[!...] character classes
pass through (with ! translated to ^).
Source Code
;; Defined in ~/.emacs.d/elpa/projectile-20260820.1509/projectile.el
(defun projectile--glob-to-regexp (glob)
"Translate the dirconfig GLOB into a regexp fragment.
`*' matches within a path segment, `**' spans segments, `?' matches
a single non-slash character and `[...]'/`[!...]' character classes
pass through (with `!' translated to `^')."
(let ((i 0) (n (length glob)) (fragments nil))
(while (< i n)
(let ((c (aref glob i)))
(cond
((eq c ?*)
(if (and (< (1+ i) n) (eq (aref glob (1+ i)) ?*))
(progn (push ".*" fragments) (setq i (1+ i)))
(push "[^/]*" fragments)))
((eq c ??) (push "[^/]" fragments))
((eq c ?\[)
;; Copy a character class through, translating glob's [!...]
;; negation; an unterminated class is treated literally.
(if-let* ((end (string-search "]" glob (+ i 2))))
(progn
(push (if (and (< (1+ i) n) (eq (aref glob (1+ i)) ?!))
(concat "[^" (substring glob (+ i 2) (1+ end)))
(substring glob i (1+ end)))
fragments)
(setq i end))
(push "\\[" fragments)))
(t (push (regexp-quote (char-to-string c)) fragments))))
(setq i (1+ i)))
(apply #'concat (nreverse fragments))))