Function: TeX-search-files-by-type

TeX-search-files-by-type is a byte-compiled function defined in tex.el.

Signature

(TeX-search-files-by-type FILETYPE &optional SCOPE NODIR STRIP EXTRA-DIRS)

Documentation

Return a list of files in TeX's search path with type FILETYPE.

FILETYPE is a symbol used to choose the search paths and extensions. See TeX-search-files-type-alist for supported symbols.

The optional argument SCOPE sets the scope for the search. Besides nil the symbols local and global are accepted. local means to search in the current directory only, global in the global directories only and nil in both.

If optional argument NODIR is non-nil, remove directory part.

If optional argument STRIP is non-nil, remove file extension.

The optional argument EXTRA-DIRS is passed to TeX-search-files-kpathsea.

Source Code

;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/tex.el
(defun TeX-search-files-by-type (filetype &optional scope nodir strip extra-dirs)
  "Return a list of files in TeX's search path with type FILETYPE.
FILETYPE is a symbol used to choose the search paths and
extensions.  See `TeX-search-files-type-alist' for supported
symbols.

The optional argument SCOPE sets the scope for the search.
Besides nil the symbols `local' and `global' are accepted.
`local' means to search in the current directory only, `global'
in the global directories only and nil in both.

If optional argument NODIR is non-nil, remove directory part.

If optional argument STRIP is non-nil, remove file extension.

The optional argument EXTRA-DIRS is passed to `TeX-search-files-kpathsea'."
  (let* ((gc-cons-threshold 10000000)
         (spec (assq filetype TeX-search-files-type-alist))
         (kpse-var (nth 1 spec))
         (rawdirs (nth 2 spec))
         (exts (nth 3 spec))
         expdirs dirs local-files)
    (setq exts (if (symbolp exts) (eval exts t) exts))
    (or (TeX-search-files-kpathsea kpse-var exts scope nodir strip extra-dirs)
        (progn
          (unless (eq scope 'global)
            (setq local-files
                  (let ((TeX-file-recurse nil))
                    (TeX-search-files '("./") exts nodir strip))))
          (if (eq scope 'local)
              local-files
            (if (null TeX-tree-roots)
                (error "No TeX trees available; configure `TeX-tree-roots'")
              ;; Expand variables.
              (setq expdirs
                    ;; Don't use `delete-dups' instead of
                    ;; `TeX-delete-duplicate-strings' here.
                    ;; Otherwise, when the last element of `rawdirs'
                    ;; is a variable, its value might be truncated as
                    ;; side effect.
                    (TeX-delete-duplicate-strings
                     (apply #'append
                            (mapcar (lambda (rawdir)
                                      (if (symbolp rawdir)
                                          (symbol-value rawdir)
                                        (list rawdir)))
                                    rawdirs))))
              ;; Assumption: Either all paths are absolute or all are relative.
              (if (file-name-absolute-p (car expdirs))
                  (setq dirs expdirs)
                ;; Append relative TDS subdirs to all TeX tree roots.
                (dolist (root TeX-tree-roots)
                  (dolist (dir expdirs)
                    (let ((dir (expand-file-name dir root)))
                      (unless (member dir dirs)
                        (setq dirs (append dirs (list dir)))))))))
            (append local-files (TeX-search-files dirs exts nodir strip)))))))