]> code.delx.au - gnu-emacs/blobdiff - lisp/find-file.el
(mac-ae-open-documents, mac-drag-n-drop): Use
[gnu-emacs] / lisp / find-file.el
index 79ff1a6ab47a9e2a1f8d3d45ee058366bba14949..e15d6e62b0b078fe5b554a65f262b4db71fc746c 100644 (file)
@@ -4,7 +4,8 @@
 ;; Maintainer: FSF
 ;; Keywords: c, matching, tools
 
-;; Copyright (C) 1994, 1995, 2002 Free Software Foundation, Inc.
+;; Copyright (C) 1994, 1995, 2002, 2003, 2004,
+;;   2005, 2006 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
@@ -20,8 +21,8 @@
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 ;;; Commentary:
 
@@ -57,7 +58,7 @@
 ;; format above can be changed to include a function to be called when the
 ;; current file matches the regexp:
 ;;
-;;   '(("\\.cc$"  cc-function)
+;;   '(("\\.cc$"  cc--function)
 ;;     ("\\.hh$"  hh-function))
 ;;
 ;; These functions must return a list consisting of the possible names of the
@@ -70,9 +71,9 @@
 ;;          ("\\.hh$"  ff-cc-hh-converter)
 ;;          ("\\.c$"   (".h"))
 ;;          ("\\.h$"   (".c" ".cc" ".C" ".CC" ".cxx" ".cpp"))))
-;; 
+;;
 ;; ff-cc-hh-converter is included at the end of this file as a reference.
-;; 
+;;
 ;; SEARCHING is carried out in a set of directories specified by the
 ;; ff-search-directories variable:
 ;;
@@ -182,23 +183,16 @@ To override this, give an argument to `ff-find-other-file'."
   :type 'boolean
   :group 'ff)
 
+;;;###autoload
 (defvar ff-special-constructs
   '(
     ;; C/C++ include, for NeXTSTEP too
     ("^\#\\s *\\(include\\|import\\)\\s +[<\"]\\(.*\\)[>\"]" .
      (lambda ()
        (setq fname (buffer-substring (match-beginning 2) (match-end 2)))))
-
-    ;; Ada import
-    ("^with[ \t]+\\([a-zA-Z0-9_\\.]+\\)" .
-     (lambda ()
-       (setq fname (buffer-substring (match-beginning 1) (match-end 1)))
-       (require 'ada-mode)
-       (setq fname (concat (ada-make-filename-from-adaname fname)
-                          ada-spec-suffix))))
     )
   "*A list of regular expressions for `ff-find-file'.
-Specifies how to recognise special constructs such as include files
+Specifies how to recognize special constructs such as include files
 etc. and an associated method for extracting the filename from that
 construct.")
 
@@ -222,7 +216,7 @@ Set by default to `cc-search-directories', expanded at run-time.
 
 This list is searched through with each extension specified in
 `ff-other-file-alist' that matches this file's extension.  So the
-longer the list, the longer it'll take to realise that a file
+longer the list, the longer it'll take to realize that a file
 may not exist.
 
 A typical format is
@@ -246,22 +240,26 @@ the preceding slash.  The star represents all the subdirectories except
   :group 'ff)
 
 (defcustom cc-other-file-alist
-  '(
-    ("\\.cc$"  (".hh" ".h"))
-    ("\\.hh$"  (".cc" ".C"))
+  '(("\\.cc\\'"  (".hh" ".h"))
+    ("\\.hh\\'"  (".cc" ".C"))
 
-    ("\\.c$"   (".h"))
-    ("\\.h$"   (".c" ".cc" ".C" ".CC" ".cxx" ".cpp"))
+    ("\\.c\\'"   (".h"))
+    ("\\.h\\'"   (".c" ".cc" ".C" ".CC" ".cxx" ".cpp"))
 
-    ("\\.C$"   (".H"  ".hh" ".h"))
-    ("\\.H$"   (".C"  ".CC"))
+    ("\\.C\\'"   (".H"  ".hh" ".h"))
+    ("\\.H\\'"   (".C"  ".CC"))
 
-    ("\\.CC$"  (".HH" ".H"  ".hh" ".h"))
-    ("\\.HH$"  (".CC"))
+    ("\\.CC\\'"  (".HH" ".H"  ".hh" ".h"))
+    ("\\.HH\\'"  (".CC"))
 
-    ("\\.cxx$" (".hh" ".h"))
-    ("\\.cpp$" (".hh" ".h"))
-    )
+    ("\\.c\\+\\+\\'" (".h++" ".hh" ".h"))
+    ("\\.h\\+\\+\\'" (".c++"))
+
+    ("\\.cpp\\'" (".hpp" ".hh" ".h"))
+    ("\\.hpp\\'" (".cpp"))
+
+    ("\\.cxx\\'" (".hxx" ".hh" ".h"))
+    ("\\.hxx\\'" (".cxx")))
   "*Alist of extensions to find given the current file's extension.
 
 This list should contain the most used extensions before the others,
