When I search through project via semantic-complete-jump and tag is not unique (its defined in multiple places), I must hit <tab> to iterate through all possible places. Problem is, I horribly dislike the way how candidate iteration works. For every candidate definition, new window is opened.

How to customize it to not open additional windows?

And even better, how to get needed data from semantic so I can create my own semantic-complete-jump with IDO interface.

Basically, I want this "theoretical" function which I failed to find when reading CEDET sources around semantic-complete-jump.

INPUT: name of symbol (function name, member name etc).

OUTPUT: list of files with positions where such symbol is defined in current project.

Again, I tried to read sources and was unable to find how this data are extracted from semantic.

1 Answer 1


Here it is, semantic-complete-jump reworked to use IDO interface.

(defun custom/semantic/complete-jump (sym)
  (interactive (list
                (thing-at-point 'symbol)))
  (let ((tags (custom/semantic/deep-brute-tags-query sym)))
    (if tags
          (let* ((summaries (mapcar #'custom/semantic/tag-summary tags))
                 (chosen-summary (ido-completing-read "Choose tag: "
                 (chosen-tag (custom/semantic/get-tag-by-summary chosen-summary
            (if chosen-tag
                  (if (boundp 'semantic-tags-location-ring)
                      (ring-insert semantic-tags-location-ring (point-marker)))
                  (find-file (nth 2 chosen-tag))
                  (goto-char (nth 3 chosen-tag))
                  (pulse-momentary-highlight-region (nth 3 chosen-tag)
                                                    (nth 4 chosen-tag)))
              (message "Error, failed to pair tags and summaries -> REPORT BUG"))))
      (message "No tags found for %s" sym))))

(defun custom/semantic/tag-summary (tag)
  (format "%s:%s -> %s"
          (nth 0 tag)
          (nth 1 tag)
          (nth 2 tag)))

(defun custom/semantic/get-tag-by-summary (summary tags)
  (let ((res nil))
    (dolist (tag tags)
      (if (and (not res)
               (string= summary
                        (custom/semantic/tag-summary tag)))
          (setq res tag)))

(defun custom/semantic/deep-brute-tags-query (sym &optional buff)
  (let ((acc nil))
    (dolist (tag (semanticdb-strip-find-results
                   (if buff buff (current-buffer)))
      (if (semantic-tag-buffer tag)
          (setq acc (push (list (semantic-tag-class tag)
                                (semantic-tag-name tag)
                                (buffer-file-name (semantic-tag-buffer tag))
                                (semantic-tag-start tag)
                                (semantic-tag-end tag))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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