📄 xcscope.el
字号:
; -*-Emacs-Lisp-*-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; File: xcscope.el; RCS: $RCSfile: xcscope.el,v $ $Revision: 1.14 $ $Date: 2002/04/10 16:59:00 $ $Author: darrylo $; Description: cscope interface for (X)Emacs; Author: Darryl Okahata; Created: Wed Apr 19 17:03:38 2000; Modified: Thu Apr 4 17:22:22 2002 (Darryl Okahata) darrylo@soco.agilent.com; Language: Emacs-Lisp; Package: N/A; Status: Experimental;; (C) Copyright 2000, 2001, 2002, Darryl Okahata <darrylo@sonic.net>,; all rights reserved.; GNU Emacs enhancements (C) Copyright 2001,; Triet H. Lai <thlai@mail.usyd.edu.au>; Fuzzy matching and navigation code (C) Copyright 2001,; Steven Elliott <selliott4@austin.rr.com>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALPHA VERSION 0.96;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; This program is free software; you can redistribute it and/or modify;; it under the terms of the GNU General Public License as published by;; the Free Software Foundation; either version 2, or (at your option);; any later version.;;;; This program is distributed in the hope that it will be useful,;; but WITHOUT ANY WARRANTY; without even the implied warranty of;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the;; GNU General Public License for more details.;;;; You should have received a copy of the GNU General Public License;; along with GNU Emacs; see the file COPYING. If not, write to;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; This is a cscope interface for (X)Emacs.;; It currently runs under Unix only.;;;; Using cscope, you can easily search for where symbols are used and defined.;; Cscope is designed to answer questions like:;;;; 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?;;;; Send comments to one of: darrylo@soco.agilent.com;; darryl_okahata@agilent.com;; darrylo@sonic.net;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ***** INSTALLATION *****;;;; * NOTE: this interface currently runs under Unix only.;;;; This module needs a shell script called "cscope-indexer", which;; should have been supplied along with this emacs-lisp file. The;; purpose of "cscope-indexer" is to create and optionally maintain;; the cscope databases. If all of your source files are in one;; directory, you don't need this script; it's very nice to have,;; though, as it handles recursive subdirectory indexing, and can be;; used in a nightly or weekly cron job to index very large source;; repositories. See the beginning of the file, "cscope-indexer", for;; usage information.;;;; Installation steps:;;;; 0. (It is, of course, assumed that cscope is already properly;; installed on the current system.);;;; 1. Install the "cscope-indexer" script into some convenient;; directory in $PATH. The only real constraint is that (X)Emacs;; must be able to find and execute it. You may also have to edit;; the value of PATH in the script, although this is unlikely; the;; majority of people should be able to use the script, "as-is".;;;; 2. Make sure that the "cscope-indexer" script is executable. In;; particular, if you had to ftp this file, it is probably no;; longer executable.;;;; 3. Put this emacs-lisp file somewhere where (X)Emacs can find it. It;; basically has to be in some directory listed in "load-path".;;;; 4. Edit your ~/.emacs file to add the line:;;;; (require 'xcscope);;;; 5. If you intend to use xcscope.el often you can optionally edit your;; ~/.emacs file to add keybindings that reduce the number of keystrokes;; required. For example, the following will add "C-f#" keybindings, which;; are easier to type than the usual "C-c s" prefixed keybindings. Note;; that specifying "global-map" instead of "cscope:map" makes the;; keybindings available in all buffers:;;;; (define-key global-map [(control f3)] 'cscope-set-initial-directory);; (define-key global-map [(control f4)] 'cscope-unset-initial-directory);; (define-key global-map [(control f5)] 'cscope-find-this-symbol);; (define-key global-map [(control f6)] 'cscope-find-global-definition);; (define-key global-map [(control f7)];; 'cscope-find-global-definition-no-prompting);; (define-key global-map [(control f8)] 'cscope-pop-mark);; (define-key global-map [(control f9)] 'cscope-next-symbol);; (define-key global-map [(control f10)] 'cscope-next-file);; (define-key global-map [(control f11)] 'cscope-prev-symbol);; (define-key global-map [(control f12)] 'cscope-prev-file);; (define-key global-map [(meta f9)] 'cscope-display-buffer);; (defin-ekey global-map [(meta f10)] 'cscope-display-buffer-toggle);;;; 6. Restart (X)Emacs. That's it.;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ***** USING THIS MODULE *****;;;; * Basic usage:;;;; If all of your C/C++/lex/yacc source files are in the same;; directory, you can just start using this module. If your files are;; spread out over multiple directories, see "Advanced usage", below.;;;; Just edit a source file, and use the pull-down or pop-up (button 3);; menus to select one of:;;;; Find symbol;; Find global definition;; Find called functions;; Find functions calling a function;; Find text string;; Find egrep pattern;; Find a file;; Find files #including a file;;;; The cscope database will be automatically created in the same;; directory as the source files (assuming that you've never used;; cscope before), and a buffer will pop-up displaying the results.;; 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].;;;; Hopefully, the interface should be fairly intuitive.;;;;;; * Locating the cscope databases:;;;; This module will first use the variable, `cscope-database-regexps',;; to search for a suitable database directory. If a database location;; cannot be found using this variable then a search is begun at the;; variable, `cscope-initial-directory', if set, or the current;; directory otherwise. If the directory is not a cscope database;; directory then the directory's parent, parent's parent, etc. is;; searched until a cscope database directory is found, or the root;; directory is reached. If the root directory is reached, the current;; directory will be used.;;;; A cscope database directory is one in which EITHER a cscope database;; file (e.g., "cscope.out") OR a cscope file list (e.g.,;; "cscope.files") exists. If only "cscope.files" exists, the;; corresponding "cscope.out" will be automatically created by cscope;; when a search is done. By default, the cscope database file is called;; "cscope.out", but this can be changed (on a global basis) via the;; variable, `cscope-database-file'. There is limited support for cscope;; databases that are named differently than that given by;; `cscope-database-file', using the variable, `cscope-database-regexps'.;;;; Note that the variable, `cscope-database-regexps', is generally not;; needed, as the normal hierarchical database search is sufficient;; for placing and/or locating the cscope databases. However, there;; may be cases where it makes sense to place the cscope databases;; away from where the source files are kept; in this case, this;; variable is used to determine the mapping. One use for this;; variable is when you want to share the database file with other;; users; in this case, the database may be located in a directory;; separate from the source files. ;;;; Setting the variable, `cscope-initial-directory', is useful when a;; search is to be expanded by specifying a cscope database directory;; that is a parent of the directory that this module would otherwise;; use. For example, consider a project that contains the following;; cscope database directories:;;;; /users/jdoe/sources;; /users/jdoe/sources/proj1;; /users/jdoe/sources/proj2;;;; If a search is initiated from a .c file in /users/jdoe/sources/proj1;; then (assuming the variable, `cscope-database-regexps', is not set);; /users/jdoe/sources/proj1 will be used as the cscope data base directory.;; Only matches in files in /users/jdoe/sources/proj1 will be found. This;; can be remedied by typing "C-c s a" and then "M-del" to remove single;; path element in order to use a cscope database directory of;; /users/jdoe/sources. Normal searching can be restored by typing "C-c s A".;;;;;; * Keybindings:;;;; All keybindings use the "C-c s" prefix, but are usable only while;; editing a source file, or in the cscope results buffer:;;;; C-c s s Find 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.;;;;;; * Advanced usage:;;;; If the source files are spread out over multiple directories,;; you've got a few choices:;;;; [ NOTE: you will need to have the script, "cscope-indexer",;; properly installed in order for the following to work. ];;;; 1. If all of the directories exist below a common directory;; (without any extraneous, unrelated subdirectories), you can tell;; this module to place the cscope database into the top-level,;; common directory. This assumes that you do not have any cscope;; databases in any of the subdirectories. If you do, you should;; delete them; otherwise, they will take precedence over the;; top-level database.;;;; If you do have cscope databases in any subdirectory, the;; following instructions may not work right.;;;; It's pretty easy to tell this module to use a top-level, common;; directory:;;;; a. Make sure that the menu pick, "Cscope/Index recursively", is;; checked (the default value).;;;; b. Select the menu pick, "Cscope/Create list and index", and;; specify the top-level directory. This will run the script,;; "cscope-indexer", in the background, so you can do other;; things if indexing takes a long time. A list of files to;; index will be created in "cscope.files", and the cscope;; database will be created in "cscope.out".
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -