diff options
| author | Carsten Dominik | 2006-02-22 07:21:09 +0000 |
|---|---|---|
| committer | Carsten Dominik | 2006-02-22 07:21:09 +0000 |
| commit | 4af584809810fa88c6faa26f19a9d07665c30361 (patch) | |
| tree | ac4c40b29b839fdfff40abb92b4cf59bb0dc2db4 | |
| parent | ea2a0e35d95d8069b6aa0e8757518736b6896d22 (diff) | |
| download | emacs-4af584809810fa88c6faa26f19a9d07665c30361.tar.gz emacs-4af584809810fa88c6faa26f19a9d07665c30361.zip | |
(reftex-locate-file): Search all extensions if
`reftex-try-all-extensions' is set.
| -rw-r--r-- | lisp/textmodes/reftex.el | 48 |
1 files changed, 46 insertions, 2 deletions
diff --git a/lisp/textmodes/reftex.el b/lisp/textmodes/reftex.el index cb2e960225d..b8ed941fcae 100644 --- a/lisp/textmodes/reftex.el +++ b/lisp/textmodes/reftex.el | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | ;; 2006 Free Software Foundation, Inc. | 3 | ;; 2006 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | ;; Author: Carsten Dominik <dominik@science.uva.nl> | 5 | ;; Author: Carsten Dominik <dominik@science.uva.nl> |
| 6 | ;; Version: VERSIONTAG | 6 | ;; Version: 4.31 |
| 7 | ;; Keywords: tex | 7 | ;; Keywords: tex |
| 8 | 8 | ||
| 9 | ;; This file is part of GNU Emacs. | 9 | ;; This file is part of GNU Emacs. |
| @@ -301,7 +301,7 @@ | |||
| 301 | ;;; Define the formal stuff for a minor mode named RefTeX. | 301 | ;;; Define the formal stuff for a minor mode named RefTeX. |
| 302 | ;;; | 302 | ;;; |
| 303 | 303 | ||
| 304 | (defconst reftex-version "RefTeX version VERSIONTAG" | 304 | (defconst reftex-version "RefTeX version 4.31" |
| 305 | "Version string for RefTeX.") | 305 | "Version string for RefTeX.") |
| 306 | 306 | ||
| 307 | (defvar reftex-mode nil | 307 | (defvar reftex-mode nil |
| @@ -1466,6 +1466,50 @@ When DIE is non-nil, throw an error if file not found." | |||
| 1466 | (die (error "No such file: %s" file) nil) | 1466 | (die (error "No such file: %s" file) nil) |
| 1467 | (t (message "No such file: %s (ignored)" file) nil)))) | 1467 | (t (message "No such file: %s (ignored)" file) nil)))) |
| 1468 | 1468 | ||
| 1469 | |||
| 1470 | ;; FIXME: this still needs testing and thinking. | ||
| 1471 | (defun reftex-locate-file (file type master-dir &optional die) | ||
| 1472 | "Find FILE of type TYPE in MASTER-DIR or on the path associcted with TYPE. | ||
| 1473 | If the file does not have any of the valid extensions for TYPE, | ||
| 1474 | try first the default extension and only then the naked file name. | ||
| 1475 | When DIE is non-nil, throw an error if file not found." | ||
| 1476 | (let* ((rec-values (if reftex-search-unrecursed-path-first '(nil t) '(t))) | ||
| 1477 | (extensions (cdr (assoc type reftex-file-extensions))) | ||
| 1478 | (def-ext (car extensions)) | ||
| 1479 | (ext-re (concat "\\(" | ||
| 1480 | (mapconcat 'regexp-quote extensions "\\|") | ||
| 1481 | "\\)\\'")) | ||
| 1482 | (files (if (string-match ext-re file) | ||
| 1483 | (cons file nil) | ||
| 1484 | (if reftex-try-all-extensions | ||
| 1485 | (append (mapcar (lambda (x) (concat file x)) | ||
| 1486 | extensions) | ||
| 1487 | (list file)) | ||
| 1488 | (list (concat file def-ext) file)))) | ||
| 1489 | path old-path file1 f fs) | ||
| 1490 | (cond | ||
| 1491 | ((file-name-absolute-p file) | ||
| 1492 | (while (setq f (pop files)) | ||
| 1493 | (if (file-regular-p f) | ||
| 1494 | (setq file1 f files nil)))) | ||
| 1495 | ((and reftex-use-external-file-finders | ||
| 1496 | (assoc type reftex-external-file-finders)) | ||
| 1497 | (setq file1 (reftex-find-file-externally file type master-dir))) | ||
| 1498 | (t | ||
| 1499 | (while (and (null file1) rec-values) | ||
| 1500 | (setq path (reftex-access-search-path | ||
| 1501 | type (pop rec-values) master-dir file)) | ||
| 1502 | (setq fs files) | ||
| 1503 | (while (and (null file1) (setq f (pop fs))) | ||
| 1504 | (when (or (null old-path) | ||
| 1505 | (not (eq old-path path))) | ||
| 1506 | (setq old-path path | ||
| 1507 | path (cons master-dir path)) | ||
| 1508 | (setq file1 (reftex-find-file-on-path f path master-dir))))))) | ||
| 1509 | (cond (file1 file1) | ||
| 1510 | (die (error "No such file: %s" file) nil) | ||
| 1511 | (t (message "No such file: %s (ignored)" file) nil)))) | ||
| 1512 | |||
| 1469 | (defun reftex-find-file-externally (file type &optional master-dir) | 1513 | (defun reftex-find-file-externally (file type &optional master-dir) |
| 1470 | ;; Use external program to find FILE. | 1514 | ;; Use external program to find FILE. |
| 1471 | ;; The program is taken from `reftex-external-file-finders'. | 1515 | ;; The program is taken from `reftex-external-file-finders'. |