- "A `company-mode' completion back-end using CEDET Semantic."
- (case command
- ('prefix (and (memq major-mode '(c-mode c++-mode jde-mode java-mode))
- (not (company-in-string-or-comment))
- (or (company-grab company-semantic-context-regexp 2) "")))
- ('candidates (or (company-semantic-completions arg)
- (mapcar 'semantic-tag-name
- (semantic-analyze-find-tags-by-prefix arg))))
- ('meta (funcall company-semantic-metadata-function
- (semantic-analyze-find-tag arg)))
- ('doc-buffer (company-semantic-doc-buffer (semantic-analyze-find-tag arg)))
- ;; because "" is an empty context and doesn't return local variables
- ('no-cache (equal arg ""))))
+ "`company-mode' completion backend using CEDET Semantic."
+ (interactive (list 'interactive))
+ (cl-case command
+ (interactive (company-begin-backend 'company-semantic))
+ (prefix (and (featurep 'semantic)
+ (semantic-active-p)
+ (memq major-mode company-semantic-modes)
+ (not (company-in-string-or-comment))
+ (or (company-semantic--prefix) 'stop)))
+ (candidates (if (and (equal arg "")
+ (not (looking-back "->\\|\\." (- (point) 2))))
+ (company-semantic-completions-raw arg)
+ (company-semantic-completions arg)))
+ (meta (funcall company-semantic-metadata-function
+ (assoc arg company-semantic--current-tags)))
+ (annotation (company-semantic-annotation arg
+ company-semantic--current-tags))
+ (doc-buffer (company-semantic-doc-buffer
+ (assoc arg company-semantic--current-tags)))
+ ;; Because "" is an empty context and doesn't return local variables.
+ (no-cache (equal arg ""))
+ (duplicates t)
+ (location (let ((tag (assoc arg company-semantic--current-tags)))
+ (when (buffer-live-p (semantic-tag-buffer tag))
+ (cons (semantic-tag-buffer tag)
+ (semantic-tag-start tag)))))))