• Stars
    star
    119
  • Rank 288,667 (Top 6 %)
  • Language
    Emacs Lisp
  • Created over 10 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

cscope interface for (X)Emacs

Overview

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

  • Where is this variable used?
  • What is the value of this preprocessor symbol?
  • Where is this function in the source files?
  • What functions call this function?
  • What functions are called by this function?
  • Where does the message “out of space” come from?
  • Where is this source file in the directory structure?
  • What files include this header file?
  • Where was this variable assigned-to?

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

GNU Global support

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”)

Usage

Quick-start

  1. Install xcscope.el through your system package manager or MELPA, or simply evaluate xcscope.el.
  2. Evaluate
  • (require ‘xcscope)
  • (cscope-setup)

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:

  • n/p navigates over individual results
  • k kills individual results
  • N/P or M-n/M-p navigates over file results
  • M-k kills file results
  • M-N/M-P navigates over result sets
  • M-K kills result sets
  • Navigation from outside the cscope buffer (C-c s n/p/N/P) is restricted to the result set at (point)

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 sFind symbol.
C-c s =Find assignments to this symbol
C-c s dFind global definition.
C-c s gFind global definition (alternate binding).
C-c s GFind global definition without prompting.
C-c s cFind functions calling a function.
C-c s CFind called functions (list functions called from a function).
C-c s tFind text string.
C-c s eFind egrep pattern.
C-c s fFind a file.
C-c s iFind files #including a file.

These pertain to navigation through the search results:

C-c s bDisplay cscope buffer.
C-c s BAuto display cscope buffer toggle.
C-c s nNext symbol.
C-c s NNext file.
C-c s pPrevious symbol.
C-c s PPrevious file.
C-c s uPop mark.

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

C-c s aSet initial directory.
C-c s AUnset initial directory.

These pertain to cscope database maintenance:

C-c s LCreate list of files to index.
C-c s ICreate list and index.
C-c s EEdit list of files to index.
C-c s WLocate this buffer’s cscope directory (“W” –> “where”).
C-c s SLocate this buffer’s cscope directory. (alternate binding: “S” –> “show”).
C-c s TLocate this buffer’s cscope directory. (alternate binding: “T” –> “tell”).
C-c s DDired this buffer’s directory.

