(Resent) completion-at-point in non-semantic buffer
Dmitry Cherkassov <[email protected]> Wed, 2 Sep 2015 14:38:52 +0300
| Newsgroups | gmane.emacs.semantic |
|---|---|
| Message-ID | <CAN0j1dQEpwkkqV8uz_MR5P2W7TOErX+xdGThMXLa7A0Lt-porw@mail.gmail.com> |
[Sorry, resending in plain-text]
Hi. I use cedet from git:26cd107a7a67d85696f019be4383db9931cc7c44
and load it as said in docs:
(load-file "~/.emacs.d/vendor/cedet/cedet-devel-load.el")
...
(semantic-mode 1)
The problem:
When calling `company-complete' in buffer with no semantic minor mode
it fails with a stacktrace:
error("Cannot analyze buffers not supported by Semantic")
semantic-analyze-current-context()
semantic-analyze-completion-at-point-function()
...
I've looked at `completion-at-point-functions' variable and
`semantic-analyze-completion-at-point-function' is indeed there.
Is this a bug? completion-at-point clearly expects either `nil' or a
list of completions when evaling `completion-at-point-functions' list.
I've devised a small patch that checks wheter semantic is active
before calling `semantic-analyze-current-context' but not sure that's
the correct way of doing things.
Please comment.
Thanks.
--
With best regards,
Dmitry
------------------------------------------------------------------------------
Monitor Your Dynamic Infrastructure at Any Scale With Datadog!
Get real-time metrics from all of your servers, apps and tools
in one place.
SourceForge users - Click here to start your Free Trial of Datadog now!
http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140
_______________________________________________
cedet-semantic mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cedet-semantic
0001-Check-if-semantic-is-active-in-semantic-analyze-comp.patch
(text/x-patch, 3.6 KB)
From b56607438b5db09bf8024f204c137b1fb12a968e Mon Sep 17 00:00:00 2001 From: Dmitry Cherkassov <[email protected]> Date: Wed, 2 Sep 2015 14:23:28 +0300 Subject: [PATCH] Check if semantic is active in `semantic-analyze-*-completion-at-point-function's Don't call `semantic-analyze-current-context' from `semantic-analyze-*-completion-at-point-function' --- lisp/cedet/semantic.el | 56 ++++++++++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/lisp/cedet/semantic.el b/lisp/cedet/semantic.el index 472a196..e897357 100644 --- a/lisp/cedet/semantic.el +++ b/lisp/cedet/semantic.el @@ -1177,17 +1177,18 @@ Semantic mode. "Return possible analasis completions at point. The completions provided are via `semantic-analyze-possible-completions'. This function can be used by `completion-at-point-functions'." - (let* ((ctxt (semantic-analyze-current-context)) - (possible (semantic-analyze-possible-completions ctxt))) - - ;; The return from this is either: - ;; nil - not applicable here. - ;; A list: (START END COLLECTION . PROPS) - (when possible - (list (car (oref ctxt bounds)) - (cdr (oref ctxt bounds)) - possible)) - )) + + (when (semantic-active-p) + (let* ((ctxt (semantic-analyze-current-context)) + (possible (semantic-analyze-possible-completions ctxt))) + + ;; The return from this is either: + ;; nil - not applicable here. + ;; A list: (START END COLLECTION . PROPS) + (when possible + (list (car (oref ctxt bounds)) + (cdr (oref ctxt bounds)) + possible))))) (defun semantic-analyze-notc-completion-at-point-function () "Return possible analasis completions at point. @@ -1195,14 +1196,15 @@ The completions provided are via `semantic-analyze-possible-completions', but with the 'no-tc option passed in, which means constraints based on what is being assigned to are ignored. This function can be used by `completion-at-point-functions'." - (let* ((ctxt (semantic-analyze-current-context)) - (possible (semantic-analyze-possible-completions ctxt 'no-tc))) - (when possible - (list (car (oref ctxt bounds)) - (cdr (oref ctxt bounds)) - possible)) - )) + (when (semantic-active-p) + (let* ((ctxt (semantic-analyze-current-context)) + (possible (semantic-analyze-possible-completions ctxt 'no-tc))) + + (when possible + (list (car (oref ctxt bounds)) + (cdr (oref ctxt bounds)) + possible))))) (defun semantic-analyze-nolongprefix-completion-at-point-function () "Return possible analasis completions at point. @@ -1210,15 +1212,15 @@ The completions provided are via `semantic-analyze-possible-completions', but with the 'no-tc and 'no-longprefix option passed in, which means constraints resulting in a long multi-symbol dereference are ignored. This function can be used by `completion-at-point-functions'." - (let* ((ctxt (semantic-analyze-current-context)) - (possible (semantic-analyze-possible-completions - ctxt 'no-tc 'no-longprefix))) - - (when possible - (list (car (oref ctxt bounds)) - (cdr (oref ctxt bounds)) - possible)) - )) + (when (semantic-active-p) + (let* ((ctxt (semantic-analyze-current-context)) + (possible (semantic-analyze-possible-completions + ctxt 'no-tc 'no-longprefix))) + + (when possible + (list (car (oref ctxt bounds)) + (cdr (oref ctxt bounds)) + possible))))) ;;; Autoload some functions that are not in semantic/loaddefs -- 2.1.4