]> code.delx.au - gnu-emacs/blobdiff - lisp/cedet/semantic/util.el
* cedet/srecode/map.el (srecode-get-maps):
[gnu-emacs] / lisp / cedet / semantic / util.el
index 7889656bd7ed5b03e59224c9e4cb766d905120ce..c100c02fc0f869851122685ec4f625740e411767 100644 (file)
 ;; Semantic utility API for use with semantic tag tables.
 ;;
 
-(require 'assoc)
 (require 'semantic)
 
+(eval-when-compile
+  (require 'semantic/db-find)
+  ;; For semantic-find-tags-by-class, semantic--find-tags-by-function,
+  ;; and semantic-brute-find-tag-standard:
+  (require 'semantic/find))
+
 (declare-function data-debug-insert-stuff-list "data-debug")
 (declare-function data-debug-insert-thing "data-debug")
-(declare-function semanticdb-file-stream "semantic/db")
-(declare-function semanticdb-abstract-table-child-p "semantic/db")
-(declare-function semanticdb-refresh-table "semantic/db")
-(declare-function semanticdb-get-tags "semantic/db")
-(declare-function semanticdb-find-results-p "semantic/db-find")
-
-;; For semantic-find-tags-by-class, semantic--find-tags-by-function,
-;; and semantic-brute-find-tag-standard:
-(eval-when-compile (require 'semantic/find))
+(declare-function semantic-ctxt-current-symbol-and-bounds "semantic/ctxt")
 
 ;;; Code:
 
@@ -70,8 +67,7 @@ If FILE is not loaded, and semanticdb is not available, find the file
    and parse it."
   (save-match-data
     (if (find-buffer-visiting file)
-       (save-excursion
-         (set-buffer (find-buffer-visiting file))
+       (with-current-buffer (find-buffer-visiting file)
          (semantic-fetch-tags))
       ;; File not loaded
       (if (and (require 'semantic/db-mode)
@@ -79,12 +75,11 @@ If FILE is not loaded, and semanticdb is not available, find the file
          ;; semanticdb is around, use it.
          (semanticdb-file-stream file)
        ;; Get the stream ourselves.
-       (save-excursion
-         (set-buffer (find-file-noselect file))
+       (with-current-buffer (find-file-noselect file)
          (semantic-fetch-tags))))))
 
 (semantic-alias-obsolete 'semantic-file-token-stream
-                        'semantic-file-tag-table)
+                        'semantic-file-tag-table "23.2")
 
 (defun semantic-something-to-tag-table (something)
   "Convert SOMETHING into a semantic tag table.
@@ -97,14 +92,12 @@ buffer, or a filename.  If SOMETHING is nil return nil."
     something)
    ;; A buffer
    ((bufferp something)
-    (save-excursion
-      (set-buffer something)
+    (with-current-buffer something
       (semantic-fetch-tags)))
    ;; A Tag: Get that tag's buffer
    ((and (semantic-tag-with-position-p something)
         (semantic-tag-in-buffer-p something))
-    (save-excursion
-      (set-buffer (semantic-tag-buffer something))
+    (with-current-buffer (semantic-tag-buffer something)
       (semantic-fetch-tags)))
    ;; Tag with a file name in it
    ((and (semantic-tag-p something)
@@ -137,7 +130,7 @@ buffer, or a filename.  If SOMETHING is nil return nil."
    (t nil)))
 
 (semantic-alias-obsolete 'semantic-something-to-stream
-                        'semantic-something-to-tag-table)
+                        'semantic-something-to-tag-table "23.2")
 
 ;;; Recursive searching through dependency trees
 ;;
@@ -151,8 +144,7 @@ The return item is of the form (BUFFER TOKEN) where BUFFER is the buffer
 in which TOKEN (the token found to match NAME) was found.
 
 THIS ISN'T USED IN SEMANTIC.  DELETE ME SOON."
-  (save-excursion
-    (set-buffer buffer)
+  (with-current-buffer buffer
     (let* ((stream (semantic-fetch-tags))
           (includelist (or (semantic-find-tags-by-class 'include stream)
                            "empty.silly.thing"))
@@ -161,9 +153,8 @@ THIS ISN'T USED IN SEMANTIC.  DELETE ME SOON."
       (while (and (not found) includelist)
        (let ((fn (semantic-dependency-tag-file (car includelist))))
          (if (and fn (not (member fn unfound)))
-             (save-excursion
-               (save-match-data
-                 (set-buffer (find-file-noselect fn)))
+             (with-current-buffer (save-match-data
+                                     (find-file-noselect fn))
                (message "Scanning %s" (buffer-file-name))
                (setq stream (semantic-fetch-tags))
                (setq found (semantic-find-first-tag-by-name name stream))
@@ -177,7 +168,7 @@ THIS ISN'T USED IN SEMANTIC.  DELETE ME SOON."
        (setq includelist (cdr includelist)))
       found)))
 (make-obsolete 'semantic-recursive-find-nonterminal-by-name
-              "Do not use this function.")
+              "Do not use this function." "23.2")
 
 ;;; Completion APIs
 ;;
@@ -290,8 +281,7 @@ If TAG is not specified, use the tag at point."
 (defun semantic-describe-buffer-var-helper (varsym buffer)
   "Display to standard out the value of VARSYM in BUFFER."
   (require 'data-debug)
-  (let ((value (save-excursion
-                (set-buffer buffer)
+  (let ((value (with-current-buffer buffer
                 (symbol-value varsym))))
     (cond
      ((and (consp value)
@@ -315,7 +305,8 @@ If TAG is not specified, use the tag at point."
        )
 
     (with-output-to-temp-buffer (help-buffer)
-      (help-setup-xref (list #'semantic-describe-buffer) (interactive-p))
+      (help-setup-xref (list #'semantic-describe-buffer)
+                      (called-interactively-p 'interactive))
       (with-current-buffer standard-output
        (princ "Semantic Configuration in ")
        (princ (buffer-name buff))
@@ -368,19 +359,9 @@ Argument P is the point to search from in the current buffer."
   "Display info about something under the cursor using generic methods."
   (interactive)
   (require 'semantic/find)
-  (let (
-       ;(name (thing-at-point 'symbol))
-       (strm (cdr (semantic-fetch-tags)))
+  (let ((strm (cdr (semantic-fetch-tags)))
        (res nil))
-;    (if name
-       (setq res
-;            (semantic-find-nonterminal-by-name name strm)
-;            (semantic-find-nonterminal-by-type name strm)
-;            (semantic-recursive-find-nonterminal-by-name name (current-buffer))
-             (semantic-brute-find-tag-by-position (point) strm)
-
-             )
-;      )
+    (setq res (semantic-brute-find-tag-by-position (point) strm))
     (if res
        (progn
          (pop-to-buffer "*SEMANTIC HACK RESULTS*")
@@ -459,7 +440,9 @@ This uses `semanticdb' when available."
       (error nil))
     (or result
        ;; If the analyzer fails, then go into boring completion.
-       (if (and (featurep 'semantic/db) (semanticdb-minor-mode-p))
+       (if (and (featurep 'semantic/db)
+                (semanticdb-minor-mode-p)
+                (require 'semantic/db-find))
            (semanticdb-fast-strip-find-results
             (semanticdb-deep-find-tags-for-completion prefix))
          (semantic-deep-find-tags-for-completion prefix (current-buffer))))))
@@ -469,6 +452,7 @@ This uses `semanticdb' when available."
 When called from a program, optional arg PREDICATE is a predicate
 determining which symbols are considered."
   (interactive)
+  (require 'semantic/ctxt)
   (let* ((start (car (nth 2 (semantic-ctxt-current-symbol-and-bounds
                             (point)))))
         (pattern (regexp-quote (buffer-substring start (point))))
@@ -515,4 +499,5 @@ determining which symbols are considered."
 ;;
 (require 'semantic/util-modes)
 
+;; arch-tag: eaa7808d-83b9-43fe-adf0-4fb742dcb956
 ;;; semantic/util.el ends here