Interesting configuration variables:

  • cscope-truncate-lines

    This is the value of `truncate-lines’ to use in cscope buffers; the default is the current setting of `truncate-lines’. This variable exists because it can be easier to read cscope buffers with truncated lines, while other buffers do not have truncated lines.

  • cscope-use-relative-paths

    If non-nil, use relative paths when creating the list of files to index. The path is relative to the directory in which the cscope database will be created. If nil, absolute paths will be used. Absolute paths are good if you plan on moving the database to some other directory (if you do so, you’ll probably also have to modify `cscope-database-regexps’). Absolute paths may also be good if you share the database file with other users (you’ll probably want to specify some automounted network path for this).

  • cscope-index-recursively

    If non-nil, index files in the current directory and all subdirectories. If nil, only files in the current directory are indexed. This variable is only used when creating the list of files to index, or when creating the list of files and the corresponding cscope database.

  • cscope-name-line-width

    The width of the combined “function name:line number” field in the cscope results buffer. If negative, the field is left-justified.

  • cscope-option-….

    Various options passed to the ‘cscope’ process. Controls things like include directories, database compression, database type, etc.

  • cscope-display-cscope-buffer

    If non-nil, display the cscope buffer after each search (default). This variable can be set in order to reduce the number of keystrokes required to navigate through the matches.

Provenance

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.

New features relative to the cscope CVS tree

  • (cscope-setup) must be called to enable cscope-minor-mode in C and C++ major modes
  • New searches are appended to the cscope buffer, instead of overwriting. The user thus sees a history of cscope search results in this buffer, and is able to navigate through all of them. There is a size limit to keep the buffer from growing out of control.
  • The cscope buffer can be navigated and edited similarly to emacs Diff buffers:
    • n/p navigates over individual results
    • k kills individual results
    • N/P or M-n/M-p navigates over file results
    • M-k kills file results
    • M-N/M-P navigates over result sets
    • M-K kills result sets
    • Navigation from outside the cscope buffer (C-c s n/p/N/P) is restricted to the result set at (point)
  • Previous searches can be re-run with the ‘r’ key in the cscope buffer. These are written in-place, overwriting the older results.
  • Fuzzy matching is now enabled/disabled for specific types of searches. This was implemented earlier, but the implementation had a bug and wasn’t working
  • xcscope.el can now work remotely over TRAMP
  • The cscope-index output now goes to the echo area instead of an explicit new buffer that the user must deal with
  • Fuzzy searching now works for non-trivial regex searches
  • The mouse face respects cscope-use-face
  • Better mouse support:
    • button3 opens a popup menu that runs prompt-less searches
    • shift-button3 reruns the last search on the point. This is thus even more prompt-less
  • Shift-return or Shift-mouse2 now open the result in the same window as the cscope buffer
  • Some bold highlighting in the cscope results: the sought term, the search directory
  • Removed the external ‘cscope-indexer’ script; this is now handled inside xcscope.el. Additionally the list of source directories to ignore and the list of filename extensions to index are now customizable in the emacs customization interface
  • Various cscope options (kernel mode, inverted index, etc) can now be accessed through the emacs variables

License and authorship

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

Contact

The maintainer is Dima Kogan <[email protected]>

More Repositories

1

feedgnuplot

Tool to plot realtime and stored data from the commandline, using gnuplot.
Perl
698
star
2

gnuplotlib

gnuplot for numpy
Python
242
star
3

vnlog

Process labelled tabular ASCII data using normal UNIX tools
Perl
158
star
4

mrcal

Next-generation camera-modeling toolkit
Python
153
star
5

ltrace

C
44
star
6

mrgingham

Chessboard corner-finder for a camera calibration system
C++
40
star
7

numpysane

more-reasonable core functionality for numpy
Python
28
star
8

libdogleg

Large-scale nonlinear least-squares optimization library for both sparse and dense problems
C
24
star
9

horizonator

Terrain renderer based on SRTM DEMs
C
24
star
10

memory_leak_instrumentation

Perl
13
star
11

PDL

Mirror of the PDL project
Perl
10
star
12

libminimath

Basic linear algebra for small matrices in C
C
9
star
13

osmgnuplot

Script to make it easy to plot OSM tiles in gnuplot
Perl
8
star
14

fltkVisionUtils

A library for simple integration of FLTK, openCV and image sources such as firewire (IIDC) cameras and video files. Includes some sample programs that show basic usage
C++
7
star
15

inaccessibility

Perl
5
star
16

PDL-Graphics-Gnuplot

Gnuplot-based plotting backend for PDL
Perl
5
star
17

notion-scripts

Debianization for the contributed scripts for the notion window manager
Lua
5
star
18

buildsystem

Build system used to manage Oblong Industries software
Makefile
4
star
19

pic-decompiler

Decompiler for PIC16 binaries
Perl
4
star
20

python-argparse-generate-manpages-example

Roff
4
star
21

clockfunction

Runs an executable, measuring execution time statistics for given functions
Python
3
star
22

flipbook

Flipbook maker
C++
2
star
23

dynamixel

Perl driver for dynamixel servo motors. This is the repo for Device::Dynamixel at CPAN
Perl
2
star
24

PDL-OpenCV

PDL bindings to OpenCV
Pure Data
2
star
25

mrbuild

Simple build system
Makefile
2
star
26

ntsb-wrecks

Plane-crash locations from NTSB reports
Perl
2
star
27

ricoh-download

Download images from Ricoh cameras over 802.11
Shell
2
star
28

blog

Less
2
star
29

FindGlobals

Finds all global state in a program by looking at the DWARF data
C
2
star
30

PDL-FFTW3

Perl
1
star
31

Backup-Manager

Shell
1
star
32

python_extensions_without_setuptools

Makefile
1
star
33

PDL-IO-Matlab_debianization

C
1
star
34

talk-feedgnuplot-vnlog

Makefile
1
star
35

toolchains

Sources for toolchain sources at http://toolchains.secretsauce.net
Shell
1
star
36

WormTracker

Vision-based tracker and data collector for analysis of nematode motion
C++
1
star
37

PDL-Triangle

PDL interface to the Triangle library
Pure Data
1
star
38

GL_image_display

Image-display library backed by OpenGL. Provided are a C library and a FLTK widget with C++ and Python interfaces
C
1
star