Mercurial > emacs
annotate lisp/cedet/cedet-global.el @ 106745:417baf3f58fe
* gnus-util.el (gnus-invisible-p, gnus-next-char-property-change)
(gnus-previous-char-property-change): New functions.
* gnus-sum.el (gnus-forward-line-ignore-invisible): Use them.
author | Katsumi Yamaoka <yamaoka@jpl.org> |
---|---|
date | Wed, 06 Jan 2010 00:07:08 +0000 |
parents | 019d906c8f48 |
children | 1d1d5d9bd884 |
rev | line source |
---|---|
105241 | 1 ;;; cedet-global.el --- GNU Global support for CEDET. |
2 | |
3 ;; Copyright (C) 2008, 2009 Free Software Foundation, Inc. | |
4 | |
5 ;; Author: Eric M. Ludlam <eric@siege-engine.com> | |
6 | |
7 ;; This file is part of GNU Emacs. | |
8 | |
9 ;; GNU Emacs is free software: you can redistribute it and/or modify | |
10 ;; it under the terms of the GNU General Public License as published by | |
11 ;; the Free Software Foundation, either version 3 of the License, or | |
12 ;; (at your option) any later version. | |
13 | |
14 ;; GNU Emacs is distributed in the hope that it will be useful, | |
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 ;; GNU General Public License for more details. | |
18 | |
19 ;; You should have received a copy of the GNU General Public License | |
20 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | |
21 | |
22 ;;; Commentary: | |
23 ;; | |
24 ;; Basic support for calling GNU Global, and testing version numbers. | |
25 | |
26 (declare-function inversion-check-version "inversion") | |
27 | |
28 (defvar cedet-global-min-version "5.0" | |
29 "Minimum version of GNU global required.") | |
30 | |
31 (defcustom cedet-global-command "global" | |
32 "Command name for the GNU Global executable." | |
33 :type 'string | |
34 :group 'cedet) | |
35 | |
36 ;;; Code: | |
37 (defun cedet-gnu-global-search (searchtext texttype type scope) | |
38 "Perform a search with GNU Global, return the created buffer. | |
39 SEARCHTEXT is text to find. | |
40 TEXTTYPE is the type of text, such as 'regexp, 'string, 'tagname, | |
41 'tagregexp, or 'tagcompletions. | |
42 TYPE is the type of search, meaning that SEARCHTEXT is compared to | |
43 filename, tagname (tags table), references (uses of a tag) , or | |
44 symbol (uses of something not in the tag table.) | |
45 SCOPE is the scope of the search, such as 'project or 'subdirs." | |
46 (let ((flgs (cond ((eq type 'file) | |
47 "-a") | |
48 (t "-xa"))) | |
49 (scopeflgs (cond | |
50 ((eq scope 'project) | |
51 "" | |
52 ) | |
53 ((eq scope 'target) | |
54 "l"))) | |
55 (stflag (cond ((or (eq texttype 'tagname) | |
56 (eq texttype 'tagregexp)) | |
57 "") | |
58 ((eq texttype 'tagcompletions) | |
59 "c") | |
60 ((eq texttype 'regexp) | |
61 "g") | |
62 (t "r")))) | |
63 (cedet-gnu-global-call (list (concat flgs scopeflgs stflag) | |
64 searchtext)))) | |
65 | |
66 (defun cedet-gnu-global-call (flags) | |
67 "Call GNU Global with the list of FLAGS." | |
68 (let ((b (get-buffer-create "*CEDET Global*")) | |
69 (cd default-directory)) | |
105799
3fe6da4a95a9
* cedet/srecode/srt-mode.el (semantic-analyze-possible-completions):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105377
diff
changeset
|
70 (with-current-buffer b |
105241 | 71 (setq default-directory cd) |
72 (erase-buffer)) | |
73 (apply 'call-process cedet-global-command | |
74 nil b nil | |
75 flags) | |
76 b)) | |
77 | |
78 (defun cedet-gnu-global-expand-filename (filename) | |
79 "Expand the FILENAME with GNU Global. | |
80 Return a fully qualified filename." | |
81 (interactive "sFile: ") | |
105799
3fe6da4a95a9
* cedet/srecode/srt-mode.el (semantic-analyze-possible-completions):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105377
diff
changeset
|
82 (let ((ans (with-current-buffer (cedet-gnu-global-call (list "-Pa" filename)) |
105241 | 83 (goto-char (point-min)) |
84 (if (looking-at "global: ") | |
85 (error "GNU Global not available") | |
86 (split-string (buffer-string) "\n" t))))) | |
106197
019d906c8f48
* cedet/srecode/map.el (srecode-get-maps):
Chong Yidong <cyd@stupidchicken.com>
parents:
105799
diff
changeset
|
87 (when (called-interactively-p 'interactive) |
105241 | 88 (if ans |
89 (if (= (length ans) 1) | |
90 (message "%s" (car ans)) | |
91 (message "%s + %d others" (car ans) | |
92 (length (cdr ans)))) | |
93 (error "No file found"))) | |
94 ans)) | |
95 | |
96 (defun cedet-gnu-global-show-root () | |
97 "Show the root of a GNU Global area under the current buffer." | |
98 (interactive) | |
99 (message "%s" (cedet-gnu-global-root))) | |
100 | |
101 (defun cedet-gnu-global-root (&optional dir) | |
102 "Return the root of any GNU Global scanned project. | |
103 If a default starting DIR is not specified, the current buffer's | |
104 `default-directory' is used." | |
105 (let ((default-directory (or dir default-directory))) | |
105799
3fe6da4a95a9
* cedet/srecode/srt-mode.el (semantic-analyze-possible-completions):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105377
diff
changeset
|
106 (with-current-buffer (cedet-gnu-global-call (list "-pq")) |
105241 | 107 (goto-char (point-min)) |
108 (when (not (eobp)) | |
109 (file-name-as-directory | |
110 (buffer-substring (point) (point-at-eol))))))) | |
111 | |
112 (defun cedet-gnu-global-version-check (&optional noerror) | |
113 "Check the version of the installed GNU Global command. | |
114 If optional programatic argument NOERROR is non-nil, then | |
115 instead of throwing an error if Global isn't available, then | |
116 return nil." | |
117 (interactive) | |
118 (require 'inversion) | |
119 (let ((b (condition-case nil | |
120 (cedet-gnu-global-call (list "--version")) | |
121 (error nil))) | |
122 (rev nil)) | |
123 (if (not b) | |
124 (progn | |
106197
019d906c8f48
* cedet/srecode/map.el (srecode-get-maps):
Chong Yidong <cyd@stupidchicken.com>
parents:
105799
diff
changeset
|
125 (when (called-interactively-p 'interactive) |
105241 | 126 (message "GNU Global not found.")) |
127 nil) | |
105799
3fe6da4a95a9
* cedet/srecode/srt-mode.el (semantic-analyze-possible-completions):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105377
diff
changeset
|
128 (with-current-buffer b |
105241 | 129 (goto-char (point-min)) |
130 (re-search-forward "GNU GLOBAL \\([0-9.]+\\)" nil t) | |
131 (setq rev (match-string 1)) | |
132 (if (inversion-check-version rev nil cedet-global-min-version) | |
133 (if noerror | |
134 nil | |
135 (error "Version of GNU Global is %s. Need at least %s" | |
136 rev cedet-global-min-version)) | |
137 ;; Else, return TRUE, as in good enough. | |
106197
019d906c8f48
* cedet/srecode/map.el (srecode-get-maps):
Chong Yidong <cyd@stupidchicken.com>
parents:
105799
diff
changeset
|
138 (when (called-interactively-p 'interactive) |
105241 | 139 (message "GNU Global %s - Good enough for CEDET." rev)) |
140 t))))) | |
141 | |
142 (defun cedet-gnu-global-scan-hits (buffer) | |
143 "Scan all the hits from the GNU Global output BUFFER." | |
144 (let ((hits nil) | |
145 (r1 "^\\([^ ]+\\) +\\([0-9]+\\) \\([^ ]+\\) ")) | |
105799
3fe6da4a95a9
* cedet/srecode/srt-mode.el (semantic-analyze-possible-completions):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105377
diff
changeset
|
146 (with-current-buffer buffer |
105241 | 147 (goto-char (point-min)) |
148 (while (re-search-forward r1 nil t) | |
149 (setq hits (cons (cons (string-to-number (match-string 2)) | |
150 (match-string 3)) | |
151 hits))) | |
152 ;; Return the results | |
153 (nreverse hits)))) | |
154 | |
155 (provide 'cedet-global) | |
156 | |
105377 | 157 ;; arch-tag: 0d0d3ac2-91ef-4820-bb2b-1d59ccf38392 |
105241 | 158 ;;; cedet-global.el ends here |