0

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.

dev1223
  • 241
  • 1
  • 10

1 Answers1

0

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
        (progn
          (let* ((summaries (mapcar #'custom/semantic/tag-summary tags))
                 (chosen-summary (ido-completing-read "Choose tag: "
                                                      summaries))
                 (chosen-tag (custom/semantic/get-tag-by-summary chosen-summary
                                                                 tags)))
            (if chosen-tag
                (progn
                  (if (boundp 'semantic-tags-location-ring)
                      (ring-insert semantic-tags-location-ring (point-marker)))
                  (push-mark)
                  (find-file (nth 2 chosen-tag))
                  (goto-char (nth 3 chosen-tag))
                  (recenter)
                  (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)))
    res))

(defun custom/semantic/deep-brute-tags-query (sym &optional buff)
  (let ((acc nil))
    (dolist (tag (semanticdb-strip-find-results
                  (semanticdb-brute-deep-find-tags-for-completion
                   sym
                   (if buff buff (current-buffer)))
                  t))
      (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))
                          acc))))
    acc))
dev1223
  • 241
  • 1
  • 10