* lisp/gnus/nnimap.el (nnimap-open-connection-1): Use tcp-keealive if possible.
[bpt/emacs.git] / lisp / cedet / semantic / tag-file.el
index 58c0aae..17fd3b4 100644 (file)
@@ -1,7 +1,6 @@
 ;;; semantic/tag-file.el --- Routines that find files based on tags.
 
-;;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007,
-;;; 2008, 2009 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2005, 2007-2011  Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <zappo@gnu.org>
 ;; Keywords: syntax
 
 (require 'semantic/tag)
 
-(declare-function semanticdb-table-child-p "semantic/db")
+(defvar ede-minor-mode)
+(declare-function semanticdb-table-child-p "semantic/db" t t)
 (declare-function semanticdb-get-buffer "semantic/db")
 (declare-function semantic-dependency-find-file-on-path "semantic/dep")
+(declare-function ede-toplevel "ede/base")
 
 ;;; Code:
 
@@ -43,29 +44,30 @@ TAG may be a stripped element, in which case PARENT specifies a
 parent tag that has position information.
 PARENT can also be a `semanticdb-table' object."
   (:override
-   (cond ((semantic-tag-in-buffer-p tag)
-         ;; We have a linked tag, go to that buffer.
-         (set-buffer (semantic-tag-buffer tag)))
-        ((semantic-tag-file-name tag)
-         ;; If it didn't have a buffer, but does have a file
-         ;; name, then we need to get to that file so the tag
-         ;; location is made accurate.
-         (set-buffer (find-file-noselect (semantic-tag-file-name tag))))
-        ((and parent (semantic-tag-p parent) (semantic-tag-in-buffer-p parent))
-         ;; The tag had nothing useful, but we have a parent with
-         ;; a buffer, then go there.
-         (set-buffer (semantic-tag-buffer parent)))
-        ((and parent (semantic-tag-p parent) (semantic-tag-file-name parent))
-         ;; Tag had nothing, and the parent only has a file-name, then
-         ;; find that file, and switch to that buffer.
-         (set-buffer (find-file-noselect (semantic-tag-file-name parent))))
-        ((and parent (featurep 'semantic/db)
-              (semanticdb-table-child-p parent))
-         (set-buffer (semanticdb-get-buffer parent)))
-        (t
-         ;; Well, just assume things are in the current buffer.
-         nil
-         ))
+   (save-match-data
+     (cond ((semantic-tag-in-buffer-p tag)
+           ;; We have a linked tag, go to that buffer.
+           (set-buffer (semantic-tag-buffer tag)))
+          ((semantic-tag-file-name tag)
+           ;; If it didn't have a buffer, but does have a file
+           ;; name, then we need to get to that file so the tag
+           ;; location is made accurate.
+           (set-buffer (find-file-noselect (semantic-tag-file-name tag))))
+          ((and parent (semantic-tag-p parent) (semantic-tag-in-buffer-p parent))
+           ;; The tag had nothing useful, but we have a parent with
+           ;; a buffer, then go there.
+           (set-buffer (semantic-tag-buffer parent)))
+          ((and parent (semantic-tag-p parent) (semantic-tag-file-name parent))
+           ;; Tag had nothing, and the parent only has a file-name, then
+           ;; find that file, and switch to that buffer.
+           (set-buffer (find-file-noselect (semantic-tag-file-name parent))))
+          ((and parent (featurep 'semantic/db)
+                (semanticdb-table-child-p parent))
+           (set-buffer (semanticdb-get-buffer parent)))
+          (t
+           ;; Well, just assume things are in the current buffer.
+           nil
+           )))
    ;; We should be in the correct buffer now, try and figure out
    ;; where the tag is.
    (cond ((semantic-tag-with-position-p tag)
@@ -84,12 +86,13 @@ PARENT can also be a `semanticdb-table' object."
                             t))
         ((semantic-tag-get-attribute tag :line)
          ;; The tag has a line number in it.  Go there.
-         (goto-line (semantic-tag-get-attribute tag :line)))
+         (goto-char (point-min))
+         (forward-line (1- (semantic-tag-get-attribute tag :line))))
         ((and (semantic-tag-p parent) (semantic-tag-get-attribute parent :line))
          ;; The tag has a line number in it.  Go there.
-         (goto-line (semantic-tag-get-attribute parent :line))
-         (re-search-forward (semantic-tag-name tag) nil t)
-         )
+         (goto-char (point-min))
+         (forward-line (1- (semantic-tag-get-attribute parent :line)))
+         (re-search-forward (semantic-tag-name tag) nil t))
         (t
          ;; Take a guess that the tag has a unique name, and just
          ;; search for it from the beginning of the buffer.
@@ -99,7 +102,7 @@ PARENT can also be a `semanticdb-table' object."
   )
 
 (make-obsolete-overload 'semantic-find-nonterminal
-                        'semantic-go-to-tag)
+                        'semantic-go-to-tag "23.2")
 
 ;;; Dependencies
 ;;
@@ -173,7 +176,7 @@ Depends on `semantic-dependency-include-path' for searching.  Always searches
       )))
 
 (make-obsolete-overload 'semantic-find-dependency
-                        'semantic-dependency-tag-file)
+                        'semantic-dependency-tag-file "23.2")
 
 ;;; PROTOTYPE FILE
 ;;
@@ -189,27 +192,24 @@ file prototypes belong in."
   (:override
    ;; Perform some default behaviors
    (if (and (fboundp 'ede-header-file) ede-minor-mode)
-       (save-excursion
-         (set-buffer buffer)
+       (with-current-buffer buffer
          (ede-header-file))
      ;; No EDE options for a quick answer.  Search.
-     (save-excursion
-       (set-buffer buffer)
+     (with-current-buffer buffer
        (if (re-search-forward "::Header:: \\([a-zA-Z0-9.]+\\)" nil t)
            (match-string 1))))))
 
 (semantic-alias-obsolete 'semantic-find-nonterminal
-                         'semantic-go-to-tag)
+                         'semantic-go-to-tag "23.2")
 
 (semantic-alias-obsolete 'semantic-find-dependency
-                         'semantic-dependency-tag-file)
+                         'semantic-dependency-tag-file "23.2")
 
 
 (provide 'semantic/tag-file)
 
 ;; Local variables:
 ;; generated-autoload-file: "loaddefs.el"
-;; generated-autoload-feature: semantic/loaddefs
 ;; generated-autoload-load-name: "semantic/tag-file"
 ;; End: