Mercurial > emacs
annotate lisp/cedet/cedet-cscope.el @ 104454:e4842bf0f303
lisp/cedet/semantic/symref/filter.el: New file.
lisp/cedet/semantic/idle.el (semantic-symref-hits-in-region): Require
semantic/symref/filter.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Sat, 05 Sep 2009 21:09:25 +0000 |
parents | e6546ef2442b |
children |
rev | line source |
---|---|
104407
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1 ;;; cedet-cscope.el --- CScope support for CEDET |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2 |
104408
e6546ef2442b
cedet-cscope.el: Fix copyright header.
Chong Yidong <cyd@stupidchicken.com>
parents:
104407
diff
changeset
|
3 ;;; Copyright (C) 2009 Free Software Foundation, Inc. |
104407
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
4 |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
5 ;; Author: Eric M. Ludlam <zappo@gnu.org> |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
6 |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
7 ;; This file is part of GNU Emacs. |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
8 |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
9 ;; GNU Emacs is free software: you can redistribute it and/or modify |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
10 ;; it under the terms of the GNU General Public License as published by |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
11 ;; the Free Software Foundation, either version 3 of the License, or |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
12 ;; (at your option) any later version. |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
13 |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
14 ;; GNU Emacs is distributed in the hope that it will be useful, |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
17 ;; GNU General Public License for more details. |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
18 |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
19 ;; You should have received a copy of the GNU General Public License |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
20 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
21 |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
22 ;;; Commentary: |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
23 ;; |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
24 ;; Support using CScope for symbol lookups. |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
25 |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
26 ;;; Code: |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
27 |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
28 (defvar cedet-cscope-min-version "16.0" |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
29 "Minimum version of GNU global required.") |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
30 |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
31 (defcustom cedet-cscope-command "cscope" |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
32 "Command name for the CScope executable." |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
33 :type 'string |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
34 :group 'cedet) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
35 |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
36 (defun cedet-cscope-search (searchtext texttype type scope) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
37 "Perform a search with CScope, return the created buffer. |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
38 SEARCHTEXT is text to find. |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
39 TEXTTYPE is the type of text, such as 'regexp, 'string, 'tagname, |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
40 'tagregexp, or 'tagcompletions. |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
41 TYPE is the type of search, meaning that SEARCHTEXT is compared to |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
42 filename, tagname (tags table), references (uses of a tag) , or |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
43 symbol (uses of something not in the tag table.) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
44 SCOPE is the scope of the search, such as 'project or 'subdirs." |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
45 ;; CScope is an interactive program. It uses number flags |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
46 ;; in order to perform command line searches. Useful for this |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
47 ;; tool are: |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
48 ;; |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
49 ;; -0 = Find C symbol |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
50 ;; -1 = Find global definition |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
51 ;; -3 = Find references |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
52 ;; -6 = Find egrep pattern |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
53 ;; -7 = Find file |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
54 (let ((idx (cond ((eq type 'file) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
55 "-7") |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
56 ;; Non files are symbols and such |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
57 ((eq texttype 'tagname) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
58 "-1") |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
59 ((eq texttype 'tagregexp) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
60 "-0") |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
61 ((eq texttype 'tagcompletions) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
62 (setq searchtext (concat "^" searchtext ".*")) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
63 "-1") |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
64 ((eq texttype 'regexp) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
65 "-5") |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
66 (t |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
67 "-3") |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
68 ) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
69 ) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
70 ) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
71 (cedet-cscope-call (list "-d" "-L" idx searchtext)))) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
72 |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
73 (defun cedet-cscope-call (flags) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
74 "Call CScope with the list of FLAGS." |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
75 (let ((b (get-buffer-create "*CEDET CScope*")) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
76 (cd default-directory) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
77 ) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
78 (save-excursion |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
79 (set-buffer b) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
80 (setq default-directory cd) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
81 (erase-buffer)) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
82 (apply 'call-process cedet-cscope-command |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
83 nil b nil |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
84 flags) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
85 b)) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
86 |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
87 (defun cedet-cscope-expand-filename (filename) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
88 "Expand the FILENAME with CScope. |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
89 Return a fully qualified filename." |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
90 (interactive "sFile: ") |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
91 (let* ((ans1 (save-excursion |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
92 (set-buffer (cedet-cscope-call (list "-d" "-L" "-7" filename))) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
93 (goto-char (point-min)) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
94 (if (looking-at "[^ \n]*cscope: ") |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
95 (error "CScope not available") |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
96 (split-string (buffer-string) "\n" t)))) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
97 (ans2 (mapcar (lambda (hit) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
98 (expand-file-name (car (split-string hit " ")))) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
99 ans1))) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
100 (when (interactive-p) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
101 (if ans2 |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
102 (if (= (length ans2) 1) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
103 (message "%s" (car ans2)) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
104 (message "%s + %d others" (car ans2) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
105 (length (cdr ans2)))) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
106 (error "No file found"))) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
107 ans2)) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
108 |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
109 (defun cedet-cscope-support-for-directory (&optional dir) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
110 "Return non-nil if CScope has a support file for DIR. |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
111 If DIR is not supplied, use the current default directory. |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
112 This works by running cscope on a bogus symbol, and looking for |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
113 the error code." |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
114 (save-excursion |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
115 (let ((default-directory (or dir default-directory))) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
116 (set-buffer (cedet-cscope-call (list "-d" "-L" "-7" "moose"))) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
117 (goto-char (point-min)) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
118 (if (looking-at "[^ \n]*cscope: ") |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
119 nil |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
120 t)))) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
121 |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
122 (declare-function inversion-check-version "inversion") |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
123 |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
124 (defun cedet-cscope-version-check (&optional noerror) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
125 "Check the version of the installed CScope command. |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
126 If optional programatic argument NOERROR is non-nil, then |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
127 instead of throwing an error if Global isn't available, then |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
128 return nil." |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
129 (interactive) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
130 (require 'inversion) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
131 (let ((b (condition-case nil |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
132 (cedet-cscope-call (list "-V")) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
133 (error nil))) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
134 (rev nil)) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
135 (if (not b) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
136 (progn |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
137 (when (interactive-p) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
138 (message "CScope not found.")) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
139 nil) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
140 (save-excursion |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
141 (set-buffer b) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
142 (goto-char (point-min)) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
143 (re-search-forward "cscope: version \\([0-9.]+\\)" nil t) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
144 (setq rev (match-string 1)) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
145 (if (inversion-check-version rev nil cedet-cscope-min-version) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
146 (if noerror |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
147 nil |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
148 (error "Version of CScope is %s. Need at least %s" |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
149 rev cedet-cscope-min-version)) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
150 ;; Else, return TRUE, as in good enough. |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
151 (when (interactive-p) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
152 (message "CScope %s - Good enough for CEDET." rev)) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
153 t))))) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
154 |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
155 (provide 'cedet-cscope) |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
156 |
4af663a1c4ab
cedet-cscope.el, cedet-edebug.el, cedet-global.el, cedet-idutils.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
157 ;;; cedet-cscope.el ends here |