* cedet/srecode/srt-mode.el (semantic-analyze-possible-completions):
[bpt/emacs.git] / lisp / cedet / semantic / complete.el
index fce7613..9f68c9f 100644 (file)
@@ -1,7 +1,7 @@
 ;;; semantic/complete.el --- Routines for performing tag completion
 
-;;; Copyright (C) 2003, 2004, 2005, 2007, 2008, 2009
-;;; Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2004, 2005, 2007, 2008, 2009
+;;   Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <zappo@gnu.org>
 ;; Keywords: syntax
@@ -36,7 +36,7 @@
 ;; quickly without resorting to "show me every possible option now".
 ;;
 ;; In addition, some symbol names will appear in multiple locations.
-;; If it is important to distiguish, then a way to provide a choice
+;; If it is important to distinguish, then a way to provide a choice
 ;; over these locations is important as well.
 ;;
 ;; Beyond brute force offers for completion of plain strings,
@@ -55,7 +55,7 @@
 ;;
 ;; Here, we will treat each section separately (excluding D)
 ;; They can then be strung together in user-visible commands to
-;; fullfill specific needs.
+;; fulfil specific needs.
 ;;
 ;; COLLECTORS:
 ;;
 ;; `semantic-complete-inline-tag-engine' will complete text in
 ;; a buffer.
 
-(require 'eieio)
-(require 'eieio-opt)
+(eval-when-compile (require 'cl))
 (require 'semantic)
+(require 'eieio-opt)
 (require 'semantic/analyze)
 (require 'semantic/ctxt)
 (require 'semantic/decorate)
 (require 'semantic/format)
-(require 'semantic/tag)
 
 (eval-when-compile
   ;; For the semantic-find-tags-for-completion macro.
   (require 'semantic/find))
 
-(eval-when-compile
-  (condition-case nil
-      ;; Tooltip not available in older emacsen.
-      (require 'tooltip)
-    (error nil))
-  )
-
 ;;; Code:
 
-;;; Compatibility
-;;
-(if (fboundp 'minibuffer-contents)
-    (eval-and-compile (defalias 'semantic-minibuffer-contents 'minibuffer-contents))
-  (eval-and-compile (defalias 'semantic-minibuffer-contents 'buffer-string)))
-(if (fboundp 'delete-minibuffer-contents)
-    (eval-and-compile (defalias 'semantic-delete-minibuffer-contents 'delete-minibuffer-contents))
-  (eval-and-compile (defalias 'semantic-delete-minibuffer-contents 'erase-buffer)))
-
 (defvar semantic-complete-inline-overlay nil
   "The overlay currently active while completing inline.")
 
@@ -159,14 +142,14 @@ For inline completion, this is the text wrapped in the inline completion
 overlay."
   (if semantic-complete-inline-overlay
       (semantic-complete-inline-text)
-    (semantic-minibuffer-contents)))
+    (minibuffer-contents)))
 
 (defun semantic-completion-delete-text ()
   "Delete the text that is actively being completed.
 Presumably if you call this you will insert something new there."
   (if semantic-complete-inline-overlay
       (semantic-complete-inline-delete-text)
-    (semantic-delete-minibuffer-contents)))
+    (delete-minibuffer-contents)))
 
 (defun semantic-completion-message (fmt &rest args)
   "Display the string FMT formatted with ARGS at the end of the minibuffer."
@@ -212,7 +195,7 @@ Keeps STRINGS only in the history.")
 Argument COLLECTOR is an object which can be used to to calculate
 a list of possible hits.  See `semantic-completion-collector-engine'
 for details on COLLECTOR.
-Argumeng DISPLAYOR is an object used to display a list of possible
+Argument DISPLAYOR is an object used to display a list of possible
 completions for a given prefix.  See`semantic-completion-display-engine'
 for details on DISPLAYOR.
 PROMPT is a string to prompt with.
@@ -330,7 +313,8 @@ HISTORY is a symbol representing a variable to story the history in."
 ;; semantic-displayor-focus-abstract-child-p is part of the
 ;; semantic-displayor-focus-abstract class, defined later in this
 ;; file.
-(declare-function semantic-displayor-focus-abstract-child-p "semantic/complete")
+(declare-function semantic-displayor-focus-abstract-child-p "semantic/complete"
+                 t t)
 
 (defun semantic-complete-current-match ()
   "Calculate a match from the current completion environment.
@@ -753,7 +737,7 @@ DO NOT CALL THIS IF THE INLINE COMPLETION ENGINE IS NOT ACTIVE."
 Argument COLLECTOR is an object which can be used to to calculate
 a list of possible hits.  See `semantic-completion-collector-engine'
 for details on COLLECTOR.
