1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-12-14 09:39:42 +00:00

(reftex-locate-file): Search all extensions if

`reftex-try-all-extensions' is set.
This commit is contained in:
Carsten Dominik 2006-02-22 07:21:09 +00:00
parent ea2a0e35d9
commit 4af5848098

View File

@ -3,7 +3,7 @@
;; 2006 Free Software Foundation, Inc. ;; 2006 Free Software Foundation, Inc.
;; Author: Carsten Dominik <dominik@science.uva.nl> ;; Author: Carsten Dominik <dominik@science.uva.nl>
;; Version: VERSIONTAG ;; Version: 4.31
;; Keywords: tex ;; Keywords: tex
;; This file is part of GNU Emacs. ;; This file is part of GNU Emacs.
@ -301,7 +301,7 @@
;;; Define the formal stuff for a minor mode named RefTeX. ;;; Define the formal stuff for a minor mode named RefTeX.
;;; ;;;
(defconst reftex-version "RefTeX version VERSIONTAG" (defconst reftex-version "RefTeX version 4.31"
"Version string for RefTeX.") "Version string for RefTeX.")
(defvar reftex-mode nil (defvar reftex-mode nil
@ -1466,6 +1466,50 @@ When DIE is non-nil, throw an error if file not found."
(die (error "No such file: %s" file) nil) (die (error "No such file: %s" file) nil)
(t (message "No such file: %s (ignored)" file) nil)))) (t (message "No such file: %s (ignored)" file) nil))))
;; FIXME: this still needs testing and thinking.
(defun reftex-locate-file (file type master-dir &optional die)
"Find FILE of type TYPE in MASTER-DIR or on the path associcted with TYPE.
If the file does not have any of the valid extensions for TYPE,
try first the default extension and only then the naked file name.
When DIE is non-nil, throw an error if file not found."
(let* ((rec-values (if reftex-search-unrecursed-path-first '(nil t) '(t)))
(extensions (cdr (assoc type reftex-file-extensions)))
(def-ext (car extensions))
(ext-re (concat "\\("
(mapconcat 'regexp-quote extensions "\\|")
"\\)\\'"))
(files (if (string-match ext-re file)
(cons file nil)
(if reftex-try-all-extensions
(append (mapcar (lambda (x) (concat file x))
extensions)
(list file))
(list (concat file def-ext) file))))
path old-path file1 f fs)
(cond
((file-name-absolute-p file)
(while (setq f (pop files))
(if (file-regular-p f)
(setq file1 f files nil))))
((and reftex-use-external-file-finders
(assoc type reftex-external-file-finders))
(setq file1 (reftex-find-file-externally file type master-dir)))
(t
(while (and (null file1) rec-values)
(setq path (reftex-access-search-path
type (pop rec-values) master-dir file))
(setq fs files)
(while (and (null file1) (setq f (pop fs)))
(when (or (null old-path)
(not (eq old-path path)))
(setq old-path path
path (cons master-dir path))
(setq file1 (reftex-find-file-on-path f path master-dir)))))))
(cond (file1 file1)
(die (error "No such file: %s" file) nil)
(t (message "No such file: %s (ignored)" file) nil))))
(defun reftex-find-file-externally (file type &optional master-dir) (defun reftex-find-file-externally (file type &optional master-dir)
;; Use external program to find FILE. ;; Use external program to find FILE.
;; The program is taken from `reftex-external-file-finders'. ;; The program is taken from `reftex-external-file-finders'.