diff options
| author | Thien-Thi Nguyen | 2006-07-16 21:08:28 +0000 |
|---|---|---|
| committer | Thien-Thi Nguyen | 2006-07-16 21:08:28 +0000 |
| commit | 7365aa8be1aec39f60512f7b84262f5e022f63cf (patch) | |
| tree | 06434ac9f151842f296bdb94aa0109bc74cc1a54 | |
| parent | ece35e15a7e73189b45b7c2d2fddcd6f46b0476f (diff) | |
| download | emacs-7365aa8be1aec39f60512f7b84262f5e022f63cf.tar.gz emacs-7365aa8be1aec39f60512f7b84262f5e022f63cf.zip | |
(ff-special-constructs): Doc fix. Also, for C/C++
entry, don't assign to free var; simply return the extracted filename.
(ff-treat-as-special): Incorporate common preamble from callers.
(ff-other-file-name, ff-find-the-other-file):
Update call to ff-treat-as-special.
| -rw-r--r-- | lisp/find-file.el | 52 |
1 files changed, 27 insertions, 25 deletions
diff --git a/lisp/find-file.el b/lisp/find-file.el index e15d6e62b0b..5618ba58dbe 100644 --- a/lisp/find-file.el +++ b/lisp/find-file.el | |||
| @@ -189,12 +189,16 @@ To override this, give an argument to `ff-find-other-file'." | |||
| 189 | ;; C/C++ include, for NeXTSTEP too | 189 | ;; C/C++ include, for NeXTSTEP too |
| 190 | ("^\#\\s *\\(include\\|import\\)\\s +[<\"]\\(.*\\)[>\"]" . | 190 | ("^\#\\s *\\(include\\|import\\)\\s +[<\"]\\(.*\\)[>\"]" . |
| 191 | (lambda () | 191 | (lambda () |
| 192 | (setq fname (buffer-substring (match-beginning 2) (match-end 2))))) | 192 | (buffer-substring (match-beginning 2) (match-end 2)))) |
| 193 | ) | 193 | ) |
| 194 | "*A list of regular expressions for `ff-find-file'. | 194 | ;; We include `ff-treat-as-special' documentation here so that autoload |
| 195 | Specifies how to recognize special constructs such as include files | 195 | ;; can make it available to be read prior to loading this file. |
| 196 | etc. and an associated method for extracting the filename from that | 196 | "*List of special constructs for `ff-treat-as-special' to recognize. |
| 197 | construct.") | 197 | Each element, tried in order, has the form (REGEXP . EXTRACT). |
| 198 | If REGEXP matches the current line (from the beginning of the line), | ||
| 199 | `ff-treat-as-special' calls function EXTRACT with no args. | ||
| 200 | If EXTRACT returns nil, keep trying. Otherwise, return the | ||
| 201 | filename that EXTRACT returned.") | ||
| 198 | 202 | ||
| 199 | (defvaralias 'ff-related-file-alist 'ff-other-file-alist) | 203 | (defvaralias 'ff-related-file-alist 'ff-other-file-alist) |
| 200 | (defcustom ff-other-file-alist 'cc-other-file-alist | 204 | (defcustom ff-other-file-alist 'cc-other-file-alist |
| @@ -405,9 +409,7 @@ If optional IN-OTHER-WINDOW is non-nil, find the file in another window." | |||
| 405 | (ff-list-replace-env-vars (symbol-value ff-search-directories)) | 409 | (ff-list-replace-env-vars (symbol-value ff-search-directories)) |
| 406 | (ff-list-replace-env-vars ff-search-directories))) | 410 | (ff-list-replace-env-vars ff-search-directories))) |
| 407 | 411 | ||
| 408 | (save-excursion | 412 | (setq fname (ff-treat-as-special)) |
| 409 | (beginning-of-line 1) | ||
| 410 | (setq fname (ff-treat-as-special))) | ||
| 411 | 413 | ||
| 412 | (cond | 414 | (cond |
| 413 | ((and (not ff-ignore-include) fname) | 415 | ((and (not ff-ignore-include) fname) |
| @@ -540,9 +542,7 @@ the `ff-ignore-include' variable." | |||
| 540 | (ff-list-replace-env-vars (symbol-value ff-search-directories)) | 542 | (ff-list-replace-env-vars (symbol-value ff-search-directories)) |
| 541 | (ff-list-replace-env-vars ff-search-directories))) | 543 | (ff-list-replace-env-vars ff-search-directories))) |
| 542 | 544 | ||
| 543 | (save-excursion | 545 | (setq fname (ff-treat-as-special)) |
| 544 | (beginning-of-line 1) | ||
| 545 | (setq fname (ff-treat-as-special))) | ||
| 546 | 546 | ||
| 547 | (cond | 547 | (cond |
| 548 | ((and (not ff-ignore-include) fname) | 548 | ((and (not ff-ignore-include) fname) |
| @@ -771,20 +771,22 @@ The value used comes from `ff-case-fold-search'." | |||
| 771 | 771 | ||
| 772 | (defun ff-treat-as-special () | 772 | (defun ff-treat-as-special () |
| 773 | "Return the file to look for if the construct was special, else nil. | 773 | "Return the file to look for if the construct was special, else nil. |
| 774 | The construct is defined in the variable `ff-special-constructs'." | 774 | See variable `ff-special-constructs'." |
| 775 | (let* (fname | 775 | (save-excursion |
| 776 | (list ff-special-constructs) | 776 | (beginning-of-line 1) |
| 777 | (elem (car list)) | 777 | (let* (fname |
| 778 | (regexp (car elem)) | 778 | (list ff-special-constructs) |
| 779 | (match (cdr elem))) | 779 | (elem (car list)) |
| 780 | (while (and list (not fname)) | 780 | (regexp (car elem)) |
| 781 | (if (and (looking-at regexp) match) | 781 | (match (cdr elem))) |
| 782 | (setq fname (funcall match))) | 782 | (while (and list (not fname)) |
| 783 | (setq list (cdr list)) | 783 | (if (and (looking-at regexp) match) |
| 784 | (setq elem (car list)) | 784 | (setq fname (funcall match))) |
| 785 | (setq regexp (car elem)) | 785 | (setq list (cdr list)) |
| 786 | (setq match (cdr elem))) | 786 | (setq elem (car list)) |
| 787 | fname)) | 787 | (setq regexp (car elem)) |
| 788 | (setq match (cdr elem))) | ||
| 789 | fname))) | ||
| 788 | 790 | ||
| 789 | (defun ff-basename (string) | 791 | (defun ff-basename (string) |
| 790 | "Return the basename of pathname STRING." | 792 | "Return the basename of pathname STRING." |