1

With semantic-mode enabled and reading a C++ source file in cc-mode, running helm-semantic-or-imenu correctly shows all the classes, variables and functions defined in that file. However, all the descriptions have the characters & and * missing. So, by simply looking at the entries shown in the helm semantic/imenu buffer, I can't tell the correct signatures. For example, a member variable defined as const char* fileName shows up as const char fileName. Is there some variable which would change this display behaviour?

EDIT : More information thanks to @TuDo - Both semantic-ia-show-summary and helm-semantic-or-imenu use semantic-format-tag-summarize to parse the tag info. However, the latter correctly outputs const char* fileName.

2

In a buffer with only the line const char* fileName as above, running (semantic-fetch-tags) returns this tag that gives back char as type:

(("filename" variable (:pointer 1 :constant-flag t :type "char") nil #<overlay from 1 to 22 in 03-095759.c>))

The type is "char", although it has the attribute :pointer 1 to denote the level of pointer. helm-semantic does not account for this attribute, so I will try to update it and create a PR for Helm to fix this.

EDIT: But then, the Helm function uses semantic-format-tag-summarize to format tag for displaying in Helm, so this is a bug in Semantic itself for not returning correct original appearance of tag. I will report this to CEDET maintainer.

EDIT2: As a workaround until this got fixed. you can at least press TAB to temporary jump to function signature and view the correct one.

EDIT3: I finally reproduced the error with a minimal example:

(let ((tag (car (semantic-fetch-tags))))
  (with-temp-buffer
    (insert (semantic-format-tag-summarize tag nil t))
    (buffer-string)))

Eval the above code in a file with a pointer. For some reason, when the buffer string is returned, characters like * or & is deleted. Maybe it should be escaped when ``semantic-format-tag-summarize` returns tag string? I already reported this issue to CEDET maintainer.

EDIT4: This bug was fixed with commit 9ea601e. The problem is solved.

  • I was looking at the code for semantic-ia-show-summary. It calls semantic-format-tag-summarize as well. However, its output correct says const char* fileName. So, this doesn't sound like a semantic issue. – Pradhan Dec 3 '14 at 5:05
  • Interesting. Helm uses the same thing but it returns string with missing info. – Tu Do Dec 3 '14 at 5:30
  • The difference is that semantic-ia-show-summary retrieves tags from semantic-analyze-interesting-tag, while Helm retrieves from semantic-fetch-tags. Probably the two tag formats are inconsistent? – Tu Do Dec 3 '14 at 5:34
  • 1
    @Pradhan I fixed this bug and made a PR here. It is not a bug, but a behaviour of semantic-format-tag-summarize. – Tu Do Dec 24 '14 at 6:28
  • 1
    @Pradhan The bug is fixed in helm-semantic now. – Tu Do Dec 24 '14 at 8:18
1

I've just patched moo-jump-local to properly handle const char* fileName. It seems that semantic can't currently parse top-level references. Although it parses them in the arguments lists, as you can see here: moo-jump-local

  • Nice. I wonder if moo-jump-local can be used in other languages that Semantic supports, i.e. Emacs Lisp, Python...? If not, then I will use this command only for C/C++ buffers and the old helm-semantic-or-imenu for others. EDIT: Seems like it's possible but very rudimentary. – Tu Do Dec 3 '14 at 8:49
  • The goto function of github.com/abo-abo/lispy is pretty advanced for Elisp, Clojure, Common Lisp and Scheme. For instance, you get dedicated tags for defgeneric or global-set-key. – abo-abo Dec 3 '14 at 9:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.