0

This might seem to be a very very stupid question. But for the past few years I have been using vim and cscope on the terminal, with some screen to make life a bit bearable. I have just started to learn emacs and it is much more satisfying to use it.

Problem using emacs: Every time I do M-x find-c-symbol, I get a new buffer with a bunch of files, but I don't know how to open the file at the exact line number. I googled a lot and found this to open file under cursor: M-x ffap but this opens at the first line. Can some emacs expert help me??

Thanks

  • I can't reproduce the problem. When I use cscope-find-this-symbol for instance, I get a new buffer with a *list* of files and I just have to click on it or press RET and it gets me to the good line. You may try activating M-x compilation-shell-minor-mode in the new buffer, that should make the links «clickable». – Ehvince Feb 05 '14 at 10:39
  • could you post the contents of your .emacs file related to the cscope? I might be missing something – user3273493 Feb 05 '14 at 12:42
  • I have nothing at all ! I followed these instructions: http://wikemacs.org/index.php/Python#Indexing_sources:_ctags.2C_cscope.2C_pycscope I call a cscope function once in a while, as I told you above. Using Emacs24. I couldn't find the function find-c-symbol by the way. Where does it come from ? – Ehvince Feb 05 '14 at 13:07
  • Hello @Ehvince I am using gnu emacs if that helps. The xemacs options have been put into the gnu emacs by one of our team members. As I am still learning, could you suggest a way I can bind a key combination to open a file at the line given. – user3273493 Feb 20 '14 at 02:32
  • This should be automatic. Are you using Emacs24.3 ? – Ehvince Feb 20 '14 at 10:05
  • no I am actually using an older version emacs 21 – user3273493 Mar 03 '14 at 06:20
  • Did you try M-x compilation-shell-minor-mode in the cscope buffer ? and you could try to install a newer version of xcscope: http://linux.die.net/man/1/xcscope , – Ehvince Mar 03 '14 at 13:51
  • there must have been some kind of installation issue. I checked with a different machine and emacs works. Need to re-configure this. Thanks for the help though. :) – user3273493 Mar 03 '14 at 19:24

1 Answers1

0

I've got both Emacs 23.x and 24.x installed, both setup with working cscope and xcscope installs. Neither has a "find-c-symbol" function, but there is a "cscope-find-this-symbol", which is what I assume you're actually using.

I'm going to assume you're using a GUI version, and not the text-only version, and that you're actually getting the *cscope* buffer automatically being opened and created (since that's what it sounds like from your description).

For a simple search, I'll get results that look like this:

Finding symbol: debug

Database directory: /home/user/emacs_tags/modular/
-------------------------------------------------------------------------------
*** /home/user/code/modular/frontend/common/controller.test/src/MainTest.cpp:
<global>[73]                   #ifdef debug
-------------------------------------------------------------------------------

Database directory: /home/user/emacs_tags/rrsdk/
-------------------------------------------------------------------------------
*** /home/user/code/rrsdk/fs/apps/busybox/src/shell/ash.c:
<global>[303]                  #define debug optlist[15 + ENABLE_ASH_BASH_COMPAT]

*** /home/user/code/rrsdk/bootloader/u-boot/src/board/mcc200/auto_update.c:
<global>[53]                   #undef debug
<global>[55]                   #define debug(fmt,args...) printf (fmt ,##args)
<global>[57]                   #define debug(fmt,args...)
-------------------------------------------------------------------------------

Search complete.  Search time = 22.44 seconds.

Assuming your results look similar (they should), there are two multiple target areas in the result. Each file line (the lines starting with ***) is a target to the start of that file. Each individual result is also a target area. If you click on one of the lines that lists a specific match (or put your cursor on it and press enter), it will attempt to jump to the specific line matching the result. If it's not jumping to the specific line correctly it usually means your code has changed since the last time the cscope index file was generated.

I'm not sure how you're using the cscope tool, but you can setup xcscope to auto-index on every change to keep the file up to date, but it really only works for smaller code bases where you can keep the cscope.out files in the top level directory and provide it with a full file list for the files to index. Most people I've talked to use the cscope tool by hand in an external script to manually index/re-index every once in a while and then just interface to the existing cscope database(s) using the emacs tools (mine takes about 4 hours to generate the cscope database for a project that includes the Linux kernel as a sub-part).

mtalexan
  • 677
  • 1
  • 7
  • 17