开发者

Can we make Emacs find the definition of the variable?

开发者 https://www.devze.com 2023-02-05 10:20 出处:网络
I try to learn to use Emacs as my programming editor. I use it to edit Java. Now, let say i have this code :

I try to learn to use Emacs as my programming editor. I use it to edit Java. Now, let say i have this code :

 
 private Sprite logo = null;//1                                                                                                


    private void createSprites(){//2
        logo = new ASprite();//3

    }//4

and now my cursor is in the word logo at line 3. How can I jump quickly to logo definition at line 1? All I know is C-s, C-r. .. but then I have to type logo, not directl开发者_JS百科y find logo definition.

Thank you

EDITED: I just using semantic-mode on Emacs 2.2 : I can jump to a definition of a tag (function, variable) using C-c , j This solve my problem :)


You can achieve this by building a TAGS file containing the needed information by using for example exuberant-ctags or Etags that should already be installed. In order to generate the TAGS file you can use:

exuberant-ctags -e -R --language-force=java /opt/sun-jdk-1.5.0.08/share/

Once done, and your cursor is on the "logo" string, press M-. ( and emacs will ask you for the TAGS file. Enter the location to it and it will find the definition of the variable.


I doubt the emacs java-mode is actually building up an internal syntax tree to make these kinds of searches possible. Eclipse is the world-champion here. The good think is: Eclipse comes with a Emacs key-bindings, so you will feel right at home.

C-x C-c

0

精彩评论

暂无评论...
验证码 换一张
取 消