Function: TeX-search-files-kpathsea

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

Signature

(TeX-search-files-kpathsea VAR EXTENSIONS SCOPE NODIR STRIP &optional EXTRA-DIRS)

Documentation

Return a list of files in directories determined by expanding VAR.

Only files which match EXTENSIONS are returned. SCOPE defines the scope for the search and can be local or global besides nil. If NODIR is non-nil, remove directory part. If STRIP is non-nil, remove file extension. If SCOPE is local and the optional argument EXTRA-DIRS is passed, it is appended to the list of local directories to search. In global scope, EXTRA-DIRS does nothing.

Source Code

;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/tex.el
;; We keep this function in addition to `TeX-search-files' because it
;; is faster.  Since it does not look further into subdirectories,
;; this comes at the price of finding a smaller number of files.
(defun TeX-search-files-kpathsea (var extensions scope nodir strip &optional extra-dirs)
  "Return a list of files in directories determined by expanding VAR.
Only files which match EXTENSIONS are returned.  SCOPE defines
the scope for the search and can be `local' or `global' besides
nil.  If NODIR is non-nil, remove directory part.  If STRIP is
non-nil, remove file extension.
If SCOPE is `local' and the optional argument EXTRA-DIRS is passed, it
is appended to the list of local directories to search.  In `global'
scope, EXTRA-DIRS does nothing."
  (when TeX-kpathsea-path-delimiter
    (let ((dirs (if (eq scope 'local)
                    (cons "./" extra-dirs)
                  (TeX-tree-expand (list var) nil)))
          result)
      (if (eq scope 'global)
          (setq dirs (delete "./" dirs)))
      (setq extensions (concat "\\.\\(?:"
                               (mapconcat #'identity extensions "\\|")
                               "\\)\\'")
            result (apply #'append (mapcar (lambda (x)
                                             (when (file-readable-p x)
                                               (directory-files
                                                x (not nodir) extensions t)))
                                           dirs)))
      (if strip
          (mapcar (lambda (x)
                    (if (string-match extensions x)
                        (substring x 0 (match-beginning 0))
                      x))
                  result)
        result))))