summaryrefslogtreecommitdiff
path: root/lisp/find-file.el
diff options
context:
space:
mode:
authorThien-Thi Nguyen <ttn@gnuvola.org>2006-07-16 21:08:28 +0000
committerThien-Thi Nguyen <ttn@gnuvola.org>2006-07-16 21:08:28 +0000
commit7365aa8be1aec39f60512f7b84262f5e022f63cf (patch)
tree06434ac9f151842f296bdb94aa0109bc74cc1a54 /lisp/find-file.el
parentece35e15a7e73189b45b7c2d2fddcd6f46b0476f (diff)
downloademacs-7365aa8be1aec39f60512f7b84262f5e022f63cf.tar.gz
(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.
Diffstat (limited to 'lisp/find-file.el')
-rw-r--r--lisp/find-file.el52
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'."
;; C/C++ include, for NeXTSTEP too
("^\#\\s *\\(include\\|import\\)\\s +[<\"]\\(.*\\)[>\"]" .
(lambda ()
- (setq fname (buffer-substring (match-beginning 2) (match-end 2)))))
+ (buffer-substring (match-beginning 2) (match-end 2))))
)
- "*A list of regular expressions for `ff-find-file'.
-Specifies how to recognize special constructs such as include files
-etc. and an associated method for extracting the filename from that
-construct.")
+ ;; We include `ff-treat-as-special' documentation here so that autoload
+ ;; can make it available to be read prior to loading this file.
+ "*List of special constructs for `ff-treat-as-special' to recognize.
+Each element, tried in order, has the form (REGEXP . EXTRACT).
+If REGEXP matches the current line (from the beginning of the line),
+`ff-treat-as-special' calls function EXTRACT with no args.
+If EXTRACT returns nil, keep trying. Otherwise, return the
+filename that EXTRACT returned.")
(defvaralias 'ff-related-file-alist 'ff-other-file-alist)
(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."
(ff-list-replace-env-vars (symbol-value ff-search-directories))
(ff-list-replace-env-vars ff-search-directories)))
- (save-excursion
- (beginning-of-line 1)
- (setq fname (ff-treat-as-special)))
+ (setq fname (ff-treat-as-special))
(cond
((and (not ff-ignore-include) fname)
@@ -540,9 +542,7 @@ the `ff-ignore-include' variable."
(ff-list-replace-env-vars (symbol-value ff-search-directories))
(ff-list-replace-env-vars ff-search-directories)))
- (save-excursion
- (beginning-of-line 1)
- (setq fname (ff-treat-as-special)))
+ (setq fname (ff-treat-as-special))
(cond
((and (not ff-ignore-include) fname)
@@ -771,20 +771,22 @@ The value used comes from `ff-case-fold-search'."
(defun ff-treat-as-special ()
"Return the file to look for if the construct was special, else nil.
-The construct is defined in the variable `ff-special-constructs'."
- (let* (fname
- (list ff-special-constructs)
- (elem (car list))
- (regexp (car elem))
- (match (cdr elem)))
- (while (and list (not fname))
- (if (and (looking-at regexp) match)
- (setq fname (funcall match)))
- (setq list (cdr list))
- (setq elem (car list))
- (setq regexp (car elem))
- (setq match (cdr elem)))
- fname))
+See variable `ff-special-constructs'."
+ (save-excursion
+ (beginning-of-line 1)
+ (let* (fname
+ (list ff-special-constructs)
+ (elem (car list))
+ (regexp (car elem))
+ (match (cdr elem)))
+ (while (and list (not fname))
+ (if (and (looking-at regexp) match)
+ (setq fname (funcall match)))
+ (setq list (cdr list))
+ (setq elem (car list))
+ (setq regexp (car elem))
+ (setq match (cdr elem)))
+ fname)))
(defun ff-basename (string)
"Return the basename of pathname STRING."