Mercurial > emacs
annotate lisp/cedet/cedet-idutils.el @ 112013:f11676feb984
Fix up last change.
* lisp/emacs-lisp/bytecomp.el (byte-compile-output-docform): Fix up use of
print-number-table.
* src/print.c (PRINT_NUMBER_OBJECT, PRINT_NUMBER_STATUS): Remove.
(print_preprocess): Fix handling of uninterned symbols in last change.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Wed, 22 Dec 2010 19:00:12 -0500 |
parents | b799d38f522a |
children | 417b1e4d63cd |
rev | line source |
---|---|
105241 | 1 ;;; cedet-idutils.el --- ID Utils support for CEDET. |
2 | |
106815 | 3 ;; Copyright (C) 2009, 2010 Free Software Foundation, Inc. |
105241 | 4 |
5 ;; Author: Eric M. Ludlam <eric@siege-engine.com> | |
6 ;; Version: 0.2 | |
7 ;; Keywords: OO, lisp | |
110015
280c8ae2476d
Add "Package:" file headers to denote built-in packages.
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
8 ;; Package: cedet |
105241 | 9 |
10 ;; This file is part of GNU Emacs. | |
11 | |
12 ;; GNU Emacs is free software: you can redistribute it and/or modify | |
13 ;; it under the terms of the GNU General Public License as published by | |
14 ;; the Free Software Foundation, either version 3 of the License, or | |
15 ;; (at your option) any later version. | |
16 | |
17 ;; GNU Emacs is distributed in the hope that it will be useful, | |
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 ;; GNU General Public License for more details. | |
21 | |
22 ;; You should have received a copy of the GNU General Public License | |
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | |
24 | |
25 ;;; Commentary: | |
26 ;; | |
27 ;; Basic support calling ID Utils functions, and checking version | |
28 ;; numbers. | |
29 | |
30 ;;; Code: | |
31 | |
32 (declare-function inversion-check-version "inversion") | |
33 | |
34 (defvar cedet-idutils-min-version "4.0" | |
35 "Minimum version of ID Utils required.") | |
36 | |
37 (defcustom cedet-idutils-file-command "fnid" | |
38 "Command name for the ID Utils executable for searching file names." | |
39 :type 'string | |
40 :group 'cedet) | |
41 | |
42 (defcustom cedet-idutils-token-command "lid" | |
43 "Command name for the ID Utils executable for searching for tokens." | |
44 :type 'string | |
45 :group 'cedet) | |
46 | |
110526
b150a06c6999
Synch EDE to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
47 (defcustom cedet-idutils-make-command "mkid" |
b150a06c6999
Synch EDE to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
48 "Command name for the ID Utils executable for creating token databases." |
b150a06c6999
Synch EDE to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
49 :type 'string |
b150a06c6999
Synch EDE to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
50 :group 'cedet) |
b150a06c6999
Synch EDE to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
51 |
105241 | 52 (defun cedet-idutils-search (searchtext texttype type scope) |
105325 | 53 "Perform a search with ID Utils, return the created buffer. |
105241 | 54 SEARCHTEXT is text to find. |
55 TEXTTYPE is the type of text, such as 'regexp, 'string, 'tagname, | |
56 'tagregexp, or 'tagcompletions. | |
57 TYPE is the type of search, meaning that SEARCHTEXT is compared to | |
58 filename, tagname (tags table), references (uses of a tag) , or | |
59 symbol (uses of something not in the tag table.) | |
60 SCOPE is the scope of the search, such as 'project or 'subdirs. | |
61 Note: Scope is not yet supported." | |
62 (if (eq type 'file) | |
63 ;; Calls for file stuff is very simple. | |
64 (cedet-idutils-fnid-call (list searchtext)) | |
65 ;; Calls for text searches is more complex. | |
66 (let* ((resultflg (if (eq texttype 'tagcompletions) | |
67 (list "--key=token") | |
68 (list "--result=grep"))) | |
69 (scopeflgs nil) ; (cond ((eq scope 'project) "" ) ((eq scope 'target) "l"))) | |
70 (stflag (cond ((or (eq texttype 'tagname) | |
71 (eq texttype 'tagregexp)) | |
72 (list "-r" "-w")) | |
73 ((eq texttype 'tagcompletions) | |
74 ;; Add regex to search text for beginning of char. | |
75 (setq searchtext (concat "^" searchtext)) | |
76 (list "-r" "-s" )) | |
77 ((eq texttype 'regexp) | |
78 (list "-r")) | |
79 ;; t means 'symbol | |
80 (t (list "-l" "-w")))) | |
81 ) | |
82 (cedet-idutils-lid-call (append resultflg scopeflgs stflag | |
83 (list searchtext)))))) | |
84 | |
85 (defun cedet-idutils-fnid-call (flags) | |
86 "Call ID Utils fnid with the list of FLAGS. | |
87 Return the created buffer with with program output." | |
88 (let ((b (get-buffer-create "*CEDET fnid*")) | |
89 (cd default-directory) | |
90 ) | |
105799
3fe6da4a95a9
* cedet/srecode/srt-mode.el (semantic-analyze-possible-completions):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105377
diff
changeset
|
91 (with-current-buffer b |
105241 | 92 (setq default-directory cd) |
93 (erase-buffer)) | |
94 (apply 'call-process cedet-idutils-file-command | |
95 nil b nil | |
96 flags) | |
97 b)) | |
98 | |
99 (defun cedet-idutils-lid-call (flags) | |
100 "Call ID Utils lid with the list of FLAGS. | |
101 Return the created buffer with with program output." | |
102 (let ((b (get-buffer-create "*CEDET lid*")) | |
103 (cd default-directory) | |
104 ) | |
105799
3fe6da4a95a9
* cedet/srecode/srt-mode.el (semantic-analyze-possible-completions):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105377
diff
changeset
|
105 (with-current-buffer b |
105241 | 106 (setq default-directory cd) |
107 (erase-buffer)) | |
108 (apply 'call-process cedet-idutils-token-command | |
109 nil b nil | |
110 flags) | |
111 b)) | |
112 | |
110526
b150a06c6999
Synch EDE to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
113 (defun cedet-idutils-mkid-call (flags) |
b150a06c6999
Synch EDE to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
114 "Call ID Utils mkid with the list of FLAGS. |
b150a06c6999
Synch EDE to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
115 Return the created buffer with with program output." |
b150a06c6999
Synch EDE to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
116 (let ((b (get-buffer-create "*CEDET mkid*")) |
b150a06c6999
Synch EDE to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
117 (cd default-directory) |
b150a06c6999
Synch EDE to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
118 ) |
b150a06c6999
Synch EDE to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
119 (with-current-buffer b |
b150a06c6999
Synch EDE to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
120 (setq default-directory cd) |
b150a06c6999
Synch EDE to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
121 (erase-buffer)) |
b150a06c6999
Synch EDE to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
122 (apply 'call-process cedet-idutils-make-command |
b150a06c6999
Synch EDE to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
123 nil b nil |
b150a06c6999
Synch EDE to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
124 flags) |
b150a06c6999
Synch EDE to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
125 b)) |
b150a06c6999
Synch EDE to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
126 |
105241 | 127 ;;; UTIL CALLS |
128 ;; | |
129 (defun cedet-idutils-expand-filename (filename) | |
105325 | 130 "Expand the FILENAME with ID Utils. |
105241 | 131 Return a filename relative to the default directory." |
132 (interactive "sFile: ") | |
105799
3fe6da4a95a9
* cedet/srecode/srt-mode.el (semantic-analyze-possible-completions):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105377
diff
changeset
|
133 (let ((ans (with-current-buffer (cedet-idutils-fnid-call (list filename)) |
105241 | 134 (goto-char (point-min)) |
135 (if (looking-at "[^ \n]*fnid: ") | |
136 (error "ID Utils not available") | |
137 (split-string (buffer-string) "\n" t))))) | |
138 (setq ans (mapcar 'expand-file-name ans)) | |
106197
019d906c8f48
* cedet/srecode/map.el (srecode-get-maps):
Chong Yidong <cyd@stupidchicken.com>
parents:
105799
diff
changeset
|
139 (when (called-interactively-p 'interactive) |
105241 | 140 (if ans |
141 (if (= (length ans) 1) | |
142 (message "%s" (car ans)) | |
143 (message "%s + %d others" (car ans) | |
144 (length (cdr ans)))) | |
145 (error "No file found"))) | |
146 ans)) | |
147 | |
148 (defun cedet-idutils-support-for-directory (&optional dir) | |
105325 | 149 "Return non-nil if ID Utils has a support file for DIR. |
105241 | 150 If DIR is not supplied, use the current default directory. |
151 This works by running lid on a bogus symbol, and looking for | |
152 the error code." | |
153 (save-excursion | |
154 (let ((default-directory (or dir default-directory))) | |
155 (condition-case nil | |
156 (progn | |
157 (set-buffer (cedet-idutils-fnid-call '("moose"))) | |
158 (goto-char (point-min)) | |
159 (if (looking-at "[^ \n]*fnid: ") | |
160 nil | |
161 t)) | |
162 (error nil))))) | |
163 | |
164 (defun cedet-idutils-version-check (&optional noerror) | |
165 "Check the version of the installed ID Utils command. | |
166 If optional programatic argument NOERROR is non-nil, then | |
167 instead of throwing an error if Global isn't available, then | |
168 return nil." | |
169 (interactive) | |
170 (require 'inversion) | |
171 (let ((b (condition-case nil | |
172 (cedet-idutils-fnid-call (list "--version")) | |
173 (error nil))) | |
174 (rev nil)) | |
175 (if (not b) | |
176 (progn | |
106197
019d906c8f48
* cedet/srecode/map.el (srecode-get-maps):
Chong Yidong <cyd@stupidchicken.com>
parents:
105799
diff
changeset
|
177 (when (called-interactively-p 'interactive) |
105241 | 178 (message "ID Utils not found.")) |
179 nil) | |
105799
3fe6da4a95a9
* cedet/srecode/srt-mode.el (semantic-analyze-possible-completions):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105377
diff
changeset
|
180 (with-current-buffer b |
105241 | 181 (goto-char (point-min)) |
182 (re-search-forward "fnid - \\([0-9.]+\\)" nil t) | |
183 (setq rev (match-string 1)) | |
184 (if (inversion-check-version rev nil cedet-idutils-min-version) | |
185 (if noerror | |
186 nil | |
105325 | 187 (error "Version of ID Utils is %s. Need at least %s" |
105241 | 188 rev cedet-idutils-min-version)) |
189 ;; 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
|
190 (when (called-interactively-p 'interactive) |
105241 | 191 (message "ID Utils %s - Good enough for CEDET." rev)) |
192 t))))) | |
193 | |
110526
b150a06c6999
Synch EDE to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
194 (defun cedet-idutils-create/update-database (&optional dir) |
b150a06c6999
Synch EDE to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
195 "Create an IDUtils database in DIR. |
b150a06c6999
Synch EDE to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
196 IDUtils must start from scratch when updating a database." |
b150a06c6999
Synch EDE to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
197 (interactive "DDirectory: ") |
b150a06c6999
Synch EDE to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
198 (let ((default-directory dir)) |
b150a06c6999
Synch EDE to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
199 (cedet-idutils-mkid-call nil))) |
105241 | 200 |
201 (provide 'cedet-idutils) | |
202 | |
105377 | 203 ;; arch-tag: 663ca082-5b3d-4384-8710-cc74f990b501 |
105241 | 204 ;;; cedet-idutils.el ends here |