Mercurial > emacs
annotate lisp/cedet/semantic/symref/cscope.el @ 106303:d3af107622c7
* erc.texi (Development): Correction to git tutorial url.
author | Kevin Ryde <user42@zip.com.au> |
---|---|
date | Sat, 28 Nov 2009 20:36:05 +0000 |
parents | 83dde921cc1b |
children | 1d1d5d9bd884 |
rev | line source |
---|---|
104422
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
1 ;;; semantic/symref/cscope.el --- Semantic-symref support via cscope. |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2 |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3 ;;; Copyright (C) 2009 Free Software Foundation, Inc. |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
4 |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
5 ;; Author: Eric M. Ludlam <eric@siege-engine.com> |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
6 |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
7 ;; This file is part of GNU Emacs. |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
8 |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
9 ;; GNU Emacs is free software: you can redistribute it and/or modify |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
10 ;; it under the terms of the GNU General Public License as published by |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
11 ;; the Free Software Foundation, either version 3 of the License, or |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
12 ;; (at your option) any later version. |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
13 |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
14 ;; GNU Emacs is distributed in the hope that it will be useful, |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
17 ;; GNU General Public License for more details. |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
18 |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
19 ;; You should have received a copy of the GNU General Public License |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
20 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
21 |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
22 ;;; Commentary: |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
23 ;; |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
24 ;; Semantic symref support via cscope. |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
25 |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
26 (require 'cedet-cscope) |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
27 (require 'semantic/symref) |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
28 |
104456
6065d66f0c99
lisp/cedet/semantic/db-ref.el: Require semantic/db.
Chong Yidong <cyd@stupidchicken.com>
parents:
104422
diff
changeset
|
29 (defvar ede-minor-mode) |
6065d66f0c99
lisp/cedet/semantic/db-ref.el: Require semantic/db.
Chong Yidong <cyd@stupidchicken.com>
parents:
104422
diff
changeset
|
30 (declare-function ede-toplevel "ede/files") |
6065d66f0c99
lisp/cedet/semantic/db-ref.el: Require semantic/db.
Chong Yidong <cyd@stupidchicken.com>
parents:
104422
diff
changeset
|
31 (declare-function ede-project-root-directory "ede/files") |
6065d66f0c99
lisp/cedet/semantic/db-ref.el: Require semantic/db.
Chong Yidong <cyd@stupidchicken.com>
parents:
104422
diff
changeset
|
32 |
104422
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
33 ;;; Code: |
104486
1ca7a97e0322
lisp/cedet/semantic/symref.el: Revert last change.
Chong Yidong <cyd@stupidchicken.com>
parents:
104456
diff
changeset
|
34 ;;;###autoload |
104422
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
35 (defclass semantic-symref-tool-cscope (semantic-symref-tool-baseclass) |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
36 ( |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
37 ) |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
38 "A symref tool implementation using CScope. |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
39 The CScope command can be used to generate lists of tags in a way |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
40 similar to that of `grep'. This tool will parse the output to generate |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
41 the hit list. |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
42 |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
43 See the function `cedet-cscope-search' for more details.") |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
44 |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
45 (defmethod semantic-symref-perform-search ((tool semantic-symref-tool-cscope)) |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
46 "Perform a search with GNU Global." |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
47 (let* ((rootproj (when (and (featurep 'ede) ede-minor-mode) |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
48 (ede-toplevel))) |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
49 (default-directory (if rootproj |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
50 (ede-project-root-directory rootproj) |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
51 default-directory)) |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
52 ;; CScope has to be run from the project root where |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
53 ;; cscope.out is. |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
54 (b (cedet-cscope-search (oref tool :searchfor) |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
55 (oref tool :searchtype) |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
56 (oref tool :resulttype) |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
57 (oref tool :searchscope) |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
58 )) |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
59 ) |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
60 (semantic-symref-parse-tool-output tool b) |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
61 )) |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
62 |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
63 (defmethod semantic-symref-parse-tool-output-one-line ((tool semantic-symref-tool-cscope)) |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
64 "Parse one line of grep output, and return it as a match list. |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
65 Moves cursor to end of the match." |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
66 (cond ((eq (oref tool :resulttype) 'file) |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
67 ;; Search for files |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
68 (when (re-search-forward "^\\([^\n]+\\)$" nil t) |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
69 (match-string 1))) |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
70 ((eq (oref tool :searchtype) 'tagcompletions) |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
71 ;; Search for files |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
72 (when (re-search-forward "^[^ ]+ [^ ]+ [^ ]+ \\(.*\\)$" nil t) |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
73 (let ((subtxt (match-string 1)) |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
74 (searchtxt (oref tool :searchfor))) |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
75 (if (string-match (concat "\\<" searchtxt "\\(\\w\\|\\s_\\)*\\>") |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
76 subtxt) |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
77 (match-string 0 subtxt) |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
78 ;; We have to return something at this point. |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
79 subtxt))) |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
80 ) |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
81 (t |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
82 (when (re-search-forward "^\\([^ ]+\\) [^ ]+ \\([0-9]+\\) " nil t) |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
83 (cons (string-to-number (match-string 2)) |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
84 (expand-file-name (match-string 1))) |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
85 )))) |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
86 |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
87 (provide 'semantic/symref/cscope) |
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
88 |
104486
1ca7a97e0322
lisp/cedet/semantic/symref.el: Revert last change.
Chong Yidong <cyd@stupidchicken.com>
parents:
104456
diff
changeset
|
89 ;; Local variables: |
1ca7a97e0322
lisp/cedet/semantic/symref.el: Revert last change.
Chong Yidong <cyd@stupidchicken.com>
parents:
104456
diff
changeset
|
90 ;; generated-autoload-file: "../loaddefs.el" |
1ca7a97e0322
lisp/cedet/semantic/symref.el: Revert last change.
Chong Yidong <cyd@stupidchicken.com>
parents:
104456
diff
changeset
|
91 ;; generated-autoload-load-name: "semantic/symref/cscope" |
1ca7a97e0322
lisp/cedet/semantic/symref.el: Revert last change.
Chong Yidong <cyd@stupidchicken.com>
parents:
104456
diff
changeset
|
92 ;; End: |
1ca7a97e0322
lisp/cedet/semantic/symref.el: Revert last change.
Chong Yidong <cyd@stupidchicken.com>
parents:
104456
diff
changeset
|
93 |
105377 | 94 ;; arch-tag: 7c0a4e02-ade4-407a-9df7-4f948bd61a19 |
104422
36f56620b2ae
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
95 ;;; semantic/symref/cscope.el ends here |