Function: projectile-replace--open
projectile-replace--open is a byte-compiled function defined in
projectile.el.
Signature
(projectile-replace--open MODE BUF-NAME ROOT TERM REGEXP REPLACEMENT LITERAL CASE-FOLD CANDIDATES NO-MATCH-MSG &optional WORD RG-PATTERN PROJECTS)
Documentation
Open BUF-NAME in MODE and scan CANDIDATES for REGEXP into it.
When scanning is asynchronous the buffer is shown immediately and matches stream in; when synchronous (always in batch) the scan completes first and, to preserve the pre-async behavior, no buffer is shown when nothing matched - NO-MATCH-MSG is issued instead. Returns the results buffer, or nil on the synchronous no-match path. ROOT, TERM, REGEXP, REPLACEMENT, LITERAL, CASE-FOLD, WORD, RG-PATTERN and PROJECTS seed the buffer state.
Source Code
;; Defined in ~/.emacs.d/elpa/projectile-20260820.1509/projectile.el
(defun projectile-replace--open (mode buf-name root term regexp replacement
literal case-fold candidates no-match-msg
&optional word rg-pattern projects)
"Open BUF-NAME in MODE and scan CANDIDATES for REGEXP into it.
When scanning is asynchronous the buffer is shown immediately and matches
stream in; when synchronous (always in batch) the scan completes first
and, to preserve the pre-async behavior, no buffer is shown when nothing
matched - NO-MATCH-MSG is issued instead. Returns the results buffer,
or nil on the synchronous no-match path. ROOT, TERM, REGEXP,
REPLACEMENT, LITERAL, CASE-FOLD, WORD, RG-PATTERN and PROJECTS seed the
buffer state."
;; re-running the command must not orphan a scan still filling an earlier
;; instance of the buffer (re-seeding resets its buffer-locals)
(when-let* ((existing (get-buffer buf-name)))
(with-current-buffer existing (projectile-replace--cancel-scan)))
(if (or (projectile-replace--async-p)
;; the read-only search reviewer's ripgrep fast-path is inherently
;; async, so it opens the streaming buffer even when the elisp async
;; engine is off (`projectile-search-async' nil); `--start' then
;; dispatches it to ripgrep
(and (eq mode #'projectile-search-mode)
(projectile-search--rg-fastpath-p literal rg-pattern)))
(let ((buf (get-buffer-create buf-name)))
(projectile-replace--seed buf mode root term regexp replacement
literal case-fold word rg-pattern projects)
(with-current-buffer buf
(setq projectile-replace--scanning t)
(funcall projectile-replace--render-function))
(pop-to-buffer buf)
(projectile-replace--start buf candidates regexp
#'projectile-replace--open-finish)
buf)
(let* ((case-fold-search case-fold)
(scan-regexp (if word
(projectile-replace--word-boundary-regexp regexp)
regexp))
(result (projectile-replace--gather
(projectile-replace--resolve-candidates candidates) scan-regexp))
(matches (plist-get result :matches))
(truncated (plist-get result :truncated)))
(if (null matches)
(progn (when no-match-msg (message "%s" no-match-msg)) nil)
(let ((buf (get-buffer-create buf-name)))
(projectile-replace--seed buf mode root term regexp replacement
literal case-fold word rg-pattern projects)
(with-current-buffer buf
(setq projectile-replace--matches matches
projectile-replace--truncated truncated)
(funcall projectile-replace--render-function))
(when truncated
(message "%s"
(projectile-prepend-project-name
(format "showing the first %d matches"
projectile-search-max-matches))))
(pop-to-buffer buf)
buf)))))