-Argumeng DISPLAYOR is an object used to display a list of possible
+Argument DISPLAYOR is an object used to display a list of possible
 completions for a given prefix.  See`semantic-completion-display-engine'
 for details on DISPLAYOR.
 BUFFER is the buffer in which completion will take place.
@@ -963,8 +947,7 @@ Calculate the cache if there isn't one."
   "Calculate the completions for prefix from completionlist.
 Output must be in semanticdb Find result format."
   ;; Must output in semanticdb format
-  (let ((table (save-excursion
-                (set-buffer (oref obj buffer))
+  (let ((table (with-current-buffer (oref obj buffer)
                 semanticdb-current-table))
        (result (semantic-find-tags-for-completion
                 prefix
@@ -1243,8 +1226,7 @@ inserted into the current context.")
            (semantic-analyze-possible-completions (oref obj context))))
   ;; search our cached completion list.  make it look like a semanticdb
   ;; results type.
-  (list (cons (save-excursion
-               (set-buffer (oref (oref obj context) buffer))
+  (list (cons (with-current-buffer (oref (oref obj context) buffer)
                semanticdb-current-table)
              (semantic-find-tags-for-completion
               prefix
@@ -1479,8 +1461,7 @@ one in the source buffer."
                   (and table (semanticdb-get-buffer table)))))
       ;; If no buffer is provided, then we can make up a summary buffer.
       (when (not buf)
-       (save-excursion
-         (set-buffer (get-buffer-create "*Completion Focus*"))
+       (with-current-buffer (get-buffer-create "*Completion Focus*")
          (erase-buffer)
          (insert "Focus on tag: \n")
          (insert (semantic-format-tag-summarize tag nil t) "\n\n")
@@ -1783,7 +1764,7 @@ completion text in ghost text."
                     C)))
           (eieio-build-class-alist semantic-displayor-abstract t))
          )
-  "Possible options for inlince completion displayors.
+  "Possible options for inline completion displayors.
 Use this to enable custom editing.")
 
 (defcustom semantic-complete-inline-analyzer-displayor-class
@@ -1896,7 +1877,7 @@ to generate the list of possible completions.
 PROMPT is the first part of the prompt.  Additional prompt
 is added based on the contexts full prefix.
 CONTEXT is the semantic analyzer context to start with.
-HISTORY is a symbol representing a variable to stor the history in.
+HISTORY is a symbol representing a variable to store the history in.
 usually a default-tag and initial-input are available for completion
 prompts.  these are calculated from the CONTEXT variable passed in."
   (if (not context) (setq context (semantic-analyze-current-context (point))))
@@ -1909,8 +1890,7 @@ prompts.  these are calculated from the CONTEXT variable passed in."
       :buffer (oref context buffer)
       :context context)
      (semantic-displayor-traditional-with-focus-highlight "simple")
-     (save-excursion
-       (set-buffer (oref context buffer))
+     (with-current-buffer (oref context buffer)
        (goto-char (cdr (oref context bounds)))
        (concat prompt (mapconcat 'identity syms ".")
               (if syms "." "")
@@ -1993,17 +1973,7 @@ completion works."
     ))
 
 \f
-;;; ------------------------------------------------------------
-;;; Testing/Samples
-;;
-(defun semantic-complete-test ()
-  "Test completion mechanisms."
-  (interactive)
-  (message "%S"
-   (semantic-format-tag-prototype
-    (semantic-complete-read-tag-project "Symbol: ")
-    )))
-
+;;;###autoload
 (defun semantic-complete-jump-local ()
   "Jump to a semantic symbol."
   (interactive)
@@ -2016,6 +1986,7 @@ completion works."
               (semantic-tag-class tag)
               (semantic-tag-name  tag)))))
 
+;;;###autoload
 (defun semantic-complete-jump ()
   "Jump to a semantic symbol."
   (interactive)
@@ -2029,6 +2000,7 @@ completion works."
               (semantic-tag-class tag)
               (semantic-tag-name  tag)))))
 
+;;;###autoload
 (defun semantic-complete-analyze-and-replace ()
   "Perform prompt completion to do in buffer completion.
 `semantic-analyze-possible-completions' is used to determine the
@@ -2044,6 +2016,7 @@ The result is inserted as a replacement of the text that was there."
     (insert (semantic-tag-name tag))
     (message "%S" (semantic-format-tag-summarize tag))))
 
+;;;###autoload
 (defun semantic-complete-analyze-inline ()
   "Perform prompt completion to do in buffer completion.
 `semantic-analyze-possible-completions' is used to determine the
@@ -2066,6 +2039,7 @@ how completion options are displayed."
     (semantic-complete-inline-TAB)
     ))
 
+;;;###autoload
 (defun semantic-complete-analyze-inline-idle ()
   "Perform prompt completion to do in buffer completion.
 `semantic-analyze-possible-completions' is used to determine the
@@ -2085,6 +2059,7 @@ to change how completion options are displayed."
       (message "Inline completion not needed."))
   )
 
+;;;###autoload
 (defun semantic-complete-self-insert (arg)
   "Like `self-insert-command', but does completion afterwards.
 ARG is passed to `self-insert-command'.  If ARG is nil,
@@ -2113,26 +2088,13 @@ use `semantic-complete-analyze-inline' to complete."
       (error nil))
     ))
 
-;; @TODO - I can't  find where this fcn is used.  Delete?
-
-;;;;###autoload
-;(defun semantic-complete-inline-project ()
-;  "Perform inline completion for any symbol in the current project.
-;`semantic-analyze-possible-completions' is used to determine the
-;possible values.
-;The function returns immediately, leaving the buffer in a mode that
-;will perform the completion."
-;  (interactive)
-;  ;; Only do this if we are not already completing something.
-;  (if (not (semantic-completion-inline-active-p))
-;      (semantic-complete-inline-tag-project))
-;  ;; Report a message if things didn't startup.
-;  (if (and (interactive-p)
-;         (not (semantic-completion-inline-active-p)))
-;      (message "Inline completion not needed."))
-;  )
-
-;; End
 (provide 'semantic/complete)
 
+;; Local variables:
+;; generated-autoload-file: "loaddefs.el"
+;; generated-autoload-feature: semantic/loaddefs
+;; generated-autoload-load-name: "semantic/complete"
+;; End:
+
+;; arch-tag: a07c8f71-e53b-416e-9704-3a99ef101b09
 ;;; semantic/complete.el ends here