@@ -312,7 +310,7 @@ If optional IN-OTHER-WINDOW is non-nil, find the file in another window."
     (ff-find-the-other-file in-other-window)
     (setq ff-ignore-include ignore)))
 
-;;;###
+;;;###autoload
 (defalias 'ff-find-related-file 'ff-find-other-file)
 
 ;;;###autoload
@@ -343,7 +341,7 @@ Variables of interest include:
    If non-nil, traces which directories are being searched.
 
  - `ff-special-constructs'
-   A list of regular expressions specifying how to recognise special
+   A list of regular expressions specifying how to recognize special
    constructs such as include files etc, and an associated method for
    extracting the filename from that construct.
 
@@ -500,12 +498,12 @@ If optional IN-OTHER-WINDOW is non-nil, find the file in another window."
                    (read-file-name
                     (format "Find or create %s in: " default-name)
                     default-directory default-name nil)))
-            
+
             (setq pathname
                   (if (file-directory-p name)
                       (concat (file-name-as-directory name) default-name)
                     (setq found name)))
-            
+
             (ff-find-file pathname in-other-window t)))
 
          (t                        ;; don't create the file, just whinge
@@ -619,7 +617,7 @@ If (optional) SUFFIX-LIST is nil, search for fname, otherwise search
 for fname with each of the given suffixes.  Get the file or the buffer
 corresponding to the name of the first file found, or nil."
   (let ((filename (ff-get-file-name search-dirs filename suffix-list)))
-            
+
     (cond
      ((not filename)
       nil)
@@ -627,7 +625,7 @@ corresponding to the name of the first file found, or nil."
      ((bufferp (get-file-buffer filename))
       (ff-switch-to-buffer (get-file-buffer filename) other-window)
       filename)
-               
+
      ((file-exists-p filename)
       (ff-find-file filename other-window nil)
       filename)
@@ -659,7 +657,7 @@ name of the first file found."
         (setq this-suffix (car suffixes))
       (setq this-suffix "")
       (setq suffixes (list "")))
-            
+
     ;; find whether the file is in a buffer first
     (while (and suffixes (not found))
       (setq filename (concat fname-stub this-suffix))
@@ -693,25 +691,25 @@ name of the first file found."
       ;; if dir does not contain '/*', look for the file
       (if (and dir (not (string-match "\\([^*]*\\)/\\\*\\(/.*\\)*" dir)))
           (progn
-            
+
             ;; suffixes is nil => fname-stub is the file we are looking for
             ;; otherwise fname-stub is a stub, and we append a suffix
             (if suffixes
                 (setq this-suffix (car suffixes))
               (setq this-suffix "")
               (setq suffixes (list "")))
-            
+
             (while (and suffixes (not found))
 
               (setq filename (concat fname-stub this-suffix))
               (setq file (concat dir "/" filename))
-              
+
               (if (not ff-quiet-mode)
                   (message "Finding %s..." file))
 
               (if (file-exists-p file)
                   (setq found file))
-              
+
               (setq suffixes (cdr suffixes))
               (setq this-suffix (car suffixes))))
 
@@ -935,7 +933,7 @@ and the name of the file passed in."
         ))
      (t
       nil))
-    
+
     return-list))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -944,25 +942,19 @@ and the name of the file passed in."
 
 (defvar ff-function-name nil "Name of the function we are in.")
 
-;(eval-when-compile (require 'ada-mode))
-
 ;; bind with (setq ff-pre-load-hook 'ff-which-function-are-we-in)
 ;;
+(defvar ada-procedure-start-regexp)
+(defvar ada-package-start-regexp)
+
 (defun ff-which-function-are-we-in ()
   "Return the name of the function whose definition/declaration point is in.
 Also remember that name in `ff-function-name'."
-
-  (setq ff-function-name nil)
-
-  (save-excursion
-    (if (re-search-backward ada-procedure-start-regexp nil t)
-        (setq ff-function-name (buffer-substring (match-beginning 0)
-                                                 (match-end 0)))
-      ; we didn't find a procedure start, perhaps there is a package
-      (if (re-search-backward ada-package-start-regexp nil t)
-          (setq ff-function-name (buffer-substring (match-beginning 0)
-                                                   (match-end 0)))
-        ))))
+  (setq ff-function-name
+        (save-excursion
+          (if (or (re-search-backward ada-procedure-start-regexp nil t)
+                  (re-search-backward ada-package-start-regexp nil t))
+              (match-string 0)))))
 
 ;; bind with (setq ff-post-load-hook 'ff-set-point-accordingly)
 ;;
@@ -976,4 +968,5 @@ That name was previously determined by `ff-which-function-are-we-in'."
 
 (provide 'find-file)
 
+;; arch-tag: 5a2fc49e-3b0a-4708-9acf-fb14e471a97a
 ;;; find-file.el ends here