git://git.code.sf.net/p/cscope/cscope https://git.code.sf.net/p/cscope/cscope https://github.com/welash/cscope.git
$ apt-get source cscope
$ cscope-indexer -r
option | description |
---|---|
-f <database-file> | 出力先データベースのファイル名を指定する(default: cscope.out) |
-i <list-file> | リストファイル(ファイルのインデックスを記録したファイル)の名前を指定する(default: cscope.files) |
-l | データベースファイルの生成・更新を抑制する。 但し、リストファイルが生成済みであること |
-r | 再帰的にディレクトリを走査する。 このオプションがない場合、走査対象はカレントディレクトリに限定される。 |
-v | 冗長モード |
gcc bison flex libncurses5
$ autoreconf -i -s
/* Define to 1 if you have the `lstat' function. */ #undef HAVE_LSTAT // この行を /* */ でコメントアウトする
$ ./configure
/* This can happen on only vaguely Unix-ish platforms... */ #ifndef HAVE_LSTAT #include <sys/stat.h> # この include文が足りてないので追加する。 # define lstat(file,buf) stat(file,buf) #endif
$ make
find $DIR \( -type f -o -type l \)
if [ "X$EXCLUDE" = "X" ] then find -L $DIR \( -xtype f -o -xtype l \) else find -L $DIR \( -xtype f -o -xtype l \) | grep -v $EXCLUDE fi
(setq c++-mode-hook '(lambda () (setq cscope-minor-mode t) ))のように ${HOME}/.emacs などの適切な初期設定ファイルに記述しておく。
C-c s L
key | description | remark |
---|---|---|
C-c s s | シンボルを指定して探す(定義・呼び出し箇所等の一覧をリストアップする) | |
C-c s C | 指定したシンボルの呼び出し箇所をリストアップ | |
C-c s G | 指定したシンボルの定義(宣言ではなく)、またはそれに関する定義をリストアップする | |
C-c s n | 次のシンボルへ Jump | |
C-c s p | 前のシンボルへ Jump | |
C-c s t | テキストを検索 | symbol や定義意外のテキスト全般はこれで検索する |
C-c s f | ファイルを検索 | 1つだけ見つかればそれを自動的に開く |
C-c s i | そのファイルを include している include 文を検索 |
;; * 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 = 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. ;;
C-c sと打っても
C-c s is undefinedとメッセージが出て動作しない場合は、xcscope.el が提供するマイナーモードに入れていない可能性がある。
; c-mode での設定 (setq c-mode-hook '(lambda () (cscope-minor-mode) )) ; c++-mode でも同様に... (setq c++-mode-hook '(lambda () (cscope-minor-mode) ))
$ git clone https://github.com/ameyp/ascope
(setq load-path (cons (expand-file-name "~/.emacs.d/site-lisp/ascope") load-path)) (load-library "~/.emacs.d/site-lisp/ascope/ascope.el") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Original is from xcscope.el (defvar cscope-minor-mode-keymap (let ((map (make-sparse-keymap))) ;; xemacs has various issues with (cscope-mouse-popup-menu-or-search), so I ;; don't use that function for xemacs. Its popup menu support won't be as ;; good (cscope will still prompt for the search term) ;(if cscope-running-in-xemacs ; (progn ; (define-key map [(shift button3)] 'cscope-mouse-search-again)) ; (define-key map [mouse-3] 'cscope-mouse-popup-menu-or-search) ; (define-key map [S-mouse-3] 'cscope-mouse-search-again)) ;; The following line corresponds to be beginning of the "Cscope" menu. (define-key map "\C-css" 'cscope-find-this-symbol) (define-key map "\C-csd" 'cscope-find-global-definition) (define-key map "\C-csg" 'cscope-find-global-definition) ; (define-key map "\C-csG" 'cscope-find-global-definition-no-prompting) ; (define-key map "\C-cs=" 'cscope-find-assignments-to-this-symbol) (define-key map "\C-csc" 'cscope-find-functions-calling-this-function) (define-key map "\C-csC" 'cscope-find-called-functions) (define-key map "\C-cst" 'cscope-find-this-text-string) ; (define-key map "\C-cse" 'cscope-find-egrep-pattern) (define-key map "\C-csf" 'cscope-find-this-file) (define-key map "\C-csi" 'cscope-find-files-including-file) ;; --- (The '---' indicates that this line corresponds to a menu separator.) ; (define-key map "\C-csb" 'cscope-display-buffer) ; (define-key map "\C-csB" 'cscope-display-buffer-toggle) ; (define-key map "\C-csn" 'cscope-history-forward-line-current-result) ; (define-key map "\C-csN" 'cscope-history-forward-file-current-result) ; (define-key map "\C-csp" 'cscope-history-backward-line-current-result) ; (define-key map "\C-csP" 'cscope-history-backward-file-current-result) ; (define-key map "\C-csu" 'cscope-pop-mark) ;; --- ; (define-key map "\C-csa" 'cscope-set-initial-directory) ; (define-key map "\C-csA" 'cscope-unset-initial-directory) ;; --- ; (define-key map "\C-csL" 'cscope-create-list-of-files-to-index) ; (define-key map "\C-csI" 'cscope-index-files) ; (define-key map "\C-csE" 'cscope-edit-list-of-files-to-index) ; (define-key map "\C-csW" 'cscope-tell-user-about-directory) ; (define-key map "\C-csS" 'cscope-tell-user-about-directory) ; (define-key map "\C-csT" 'cscope-tell-user-about-directory) ; (define-key map "\C-csD" 'cscope-dired-directory) ;; The previous line corresponds to be end of the "Cscope" menu. ;; (START Add) -------------------------------------- ;; ここは xcscope.el にないものを追加 (define-key map "\C-csa" 'cscope-setup) ;; (END Add) -------------------------------------- map) "The global cscope keymap") (require 'ascope)
$ autoreconf -i -s $ ./configure $ make src/cscope が出来ていれば成功。