Mercurial > emacs
annotate lisp/emacs-lisp/regi.el @ 110523:a5ad4f188e19
Synch Semantic to CEDET 1.0.
Move CEDET ChangeLog entries to new file lisp/cedet/ChangeLog.
* semantic.el (semantic-version): Update to 2.0.
(semantic-mode-map): Add "," and "m" bindings.
(navigate-menu): Update.
* semantic/symref.el (semantic-symref-calculate-rootdir):
New function.
(semantic-symref-detect-symref-tool): Use it.
* semantic/symref/grep.el (semantic-symref-grep-shell): New var.
(semantic-symref-perform-search): Use it. Calculate root dir with
semantic-symref-calculate-rootdir.
(semantic-symref-derive-find-filepatterns): Improve error message.
* semantic/symref/list.el
(semantic-symref-results-mode-map): New bindings.
(semantic-symref-auto-expand-results): New option.
(semantic-symref-results-dump): Obey auto-expand.
(semantic-symref-list-expand-all, semantic-symref-regexp)
(semantic-symref-list-contract-all)
(semantic-symref-list-map-open-hits)
(semantic-symref-list-update-open-hits)
(semantic-symref-list-create-macro-on-open-hit)
(semantic-symref-list-call-macro-on-open-hits): New functions.
(semantic-symref-list-menu-entries)
(semantic-symref-list-menu): New vars.
(semantic-symref-list-map-open-hits): Move cursor to beginning of
match before calling the mapped function.
* semantic/doc.el
(semantic-documentation-comment-preceeding-tag): Do nothing if the
mode doesn't provide comment-start-skip.
* semantic/scope.el
(semantic-analyze-scope-nested-tags-default): Strip duplicates.
(semantic-analyze-scoped-inherited-tag-map): Take the tag we are
looking for as part of the scoped tags list.
* semantic/html.el (semantic-default-html-setup): Add
senator-step-at-tag-classes.
* semantic/decorate/include.el
(semantic-decoration-on-unknown-includes): Change light bgcolor.
(semantic-decoration-on-includes-highlight-default): Check that
the include tag has a postion.
* semantic/complete.el (semantic-collector-local-members):
(semantic-complete-read-tag-local-members)
(semantic-complete-jump-local-members): New class and functions.
(semantic-complete-self-insert): Save excursion before completing.
* semantic/analyze/complete.el
(semantic-analyze-possible-completions-default): If no completions
are found, return the raw by-name-only completion list. Add FLAGS
arguments. Add support for 'no-tc (type constraint) and
'no-unique, or no stripping duplicates.
(semantic-analyze-possible-completions-default): Add FLAGS arg.
* semantic/util-modes.el
(semantic-stickyfunc-show-only-functions-p): New option.
(semantic-stickyfunc-fetch-stickyline): Don't show stickytext for
the very first line in a buffer.
* semantic/util.el (semantic-hack-search)
(semantic-recursive-find-nonterminal-by-name)
(semantic-current-tag-interactive): Deleted.
(semantic-describe-buffer): Fix expand-nonterminal. Add
lex-syntax-mods, type relation separator char, and command
separation char.
(semantic-sanity-check): Only message if called interactively.
* semantic/tag.el (semantic-tag-deep-copy-one-tag): Copy the
:filename property and the tag position.
* semantic/lex-spp.el (semantic-lex-spp-lex-text-string):
Add recursion limit.
* semantic/imenu.el (semantic-imenu-bucketize-type-members):
Make this buffer local, not the obsoleted variable.
* semantic/idle.el: Add breadcrumbs support.
(semantic-idle-summary-current-symbol-info-default)
(semantic-idle-tag-highlight)
(semantic-idle-completion-list-default): Use
semanticdb-without-unloaded-file-searches for speed, and to
conform to the controls that specify if the idle timer is supposed
to be parsing unparsed includes.
(semantic-idle-symbol-highlight-face)
(semantic-idle-symbol-maybe-highlight): Rename from *-summary-*.
Callers changed.
(semantic-idle-work-parse-neighboring-files-flag): Default to nil.
(semantic-idle-work-update-headers-flag): New var.
(semantic-idle-work-for-one-buffer): Use it.
(semantic-idle-local-symbol-highlight): Rename from
semantic-idle-tag-highlight.
(semantic-idle-truncate-long-summaries): New option.
* semantic/ia.el (semantic-ia-cache)
(semantic-ia-get-completions): Deleted. Callers changed.
(semantic-ia-show-variants): New command.
(semantic-ia-show-doc): If doc is empty, don't make a temp buffer.
(semantic-ia-show-summary): If there isn't anything to show, say so.
* semantic/grammar.el (semantic-grammar-create-package):
Save the buffer even in batch mode.
* semantic/fw.el
(semanticdb-without-unloaded-file-searches): New macro.
* semantic/dep.el (semantic-dependency-find-file-on-path):
Fix case dereferencing ede-object when it is a list.
* semantic/db-typecache.el (semanticdb-expand-nested-tag)
(semanticdb-typecache-faux-namespace): New functions.
(semanticdb-typecache-file-tags)
(semanticdb-typecache-merge-streams): Use them.
(semanticdb-typecache-file-tags): When deriving tags from a file,
give the mode a chance to monkey with the tag copy.
(semanticdb-typecache-find-default): Wrap find in save-excursion.
(semanticdb-typecache-find-by-name-helper): Merge found names down.
* semantic/db-global.el
(semanticdb-enable-gnu-global-in-buffer): Don't show messages if
GNU Global is not available and we don't want to throw an error.
* semantic/db-find.el (semanticdb-find-result-nth-in-buffer):
When trying to normalize the tag to a buffer, don't error if
set-buffer method doesn't exist.
* semantic/db-file.el (semanticdb-save-db): Simplify msg.
* semantic/db.el (semanticdb-refresh-table): If forcing a
refresh on a file not in a buffer, use semantic-find-file-noselect
and delete the buffer after use.
(semanticdb-current-database-list): When calculating root via
hooks, force it through true-filename and skip the list of
possible roots.
* semantic/ctxt.el (semantic-ctxt-imported-packages): New.
* semantic/analyze/debug.el
(semantic-analyzer-debug-insert-tag): Reset standard output to
current buffer.
(semantic-analyzer-debug-global-symbol)
(semantic-analyzer-debug-missing-innertype): Change "prefix" to
"symbol" in messages.
* semantic/analyze/refs.el: (semantic-analyze-refs-impl)
(semantic-analyze-refs-proto): When calculating value, make sure
the found tag is 'similar' to the originating tag.
(semantic--analyze-refs-find-tags-with-parent): Attempt to
identify matches via imported symbols of parents.
(semantic--analyze-refs-full-lookup-with-parents): Do a deep
search during the brute search.
* semantic/analyze.el
(semantic-analyze-find-tag-sequence-default): Be robust to
calculated scopes being nil.
* semantic/bovine/c.el (semantic-c-describe-environment): Add
project macro symbol array.
(semantic-c-parse-lexical-token): Add recursion limit.
(semantic-ctxt-imported-packages, semanticdb-expand-nested-tag):
New overrides.
(semantic-expand-c-tag-namelist): Split a full type from a typedef
out to its own tag.
(semantic-expand-c-tag-namelist): Do not split out a typedef'd
inline type if it is an anonymous type.
(semantic-c-reconstitute-token): Use the optional initializers as
a clue that some function is probably a constructor. When
defining the type of these constructors, split the parent name,
and use only the class part, if applicable.
* semantic/bovine/c-by.el:
* semantic/wisent/python-wy.el: Regenerate.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Sat, 18 Sep 2010 22:49:54 -0400 |
parents | 1d1d5d9bd884 |
children | 376148b31b5e |
rev | line source |
---|---|
51349 | 1 ;;; regi.el --- REGular expression Interpreting engine |
2 | |
74466 | 3 ;; Copyright (C) 1993, 2001, 2002, 2003, 2004, 2005, |
106815 | 4 ;; 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
51349 | 5 |
6 ;; Author: 1993 Barry A. Warsaw, Century Computing, Inc. <bwarsaw@cen.com> | |
7 ;; Maintainer: bwarsaw@cen.com | |
8 ;; Created: 24-Feb-1993 | |
9 ;; Version: 1.8 | |
10 ;; Last Modified: 1993/06/01 21:33:00 | |
11 ;; Keywords: extensions, matching | |
12 | |
13 ;; This file is part of GNU Emacs. | |
14 | |
94655
90a2847062be
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
15 ;; GNU Emacs is free software: you can redistribute it and/or modify |
51349 | 16 ;; it under the terms of the GNU General Public License as published by |
94655
90a2847062be
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
17 ;; the Free Software Foundation, either version 3 of the License, or |
90a2847062be
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
18 ;; (at your option) any later version. |
51349 | 19 |
20 ;; GNU Emacs is distributed in the hope that it will be useful, | |
21 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
22 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
23 ;; GNU General Public License for more details. | |
24 | |
25 ;; You should have received a copy of the GNU General Public License | |
94655
90a2847062be
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
26 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
51349 | 27 |
28 ;;; Commentary: | |
29 | |
30 ;;; Code: | |
31 | |
32 | |
33 (defun regi-pos (&optional position col-p) | |
34 "Return the character position at various buffer positions. | |
35 Optional POSITION can be one of the following symbols: | |
36 | |
37 `bol' == beginning of line | |
38 `boi' == beginning of indentation | |
39 `eol' == end of line [default] | |
40 `bonl' == beginning of next line | |
41 `bopl' == beginning of previous line | |
42 | |
43 Optional COL-P non-nil returns `current-column' instead of character position." | |
44 (save-excursion | |
45 (cond | |
46 ((eq position 'bol) (beginning-of-line)) | |
47 ((eq position 'boi) (back-to-indentation)) | |
48 ((eq position 'bonl) (forward-line 1)) | |
49 ((eq position 'bopl) (forward-line -1)) | |
50 (t (end-of-line))) | |
51 (if col-p (current-column) (point)))) | |
52 | |
53 (defun regi-mapcar (predlist func &optional negate-p case-fold-search-p) | |
54 "Build a regi frame where each element of PREDLIST appears exactly once. | |
55 The frame contains elements where each member of PREDLIST is | |
56 associated with FUNC, and optionally NEGATE-P and CASE-FOLD-SEARCH-P." | |
57 (let (frame tail) | |
58 (if (or negate-p case-fold-search-p) | |
59 (setq tail (list negate-p))) | |
60 (if case-fold-search-p | |
61 (setq tail (append tail (list case-fold-search-p)))) | |
62 (while predlist | |
63 (let ((element (list (car predlist) func))) | |
64 (if tail | |
65 (setq element (append element tail))) | |
66 (setq frame (append frame (list element)) | |
67 predlist (cdr predlist)) | |
68 )) | |
69 frame)) | |
70 | |
71 | |
72 (defun regi-interpret (frame &optional start end) | |
73 "Interpret the regi frame FRAME. | |
74 If optional START and END are supplied, they indicate the region of | |
75 interest, and the buffer is narrowed to the beginning of the line | |
76 containing START, and beginning of the line after the line containing | |
77 END. Otherwise, point and mark are not set and processing continues | |
78 until your FUNC returns the `abort' symbol (see below). Beware! Not | |
79 supplying a START or END could put you in an infinite loop. | |
80 | |
81 A regi frame is a list of entries of the form: | |
82 | |
83 (PRED FUNC [NEGATE-P [CASE-FOLD-SEARCH]]) | |
84 | |
85 PRED is a predicate against which each line in the region is tested, | |
86 and if a match occurs, FUNC is `eval'd. Point is then moved to the | |
87 beginning of the next line, the frame is reset and checking continues. | |
88 If a match doesn't occur, the next entry is checked against the | |
89 current line until all entries in the frame are checked. At this | |
90 point, if no match occurred, the frame is reset and point is moved to | |
91 the next line. Checking continues until every line in the region is | |
92 checked. Optional NEGATE-P inverts the result of PRED before FUNC is | |
93 called and `case-fold-search' is bound to the optional value of | |
94 CASE-FOLD-SEARCH for the PRED check. | |
95 | |
96 PRED can be a string, variable, function or one of the following | |
97 symbols: t, nil, `begin', `end', and `every'. If PRED is a string, or | |
98 a variable or list that evaluates to a string, it is interpreted as a | |
99 regular expression and is matched against the current line (from the | |
100 beginning) using `looking-at'. If PRED does not evaluate to a string, | |
101 it is interpreted as a binary value (nil or non-nil). | |
102 | |
103 PRED can also be one of the following symbols: | |
104 | |
105 t -- always produces a true outcome | |
106 `begin' -- always executes before anything else | |
107 `end' -- always executes after everything else | |
108 `every' -- execute after frame is matched on a line | |
109 | |
110 Note that NEGATE-P and CASE-FOLD-SEARCH are meaningless if PRED is one | |
111 of these special symbols. Only the first occurrence of each symbol in | |
112 a frame entry is used, the rest are ignored. | |
113 | |
114 Your FUNC can return values which control regi processing. If a list | |
115 is returned from your function, it can contain any combination of the | |
116 following elements: | |
117 | |
118 the symbol `continue' | |
119 Tells regi to continue processing frame-entries after a match, | |
120 instead of resetting to the first entry and advancing to the next | |
121 line, as is the default behavior. When returning this symbol, | |
122 you must take care not to enter an infinite loop. | |
123 | |
124 the symbol `abort' | |
125 Tells regi to terminate processing this frame. any end | |
126 frame-entry is still processed. | |
127 | |
128 the list `(frame . NEWFRAME)' | |
129 Tells regi to use NEWFRAME as its current frame. In other words, | |
130 your FUNC can modify the executing regi frame on the fly. | |
131 | |
132 the list `(step . STEP)' | |
133 Tells regi to move STEP number of lines forward during normal | |
134 processing. By default, regi moves forward 1 line. STEP can be | |
135 negative, but be careful of infinite loops. | |
136 | |
137 You should usually take care to explicitly return nil from your | |
138 function if no action is to take place. Your FUNC will always be | |
139 `eval'ed. The following variables will be temporarily bound to some | |
140 useful information: | |
141 | |
142 `curline' | |
143 the current line in the buffer, as a string | |
144 | |
145 `curframe' | |
146 the full, current frame being executed | |
147 | |
148 `curentry' | |
149 the current frame entry being executed." | |
150 | |
151 (save-excursion | |
152 (save-restriction | |
153 (let (begin-tag end-tag every-tag current-frame working-frame donep) | |
154 | |
155 ;; set up the narrowed region | |
156 (and start | |
157 end | |
158 (let* ((tstart start) | |
159 (start (min start end)) | |
160 (end (max start end))) | |
161 (narrow-to-region | |
162 (progn (goto-char end) (regi-pos 'bonl)) | |
163 (progn (goto-char start) (regi-pos 'bol))))) | |
164 | |
165 ;; lets find the special tags and remove them from the working | |
166 ;; frame. note that only the last special tag is used. | |
84903
a164ccfc4d79
(regi-interpret): Use `mapc' rather than `mapcar'.
Juanma Barranquero <lekktu@gmail.com>
parents:
78217
diff
changeset
|
167 (mapc |
51349 | 168 (function |
169 (lambda (entry) | |
170 (let ((pred (car entry)) | |
171 (func (car (cdr entry)))) | |
172 (cond | |
173 ((eq pred 'begin) (setq begin-tag func)) | |
174 ((eq pred 'end) (setq end-tag func)) | |
175 ((eq pred 'every) (setq every-tag func)) | |
176 (t | |
177 (setq working-frame (append working-frame (list entry)))) | |
178 ) ; end-cond | |
179 ))) | |
180 frame) ; end-mapcar | |
181 | |
182 ;; execute the begin entry | |
183 (eval begin-tag) | |
184 | |
185 ;; now process the frame | |
186 (setq current-frame working-frame) | |
187 (while (not (or donep (eobp))) | |
188 (let* ((entry (car current-frame)) | |
189 (pred (nth 0 entry)) | |
190 (func (nth 1 entry)) | |
191 (negate-p (nth 2 entry)) | |
192 (case-fold-search (nth 3 entry)) | |
193 match-p) | |
194 (catch 'regi-throw-top | |
195 (cond | |
196 ;; we are finished processing the frame for this line | |
197 ((not current-frame) | |
198 (setq current-frame working-frame) ;reset frame | |
199 (forward-line 1) | |
200 (throw 'regi-throw-top t)) | |
201 ;; see if predicate evaluates to a string | |
202 ((stringp (setq match-p (eval pred))) | |
203 (setq match-p (looking-at match-p))) | |
204 ) ; end-cond | |
205 | |
206 ;; now that we've done the initial matching, check for | |
207 ;; negation of match | |
208 (and negate-p | |
209 (setq match-p (not match-p))) | |
210 | |
211 ;; if the line matched, package up the argument list and | |
212 ;; funcall the FUNC | |
213 (if match-p | |
214 (let* ((curline (buffer-substring | |
215 (regi-pos 'bol) | |
216 (regi-pos 'eol))) | |
217 (curframe current-frame) | |
218 (curentry entry) | |
219 (result (eval func)) | |
220 (step (or (cdr (assq 'step result)) 1)) | |
221 ) | |
222 ;; changing frame on the fly? | |
223 (if (assq 'frame result) | |
224 (setq working-frame (cdr (assq 'frame result)))) | |
225 | |
226 ;; continue processing current frame? | |
227 (if (memq 'continue result) | |
228 (setq current-frame (cdr current-frame)) | |
229 (forward-line step) | |
230 (setq current-frame working-frame)) | |
231 | |
232 ;; abort current frame? | |
233 (if (memq 'abort result) | |
234 (progn | |
235 (setq donep t) | |
236 (throw 'regi-throw-top t))) | |
237 ) ; end-let | |
238 | |
239 ;; else if no match occurred, then process the next | |
240 ;; frame-entry on the current line | |
241 (setq current-frame (cdr current-frame)) | |
242 | |
243 ) ; end-if match-p | |
244 ) ; end catch | |
245 ) ; end let | |
246 | |
247 ;; after every cycle, evaluate every-tag | |
248 (eval every-tag) | |
249 ) ; end-while | |
250 | |
251 ;; now process the end entry | |
252 (eval end-tag))))) | |
253 | |
254 | |
255 (provide 'regi) | |
256 | |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
257 ;; arch-tag: 804b4e45-4109-4f76-9a88-21887b881747 |
51349 | 258 ;;; regi.el ends here |