Function: tuareg--other-file

tuareg--other-file is a natively compiled function defined in tuareg.el.

Signature

(tuareg--other-file FILENAME)

Documentation

Given a FILENAME "foo.ml", return "foo.mli" if it exists.

Return nil otherwise.

Source Code

;; Defined in /nix/store/6mbh851dhnag8f92qfrlh9ckldzwf6c6-emacs-packages-deps/share/emacs/site-lisp/elpa/tuareg-20260626.936/tuareg.el
(defun tuareg--other-file (filename)
  "Given a FILENAME \"foo.ml\", return \"foo.mli\" if it exists.
Return nil otherwise."
  ;; FIXME: Share code with `tuareg-find-alternate-file'.
  (when filename
    (catch 'found
      (let* ((file-no-ext (file-name-sans-extension filename))
             (matching-exts
              (catch 'found
                (pcase-dolist (`(,rx ,exts) tuareg-other-file-alist)
                  (when (string-match-p rx filename) (throw 'found exts))))))
        (dolist (ext matching-exts)
          (when (file-exists-p (concat file-no-ext ext))
            (throw 'found (substring ext 1))))))))