tags:

views:

381

answers:

4

Is it possible to use ido-mode completion to find definitions in a TAGS file? I suspect that ido-completing-read is part of the answer. Here's my non-working code, which shows an unpopulated ido-mode minibuffer:

(defun ido-choose-from-tags ()
  "Use ido to select tags "
  (interactive)
    (etags-tags-apropos
     (ido-completing-read "Tags: "  nil t)))
+1  A: 

This blog post already implements what you are trying to do:

http://chopmo.blogspot.com/2008/09/quickly-jumping-to-symbols.html

Vicent Marti
Not quite, that uses imenu not etags.
scottfrazer
A: 

Of course it's possible, this is EMACS. What does the non-working code do that tells you it isn't working?

My first suspicion is that it might work better if you used tags-apropos (see about line 1885 in etags.el), seeing as etags-tags-apropos isn't defined and all.

Charlie Martin
+1  A: 

Kind of inefficient, but how about:

(defun my-ido-find-tag ()
  "Find a tag using ido"
  (interactive)
  (tags-completion-table)
  (let (tag-names)
    (mapc (lambda (x)
            (unless (integerp x)
              (push (prin1-to-string x t) tag-names)))
          tags-completion-table)
    (find-tag (ido-completing-read "Tag: " tag-names))))
scottfrazer
Thanks, Scott. One bug: when a tag contains a period, it inserts a backslash in front of it, preventing emacs from from finding the tag.
James Sulak
Replacing the last line with "(find-tag (replace-regexp-in-string "\\\\" "" (ido-completing-read "Tag: " tag-names)))))" seems to work.
James Sulak
Good catch. prin1-to-string can also take an optional 2nd argument that doesn't escape chars, so maybe (prin1-to-string x t) would fix it also.
scottfrazer
Yeah, it does. That's a much better solution than the regex replace.
James Sulak
+1  A: 

To find definitions i use CEDET's command semantic-ia-fast-jump, that together with gtags from GNU Global gives proper and quick navigation through source files.

Alex Ott