]> code.delx.au - gnu-emacs-elpa/blobdiff - company-semantic.el
Bumped version to 0.4.
[gnu-emacs-elpa] / company-semantic.el
index e1cfbda415d7fef3795199b6e6e71e18a559f6df..4d23bf6f62592ae80f15bbfffe95caa719fb6f19 100644 (file)
@@ -2,7 +2,7 @@
 ;;
 ;; Copyright (C) 2009 Nikolaj Schumacher
 ;;
-;; This file is part of company 0.3.
+;; This file is part of company 0.4.
 ;;
 ;; This program is free software; you can redistribute it and/or
 ;; modify it under the terms of the GNU General Public License
@@ -26,9 +26,6 @@
   :group 'company
   :type 'function)
 
-(defvar company-semantic-context-regexp
-  "\\(->\\|\\.\\|\\_<\\)\\(\\(\\s_\\|\\sw\\)+\\_>\\=\\)")
-
 (defun company-semantic-doc-or-summary (tag)
   (or (semantic-documentation-for-tag tag)
       (funcall semantic-idle-summary-function tag nil t)))
           (context (semantic-analyze-current-context)))
       (all-completions prefix (semantic-ia-get-completions context (point))))))
 
+(defun company-semantic-completions-raw (prefix)
+  (let (candidates)
+    (dolist (tag (semantic-analyze-find-tags-by-prefix prefix))
+      (unless (eq (semantic-tag-class tag) 'include)
+        (push (semantic-tag-name tag) candidates)))
+    (delete "" candidates)))
+
 ;;;###autoload
 (defun company-semantic (command &optional arg &rest ignored)
   "A `company-mode' completion back-end using CEDET Semantic."
     ('prefix (and (memq major-mode '(c-mode c++-mode jde-mode java-mode))
                   (semantic-active-p)
                   (not (company-in-string-or-comment))
-                  (or (company-grab company-semantic-context-regexp 2) "")))
+                  (or (company-grab-symbol) 'stop)))
     ('candidates (or (company-semantic-completions arg)
-                     (mapcar 'semantic-tag-name
-                             (semantic-analyze-find-tags-by-prefix arg))))
+                     (company-semantic-completions-raw arg)))
     ('meta (funcall company-semantic-metadata-function
                     (semantic-analyze-find-tag arg)))
     ('doc-buffer (company-semantic-doc-buffer (semantic-analyze-find-tag arg)))