Mercurial > emacs
annotate etc/emacs2.py @ 103616:af77bf73dfe0
* verilog-mode.el (verilog-beg-of-statement)
(verilog-endcomment-reason-re): Support unique case and priority
case.
(verilog-basic-complete-re): Support localparam lineup.
(verilog-beg-of-statement-1): Fix for robustness, unique case.
(verilog-set-auto-endcomments): Fix for unique case, always_comb
commenting.
(verilog-leap-to-case-head): Now support *nested* unique &
priority case statements.
(verilog-auto-lineup): Make just declarations the default (as it
had been).
(verilog-leap-to-case-head): Support priority/unique case
statements.
(verilog-auto-lineup): Rework to give users radio buttons to
select the various styles of automatic lineup
(verilog-error-regexp-alist): Rework to support the XEmacs style
of error regular expressions from compilers, lint tools &
simulators. Note that GNU Emacs has made it impossible for a mode
to load such things.
(electric-verilog-terminate-line, verilog-indent-declaration)
(verilog-auto-wiure): Rework for radio button selection of
auto-lineup selection of specification of auto lineup.
(verilog-beg-of-statement-1): Redesign to support proper operation
in additional code, based on testing with auto-lineup.
(verilog-calculate-indent, assignments & declarations)
(verilog-backward-token): Enhance to support auto-lineup of
assignments & declarations.
(verilog-in-directive-p, verilog-at-struct-p): New function for
easy test of whether we are.
(verilog-pretty-declarations, verilog-pretty-expr): Massive rework
to support safe execution at almost anyline.
(verilog-calc-1): Properly support indenting deep inside generate
blocks.
(verilog-init-font) Remove definition & use of verilog-init-font,
as it is redundant with font-lock-defaults.
(verilog-mode): Alter the definition of verilog-font-lock-defualts
to avoid circular calls if syntax-ppss is a function (as is the
case now in 22.x GNU Emacs) as that function would sometimes call
itself, leading to (nearly) infinite recursion
(verilog-ovm-begin-re, verilog-ovm-end-re)
(verilog-ovm-statement-re, verilog-leap-to-head)
(verilog-backward-token): Add support for OVM macros. Some are
complete statements, and others open and close scopes like begin
and end.
(verilog-defun-level-not-generate-re, verilog-defun-level-re)
(verilog-defun-level-generate-only-re): Really fix the defun-list
compilation issue
(verilog-calc-1) (verilog-beg-of-statement): Enhance support for
coverpoint, constraint and cross statements
(verilog-defun-level-list, verilog-generate-defun-level-list)
(verilog-all-defun-level-list): Redo these specifications - it is
too hard to support eval-when compile aggregation of lists also
built at when-compile time.
(verilog-defun-level-list): Place defconsts of variables used in
building regular expressions which are built in eval-when-compile
bodies in the same eval-when-compile body to facilitate compile
without load.
(verilog-beg-block-re-ordered): Support indenting
virtual/protected tasks and functions.
(verilog-defun-level-list,verilog-in-generate-region-p)
(verilog-backward-ws&directives, verilog-calc-1): Speed up
indentation of some module items (generate items).
(verilog-forward-sexp, verilog-leap-to-head): Support stepping
across virtual/protected tasks and functions.
* verilog-mode.el (verilog-auto-arg, verilog-auto-arg-sort): Allow
sorting AUTOARG lists. Suggested by Andrea Fedeli.
(verilog-read-sub-decls-line): Fix AUTOWIRE signals getting lost
in concatenations. Reported by Yishay Belkind.
(verilog-auto-ascii-enum): Support one-hot state machines in
AUTOASCIIENUM. Suggested by Lloyd Gomez.
(verilog-auto-inst, verilog-auto-inst-port): Include interface
modport in AUTOINST and add vl-modport for users. Reported by
David Rogoff.
(verilog-auto-inout-module, verilog-auto-inst)
(verilog-decls-get-interfaces, verilog-insert-definition)
(verilog-insert-one-definition, verilog-read-decls)
(verilog-read-sub-decls, verilog-read-sub-decls-sig)
(verilog-sig-modport, verilog-signals-combine-bus)
(verilog-subdecls-get-interfaces): Fix expansion of SystemVerilog
interfaces in AUTOINOUTMODULE, AUTOINOUTCOMP, and AUTOINST.
Suggested by David Rogoff.
(verilog-repair-open-comma): Fix non-insertion of comma when
`DEFINE occurs in V2K argument list. Reported by Lane Brooks.
(verilog-make-width-expression): Simplify [A-1:0] expression
widths to just {A{1'b0}}.
(verilog-mode): Cleanup checkdoc warnings.
(verilog-auto-inout-module, verilog-signals-matching-dir-re): Add
third optional regexp to AUTOINOUTMODULE to allow selecting only
inputs/outputs or data type. Suggested by Vasu Kandadi.
(next-error-last-buffer): Fix byte-compiler warning.
(verilog-auto, verilog-auto-insert-lisp, verilog-auto-inst)
(verilog-delete-auto): Add AUTOINSERTLISP to insert arbitrary lisp
or shell command text during AUTO expansion. Suggested by Tad
Truex.
(verilog-read-sub-decls-expr, verilog-read-sub-decls-line)
(verilog-read-sub-decls-sig, verilog-symbol-detick-text): Fix
dotted nets {a.b,c.d} and excaped identifiers being mis-included
in AUTOINOUT. Reported by Matthew Lovell.
(verilog-read-always-signals-recurse): Fix AUTORESET "if (a<=b)"
causing use of <= assignments. Reported by Alex Reed.
(verilog-read-decls): Fix triand, trior, wand, wor to be
recognized by AUTOWIRE. Reported by Spencer Isaacson.
(verilog-extended-complete-re): Support import "DPI-C" functions.
(verilog-read-always-signals-recurse): Fix AUTORESET of "x <=
y[a+1:a+1]" to not include a in reset list. Reported by Dan
Dever.
(verilog-insert-date, verilog-insert-year)
(verilog-sk-header-tmpl): Fix verilog-header inserting error on
Windows systems. Reported by Michael Potts.
(verilog-read-module-name): Fix AUTOINST when the child module
declaration's name is a tick define. Reported by Elliot Mednick.
(verilog-read-decls): Fix V2K parameter bit subscripts getting
passed to next parameter's definition. Reported by Bruce T.
(verilog-read-decls): Fix detecting "parameter int" when using
AUTOINSTPARAM. Reported by Bruce T.
(verilog-goto-defun): Fix goto not finding modules unless first
perform a verilog-auto expansion. Suggested by Lawrence Butcher.
(verilog-mode): Expand -f flag arguments on entry to mode so
verilog-goto-defun will work. Reported by Lawrence Butcher.
(verilog-getopt): Expand environment variables in -f file
arguments. Suggested by Lawrence Butcher.
(verilog-set-define): Fix "Symbol's value as variable is void"
when reading enumerations.
(verilog-auto-ascii-enum): Fix duplicate labels in AUTOASCIIENUM.
Suggested by Stephen Peltan.
(verilog-read-defines): Fix reading of enumerations in include
files. Reported by Steve Peltan.
author | Dan Nicolaescu <dann@ics.uci.edu> |
---|---|
date | Sun, 28 Jun 2009 17:52:45 +0000 |
parents | c90853557b90 |
children | 1d1d5d9bd884 |
rev | line source |
---|---|
84821 | 1 """Definitions used by commands sent to inferior Python in python.el.""" |
2 | |
100972 | 3 # Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. |
84821 | 4 # Author: Dave Love <fx@gnu.org> |
5 | |
6 # This file is part of GNU Emacs. | |
7 | |
95004
cbf5528cf447
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
8 # GNU Emacs is free software: you can redistribute it and/or modify |
84821 | 9 # it under the terms of the GNU General Public License as published by |
95004
cbf5528cf447
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
10 # the Free Software Foundation, either version 3 of the License, or |
cbf5528cf447
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
11 # (at your option) any later version. |
84821 | 12 |
13 # GNU Emacs is distributed in the hope that it will be useful, | |
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 # GNU General Public License for more details. | |
17 | |
18 # You should have received a copy of the GNU General Public License | |
95004
cbf5528cf447
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
19 # along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
84821 | 20 |
21 import os, sys, traceback, inspect, __main__ | |
22 | |
23 try: | |
24 set | |
25 except: | |
26 from sets import Set as set | |
27 | |
28 __all__ = ["eexecfile", "eargs", "complete", "ehelp", "eimport", "modpath"] | |
29 | |
30 def format_exception (filename, should_remove_self): | |
31 type, value, tb = sys.exc_info () | |
32 sys.last_type = type | |
33 sys.last_value = value | |
34 sys.last_traceback = tb | |
35 if type is SyntaxError: | |
36 try: # parse the error message | |
37 msg, (dummy_filename, lineno, offset, line) = value | |
38 except: | |
39 pass # Not the format we expect; leave it alone | |
40 else: | |
41 # Stuff in the right filename | |
42 value = SyntaxError(msg, (filename, lineno, offset, line)) | |
43 sys.last_value = value | |
44 res = traceback.format_exception_only (type, value) | |
45 # There are some compilation errors which do not provide traceback so we | |
46 # should not massage it. | |
47 if should_remove_self: | |
48 tblist = traceback.extract_tb (tb) | |
49 del tblist[:1] | |
50 res = traceback.format_list (tblist) | |
51 if res: | |
52 res.insert(0, "Traceback (most recent call last):\n") | |
53 res[len(res):] = traceback.format_exception_only (type, value) | |
54 # traceback.print_exception(type, value, tb) | |
55 for line in res: print line, | |
56 | |
57 def eexecfile (file): | |
58 """Execute FILE and then remove it. | |
59 Execute the file within the __main__ namespace. | |
60 If we get an exception, print a traceback with the top frame | |
61 (ourselves) excluded.""" | |
62 # We cannot use real execfile since it has a bug where the file stays | |
63 # locked forever (under w32) if SyntaxError occurs. | |
64 # --- code based on code.py and PyShell.py. | |
65 try: | |
66 try: | |
67 source = open (file, "r").read() | |
68 code = compile (source, file, "exec") | |
69 # Other exceptions (shouldn't be any...) will (correctly) fall | |
70 # through to "final". | |
71 except (OverflowError, SyntaxError, ValueError): | |
72 # FIXME: When can compile() raise anything else than | |
73 # SyntaxError ???? | |
74 format_exception (file, False) | |
75 return | |
76 try: | |
77 exec code in __main__.__dict__ | |
78 except: | |
79 format_exception (file, True) | |
80 finally: | |
81 os.remove (file) | |
82 | |
83 def eargs (name, imports): | |
84 "Get arglist of NAME for Eldoc &c." | |
85 try: | |
86 if imports: exec imports | |
87 parts = name.split ('.') | |
88 if len (parts) > 1: | |
89 exec 'import ' + parts[0] # might fail | |
90 func = eval (name) | |
91 if inspect.isbuiltin (func) or type(func) is type: | |
92 doc = func.__doc__ | |
93 if doc.find (' ->') != -1: | |
94 print '_emacs_out', doc.split (' ->')[0] | |
95 else: | |
96 print '_emacs_out', doc.split ('\n')[0] | |
97 return | |
98 if inspect.ismethod (func): | |
99 func = func.im_func | |
100 if not inspect.isfunction (func): | |
101 print '_emacs_out ' | |
102 return | |
103 (args, varargs, varkw, defaults) = inspect.getargspec (func) | |
104 # No space between name and arglist for consistency with builtins. | |
105 print '_emacs_out', \ | |
106 func.__name__ + inspect.formatargspec (args, varargs, varkw, | |
107 defaults) | |
108 except: | |
109 print "_emacs_out " | |
110 | |
111 def all_names (object): | |
112 """Return (an approximation to) a list of all possible attribute | |
113 names reachable via the attributes of OBJECT, i.e. roughly the | |
114 leaves of the dictionary tree under it.""" | |
115 | |
116 def do_object (object, names): | |
117 if inspect.ismodule (object): | |
118 do_module (object, names) | |
119 elif inspect.isclass (object): | |
120 do_class (object, names) | |
121 # Might have an object without its class in scope. | |
122 elif hasattr (object, '__class__'): | |
123 names.add ('__class__') | |
124 do_class (object.__class__, names) | |
125 # Probably not a good idea to try to enumerate arbitrary | |
126 # dictionaries... | |
127 return names | |
128 | |
129 def do_module (module, names): | |
130 if hasattr (module, '__all__'): # limited export list | |
131 names.update(module.__all__) | |
132 for i in module.__all__: | |
133 do_object (getattr (module, i), names) | |
134 else: # use all names | |
135 names.update(dir (module)) | |
136 for i in dir (module): | |
137 do_object (getattr (module, i), names) | |
138 return names | |
139 | |
140 def do_class (object, names): | |
141 ns = dir (object) | |
142 names.update(ns) | |
143 if hasattr (object, '__bases__'): # superclasses | |
144 for i in object.__bases__: do_object (i, names) | |
145 return names | |
146 | |
147 return do_object (object, set([])) | |
148 | |
149 def complete (name, imports): | |
150 """Complete TEXT in NAMESPACE and print a Lisp list of completions. | |
151 Exec IMPORTS first.""" | |
152 import __main__, keyword | |
153 | |
154 def class_members(object): | |
155 names = dir (object) | |
156 if hasattr (object, '__bases__'): | |
157 for super in object.__bases__: | |
158 names = class_members (super) | |
159 return names | |
160 | |
161 names = set([]) | |
162 base = None | |
163 try: | |
164 dict = __main__.__dict__.copy() | |
165 if imports: exec imports in dict | |
166 l = len (name) | |
167 if not "." in name: | |
168 for src in [dir (__builtins__), keyword.kwlist, dict.keys()]: | |
169 for elt in src: | |
170 if elt[:l] == name: names.add(elt) | |
171 else: | |
172 base = name[:name.rfind ('.')] | |
173 name = name[name.rfind('.')+1:] | |
174 try: | |
175 object = eval (base, dict) | |
176 names = set(dir (object)) | |
177 if hasattr (object, '__class__'): | |
178 names.add('__class__') | |
179 names.update(class_members (object)) | |
180 except: names = all_names (dict) | |
181 except: | |
182 print sys.exc_info() | |
183 names = [] | |
184 | |
185 l = len(name) | |
186 print '_emacs_out (', | |
187 for n in names: | |
188 if name == n[:l]: | |
189 if base: print '"%s.%s"' % (base, n), | |
190 else: print '"%s"' % n, | |
191 print ')' | |
192 | |
193 def ehelp (name, imports): | |
194 """Get help on string NAME. | |
195 First try to eval name for, e.g. user definitions where we need | |
196 the object. Otherwise try the string form.""" | |
197 locls = {} | |
198 if imports: | |
199 try: exec imports in locls | |
200 except: pass | |
201 try: help (eval (name, globals(), locls)) | |
202 except: help (name) | |
203 | |
204 def eimport (mod, dir): | |
205 """Import module MOD with directory DIR at the head of the search path. | |
206 NB doesn't load from DIR if MOD shadows a system module.""" | |
207 from __main__ import __dict__ | |
208 | |
209 path0 = sys.path[0] | |
210 sys.path[0] = dir | |
211 try: | |
212 try: | |
213 if __dict__.has_key(mod) and inspect.ismodule (__dict__[mod]): | |
214 reload (__dict__[mod]) | |
215 else: | |
216 __dict__[mod] = __import__ (mod) | |
217 except: | |
218 (type, value, tb) = sys.exc_info () | |
219 print "Traceback (most recent call last):" | |
220 traceback.print_exception (type, value, tb.tb_next) | |
221 finally: | |
222 sys.path[0] = path0 | |
223 | |
224 def modpath (module): | |
225 """Return the source file for the given MODULE (or None). | |
226 Assumes that MODULE.py and MODULE.pyc are in the same directory.""" | |
227 try: | |
228 path = __import__ (module).__file__ | |
229 if path[-4:] == '.pyc' and os.path.exists (path[0:-1]): | |
230 path = path[:-1] | |
231 print "_emacs_out", path | |
232 except: | |
233 print "_emacs_out ()" | |
234 | |
235 # print '_emacs_ok' # ready for input and can call continuation | |
236 | |
237 # arch-tag: d90408f3-90e2-4de4-99c2-6eb9c7b9ca46 |