Search code examples
rubyemacsctags

Quick navigate to the definition code of a function from another ruby gem in Emacs using ctags


I have a ruby script in emacs.

require 'watir'
ie=Watir::IE.new

When I puts the cursor on the word IE and press C+] , I want Emacs to open the definition of the IE class, which is in the source code of the watir gem.

How can I achieve that using Emacs and ctags?


Solution

  • Use the following command it the directory where your gems are installed:

    ctags -e -a --Ruby-kinds=-fF -o TAGS -R .
    

    Afterwards press M-. in Emacs while your cursor is over the Watir word. Emacs will prompt you for the location of the TAGS file and afterwards it will jump to the definition of the type.

    Basic etags usage in Emacs:

    M-. goes to the method under the cur­sor, in the same win­dow. First time it asks for the TAGS file. C-4 . goes to the method under the cur­sor. Opens a new win­dow. First time it asks for the TAGS file. M-, cycles to the next selection.