dkogan / xcscope.el

cscope interface for (X)Emacs
121 stars 29 forks source link

This is an emacs interface to the 'cscope' source cross-referencing tool (http://cscope.sf.net). It can answer such questions as

The 'cscope' tool does the actual searching and lookup, while xcscope.el provides a convenient interface.

GNU global (http://www.gnu.org/s/global/) is another source indexer much like cscope. It's better than cscope in some ways and worse in others. It also provides a compatibility interface to allow it to be used just like cscope. This means that xcscope.el can be used as a front-end to GNU Global. To do that, simply evaluate

(setq cscope-program "gtags-cscope")

** Quick-start

  1. Install xcscope.el through your system package manager or MELPA, or simply evaluate xcscope.el.

  2. Evaluate

Done! cscope-minor-mode is now hooked to C, C++ and dired modes. Default bindings are all prefixed with C-c s. So, for instance, to find a symbol do C-c s s. This is analogous to the M-. of tags. All results are shown in a new cscope buffer which pops up when needed.

** More-detailed usage instructions

When xcscope.el is active, you can just use the keybindings (described below) when looking at source. You can also use the Cscope menu or a mouse pop-up menu (button 3).

When a search is performend, by default xcscope.el will traverse the directory hierarchy upwards, looking for the cscope database. If it doesn't find it, a new database will be made in the current directory. To create the database in a different (higher) directory, explicitly invoke C-c s I. A currently-existing database can be removed simply by deleting cscope.*. By default, cscope updates the database with every search. This is very convenient, but can be too slow for very large source trees.

The third mouse button is bound to a popup menu for cscope. Shift-mouse button 3 invokes the last find command again. E.g. if you look for the symbol 'main' and afterwards you want to look for another symbol, just press Shift and click the third button.

Search results are displayed in a cscope buffer, which pops up when results are available. You can then use button 2 (the middle button) on the mouse to edit the selected file, or you can move the text cursor over a selection and press [Enter]. You can also press [space] to show the result in the other window (cscope buffer stays focused). Alternately, the navigation commands invoked with n/p, show the results too.

Each cscope search adds its results to the cscope buffer. Thus this buffer contains a history of all past searches. These sets of results can be navigated and manupulated similar to patches in diff-mode:

Any result set in the cscope buffer can be re-run with the 'r' key. This is useful if the sources changed

** Keybindings:

All keybindings use the "C-c s" prefix:

| C-c s s | Find symbol. | | C-c s = | Find assignments to this symbol | | C-c s d | Find global definition. | | C-c s g | Find global definition (alternate binding). | | C-c s G | Find global definition without prompting. | | C-c s c | Find functions calling a function. | | C-c s C | Find called functions (list functions called from a function). | | C-c s t | Find text string. | | C-c s e | Find egrep pattern. | | C-c s f | Find a file. | | C-c s i | Find files #including a file. |

These pertain to navigation through the search results:

| C-c s b | Display cscope buffer. | | C-c s B | Auto display cscope buffer toggle. | | C-c s n | Next symbol. | | C-c s N | Next file. | | C-c s p | Previous symbol. | | C-c s P | Previous file. | | C-c s u | Pop mark. |

These pertain to setting and unsetting the variable, `cscope-initial-directory', (location searched for the cscope database directory):

| C-c s a | Set initial directory. | | C-c s A | Unset initial directory. |

These pertain to cscope database maintenance:

| C-c s L | Create list of files to index. | | C-c s I | Create list and index. | | C-c s E | Edit list of files to index. | | C-c s W | Locate this buffer's cscope directory ("W" --> "where"). | | C-c s S | Locate this buffer's cscope directory. (alternate binding: "S" --> "show"). | | C-c s T | Locate this buffer's cscope directory. (alternate binding: "T" --> "tell"). | | C-c s D | Dired this buffer's directory. |

** Interesting configuration variables:

This is a continuation of the xcscope.el (by Darryl Okahata) that ships in the CVS tree of cscope itself. The code in the cscope tree is stable, so /this/ tree expands on the original source, fixing various bugs and adding features.

xcscope.el was written by Darryl Okahata, with patches contributed by Triet H. Lai and Steven Elliott. Dima Kogan added some features.

xcscope.el is distributed under the terms of version 2 (or later) of the GNU General Public License

The maintainer is Dima Kogan dima@secretsauce.net