I mostly do Python work (not Ruby) and I usually rely on memory to
tell me where something is defined. If it's in a 3rd party library
which I'm not familiar with, I use etags[1] which is not totally
reliable for dynamic languages but hasn't failed me till now.
Footnotes:
1. http://www.gnu.org/software/emacs/emacs-lisp-intro/html_node/etags.html
--
~noufal
http://nibrahim.net.in
On Sat, Sep 24, 2011 at 11:27 PM, srihari k <sri...@gmail.com> wrote:I mostly do Python work (not Ruby) and I usually rely on memory to
> Hey all,
>
> In emacs what do you use to go to definition of a method ?
tell me where something is defined. If it's in a 3rd party library
which I'm not familiar with, I use etags[1] which is not totally
reliable for dynamic languages but hasn't failed me till now.
Unfortunately, yes... I generate ctags (& the cscope db). I have a
line like below in my .zshrc file and I just run it as and when I need
it (just the first part relates to ctags).
alias refreshctags="ctags -f tags --recurse=yes . && find . -name
'*.rb' -o -name '*.java' -o -name '*.cs' -o -name '*.js' -o -name
'*.haml' -o -name '*.erb' >| cscope.files && cscope -b -q"
Then you build the tag definitions specific to your project with this command - (i've renamed the ctags binary which I installed from the above URL, to ctags-exuberant, because a different version of ctags was installed by default)
ctags-exuberant -a -e -f <path-to-tags-file> --tag-relative -R <folder1> <folder 2>
Eg: ctags-exuberant -a -e -f TAGS --tag-relative -R lib vendor
(This will generate a TAGS file in the current directory)
Then fire up emacs, and you can select the TAGS file with this command : M-x visit-tags-table
Then you can look up tags definition with M-x . (meta-x dot).
Also everytime you make changes to your functions, you will have to rebuild the tag definitions again by executing the above command.
The lookup doesn't work 100% of the time, but its better than not having any tag definitions. Hope this helps :)
Punit Rathore
I use M-x find-grep-dired which works like find in files.
To find the method definition I type def <method_name>
I am thinking that one can streamline this using keyboard macros [1]
so that it will combine all the above steps into one macro which you
have to execute (and maybe bind to <your_fav_key>) to go to the
definition of the method.
[1] http://www.emacswiki.org/emacs/KeyboardMacros
--
Kumar Gaurav
Latest Post -- Definitive Guide to accepts_nested_attributes_for in rails 3
http://wp.me/pbU2Q-4v
--
Regards,
Jasim A Basheer.
C42 Engineering, http://c42.in
http://jasimabasheer.com
Having said that. For C/C++ or moderately small Ruby projects,
excuberant ctags works well enough. So, I keep following snippet in my
.emacs:
(setq path-to-ctags "/usr/local/bin/ctags") ;; <- you're ctags path here
(defun create-tags (dir-name)
"Create tags file."
(interactive "DDirectory: ")
(shell-command
(format "%s -f %s/TAGS -e -R %s" path-to-ctags dir-name dir-name))
)
(global-set-key "\C-ct" 'visit-tags-table)
(global-set-key "\C-cd" 'create-tags)
And use "M-." for visiting the definition of word under the cursor and
"M-*" to pop back. Works well enough, unless we are talking about
painfully meta-programmed code base. :)
There is also,
http://code.google.com/p/google-gtags/
I have heard at least one guy saying that, he managed to make it work
with Ruby/Rails. But honestly, did not look too closely.
--
Let them talk of their oriental summer climes of everlasting
conservatories; give me the privilege of making my own summer with my
own coals.
exuberant-ctags works well with emacs too. You can get is from here - http://ctags.sourceforge.net/
Then you build the tag definitions specific to your project with this command - (i've renamed the ctags binary which I installed from the above URL, to ctags-exuberant, because a different version of ctags was installed by default)
ctags-exuberant -a -e -f <path-to-tags-file> --tag-relative -R <folder1> <folder 2>
Eg: ctags-exuberant -a -e -f TAGS --tag-relative -R lib vendor
(This will generate a TAGS file in the current directory)
Then fire up emacs, and you can select the TAGS file with this command : M-x visit-tags-table
Then you can look up tags definition with M-x . (meta-x dot).
Also everytime you make changes to your functions, you will have to rebuild the tag definitions again by executing the above command.
The lookup doesn't work 100% of the time, but its better than not having any tag definitions. Hope this helps :)
RubyMine (or any other Java IDE for that matter - NetBeans/Eclipse) is
pretty heavy. I found it too slow to be of any use in my macbook.
However for development I'm using a quad-core desktop with 8gb RAM
which takes the sting out a little bit.
About customization, I've found the default features available in
RubyMine to be well-aligned with my requirements.
I also found Vim with vim-rails, NerdTree, CommandT, Exuberant CTags
and Ack integration pretty neat for Rails development. I'm using
Srushti's VimGet bundle (https://github.com/srushti/vim-get). I
presume a lot of Ruby devs are using Carlhuda's Janus
(https://github.com/carlhuda/janus) happily.
I've never worked with emacs before. How good is the Rails editing
ecosystem in emacs compared to vim?
On Sun, Sep 25, 2011 at 11:56 AM, hemant <geth...@gmail.com> wrote:
I've never worked with emacs before. How good is the Rails editing
ecosystem in emacs compared to vim?
<chop>
On Sun, Sep 25, 2011 at 12:19 PM, Habibullah Pagarkar
<habibp...@gmail.com> wrote:
> Hemant, I find RubyMine 3.2.4 to be quite fast as long as it isn't opening a
> 1000 line file. :D But then speed is relative.
>
> Thanks for the link to gtags. Will play with that soon.
Yup agreed speed is relative. Let me know, if you manage to get gtags
going for Ruby, that will be interesting.
--
srihari
You can automate this using inotifywait (if you're on Linux).
Check this out http://superuser.com/questions/181517/how-to-execute-a-command-whenever-a-file-changes/181543#181543
You might want to watch the directory instead of the file so that you
can track multiple ones.
--
~noufal
http://nibrahim.net.in