]> code.delx.au - gnu-emacs/blobdiff - lisp/cedet/semantic/analyze/complete.el
Update copyright year to 2015
[gnu-emacs] / lisp / cedet / semantic / analyze / complete.el
index bbe87f341722a40ed84fe02dc69255cfb1eec141..c47b57336c5bae815be9e5b0a6900367fabef8f1 100644 (file)
@@ -1,6 +1,6 @@
 ;;; semantic/analyze/complete.el --- Smart Completions
 
-;; Copyright (C) 2007-201 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2015 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <zappo@gnu.org>
 
@@ -28,7 +28,7 @@
 ;;
 ;;; History:
 ;;
-;; Code was moved here from semantic-analyze.el
+;; Code was moved here from semantic/analyze.el
 
 (require 'semantic/analyze)
 
@@ -87,28 +87,34 @@ in a buffer."
   ;; In theory, we don't need the below since the context will
   ;; do it for us.
   ;;(semantic-refresh-tags-safe)
-  (with-syntax-table semantic-lex-syntax-table
-    (let* ((context (if (semantic-analyze-context-child-p context)
-                        context
-                      (semantic-analyze-current-context context)))
-          (ans (if (not context)
-                   (error "Nothing to complete")
-                 (:override))))
-      ;; If interactive, display them.
-      (when (called-interactively-p 'any)
-       (with-output-to-temp-buffer "*Possible Completions*"
-         (semantic-analyze-princ-sequence ans "" (current-buffer)))
-       (shrink-window-if-larger-than-buffer
-        (get-buffer-window "*Possible Completions*")))
-      ans)))
+  (if (semantic-active-p)
+    (with-syntax-table semantic-lex-syntax-table
+      (let* ((context (if (semantic-analyze-context-child-p context)
+                         context
+                       (semantic-analyze-current-context context)))
+            (ans (if (not context)
+                     (error "Nothing to complete")
+                   (:override))))
+       ;; If interactive, display them.
+       (when (called-interactively-p 'any)
+         (with-output-to-temp-buffer "*Possible Completions*"
+           (semantic-analyze-princ-sequence ans "" (current-buffer)))
+         (shrink-window-if-larger-than-buffer
+          (get-buffer-window "*Possible Completions*")))
+       ans))
+    ;; Buffer was not parsed by Semantic.
+    ;; Raise error if called interactively.
+    (when (called-interactively-p 'any)
+      (error "Buffer was not parsed by Semantic."))))
 
 (defun semantic-analyze-possible-completions-default (context &optional flags)
   "Default method for producing smart completions.
 Argument CONTEXT is an object specifying the locally derived context.
 The optional argument FLAGS changes which return options are returned.
 FLAGS can be any number of:
-  'no-tc     - do not apply data-type constraint.
-  'no-unique - do not apply unique by name filtering."
+  'no-tc         - do not apply data-type constraint.
+  'no-longprefix - ignore long multi-symbol prefixes.
+  'no-unique     - do not apply unique by name filtering."
   (let* ((a context)
         (desired-type (semantic-analyze-type-constraint a))
         (desired-class (oref a prefixclass))
@@ -122,9 +128,16 @@ FLAGS can be any number of:
         (c nil)
         (any nil)
         (do-typeconstraint (not (memq 'no-tc flags)))
+        (do-longprefix (not (memq 'no-longprefix flags)))
         (do-unique (not (memq 'no-unique flags)))
         )
 
+    (when (not do-longprefix)
+      ;; If we are not doing the long prefix, shorten all the key
+      ;; elements.
+      (setq prefix (list (car (reverse prefix)))
+           prefixtypes nil))
+
     ;; Calculate what our prefix string is so that we can
     ;; find all our matching text.
     (setq completetext (car (reverse prefix)))
@@ -188,7 +201,7 @@ FLAGS can be any number of:
       ;; Reset c.
       (setq c nil)
 
-      ;; Loop over all the found matches, and catagorize them
+      ;; Loop over all the found matches, and categorize them
       ;; as being possible features.
       (while (and loopc do-typeconstraint)