 (defun elisp/runfiles/handle--process-file
     (program infile buffer display &rest args)
   "Implementation of ‘process-file’ for Bazel runfiles.
-See ‘process-file’ for the meaning of PROGRAM, INFILE, BUFFER,
-DISPLAY, and ARGS."
+See Info node ‘(elisp) Synchronous Processes’ for the meaning of
+PROGRAM, INFILE, BUFFER, DISPLAY, and ARGS."
   (let ((default-directory (elisp/runfiles/transform--name default-directory)))
     (apply #'process-file
            (elisp/runfiles/transform--name program)


(defun elisp/runfiles/handle--get-file-buffer (filename)
  "Implementation of ‘get-file-buffer’ for Bazel runfiles.
See ‘get-file-buffer’ for the meaning of FILENAME."
  ;; We accept both buffers visiting FILENAME directly as well as the
  ;; transformed filename.
  (or (get-file-buffer filename)

     ;; Attempt to handle everything else in a generic way.
     (t (elisp/runfiles/handle--generic operation args)))))

(defun elisp/runfiles/handle--directory-files
    (directory full-name match-regexp nosort)
  "Implementation of ‘directory-files’ for Bazel runfiles.
See Info node ‘(elisp) Contents of Directories’ for the meaning
of DIRECTORY, FULL-NAME, MATCH-REGEXP, and NOSORT."
  (let ((files (directory-files (elisp/runfiles/transform--name directory) nil
                                match-regexp nosort)))
    (if full-name
        (mapcar (lambda (file) (expand-file-name file directory)) files)
      files)))

(defun elisp/runfiles/handle--directory-files-and-attributes
    (directory full-name match-regexp nosort id-format)
  "Implementation of ‘directory-files-and-attributes’ for Bazel runfiles.
See Info node ‘(elisp) Contents of Directories’ for the meaning
of DIRECTORY, FULL-NAME, MATCH-REGEXP, NOSORT, and ID-FORMAT."
  (let ((files (directory-files-and-attributes
                (elisp/runfiles/transform--name directory) nil
                match-regexp nosort id-format)))
    (if full-name
        (mapcar (lambda (info)
                  (setcar info (expand-file-name (car info) directory)))
                files)
      files)))

(defun elisp/runfiles/handle--expand-file-name (filename &optional directory)
  "Implementation of ‘expand-file-name’ for Bazel runfiles.
See Info node ‘(elisp) File Name Expansion’ for the meaning of
FILENAME and DIRECTORY."
  (cond ((string-prefix-p "/bazel-runfile:" filename)
         ;; Bazel runfile names are always canonical (or invalid), so return the
         ;; name as-is.
         filename)
        ((file-name-absolute-p filename)
         (expand-file-name filename "/"))
        (t (let ((directory (or directory default-directory)))
             (if (string-prefix-p "/bazel-runfile:" directory)
                 (concat (file-name-as-directory directory) filename)
               (expand-file-name filename directory))))))

(defun elisp/runfiles/handle--file-remote-p (file identification _connected)
  "Implementation of ‘file-remote-p’ for Bazel runfiles.
See Info node ‘(elisp) Magic File Names’ for the meaning of FILE
and IDENTIFICATION."
  (pcase-exhaustive file
    ((rx bos "/bazel-runfile:" (let name (* anything)) eos)
     (cl-ecase identification
