Function: projectile--embark-project-file-target

projectile--embark-project-file-target is a byte-compiled function defined in projectile.el.

Signature

(projectile--embark-project-file-target TARGET)

Documentation

Resolve a project-file TARGET to an absolute path under the Projectile root.

Return (file . ABSOLUTE) only when TARGET actually exists under the current Projectile project root, otherwise nil so the caller can defer to Embark's own project-file handling. The existence guard keeps the integration from ever misresolving a project-file candidate that is not Projectile's - worst case it does nothing and Embark behaves as before.

Source Code

;; Defined in ~/.emacs.d/elpa/projectile-20260820.1509/projectile.el
;;; Optional Embark / Marginalia integration
;;
;; Gated behind `with-eval-after-load' so Embark and Marginalia stay soft,
;; opt-in enhancements rather than dependencies.  Two Embark wins on top of the
;; completion categories Projectile already advertises:
;;
;; 1. A transformer that expands a `project-file' candidate (which Projectile
;;    presents project-relative) to an absolute path against the Projectile
;;    root, so Embark's file actions hit the right file regardless of
;;    `default-directory'.
;; 2. A `projectile-project' action keymap, so acting on a project candidate
;;    offers project operations (switch, vc, dired, remove) instead of only
;;    generic file actions.  Marginalia keeps annotating those candidates via
;;    the built-in file annotator (they are directory paths).
;;
;; The `projectile-worktree' category gets the same Embark actions but is
;; deliberately left out of the Marginalia registry: those candidates carry
;; their own `annotation-function' naming what each worktree has checked
;; out, and a registered annotator would take precedence over it.

(defun projectile--embark-project-file-target (target)
  "Resolve a `project-file' TARGET to an absolute path under the Projectile root.
Return (file . ABSOLUTE) only when TARGET actually exists under the
current Projectile project root, otherwise nil so the caller can defer to
Embark's own `project-file' handling.  The existence guard keeps the
integration from ever misresolving a `project-file' candidate that is not
Projectile's - worst case it does nothing and Embark behaves as before."
  (when-let* ((root (projectile-project-root))
              (full (expand-file-name target root))
              ((file-exists-p full)))
    (cons 'file full)))