aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2012-06-27 23:58:39 -0700
committerGlenn Morris2012-06-27 23:58:39 -0700
commit9ab89959267fed796a0d5f548c976bb8fb45f1b9 (patch)
tree396fe5eb191950f7fa51a2710752fac5c98d6195
parent15458df459c03803990c8e0752bbdda6f8a173d6 (diff)
downloademacs-9ab89959267fed796a0d5f548c976bb8fb45f1b9.tar.gz
emacs-9ab89959267fed796a0d5f548c976bb8fb45f1b9.zip
* emacs.py, emacs2.py, emacs3.py: Remove files.
AFAICS, the new python.el does not use these files.
-rw-r--r--etc/ChangeLog4
-rw-r--r--etc/emacs.py10
-rw-r--r--etc/emacs2.py236
-rw-r--r--etc/emacs3.py234
4 files changed, 4 insertions, 480 deletions
diff --git a/etc/ChangeLog b/etc/ChangeLog
index 9a65aa0bf2d..94e8480202c 100644
--- a/etc/ChangeLog
+++ b/etc/ChangeLog
@@ -1,3 +1,7 @@
12012-06-28 Glenn Morris <rgm@gnu.org>
2
3 * emacs.py, emacs2.py, emacs3.py: Remove files, no longer used.
4
12012-06-24 Lawrence Mitchell <wence@gmx.li> 52012-06-24 Lawrence Mitchell <wence@gmx.li>
2 6
3 * NEWS: Move and improve the defun/defalias changes (bug#11686). 7 * NEWS: Move and improve the defun/defalias changes (bug#11686).
diff --git a/etc/emacs.py b/etc/emacs.py
deleted file mode 100644
index 24004b321fe..00000000000
--- a/etc/emacs.py
+++ /dev/null
@@ -1,10 +0,0 @@
1"""Wrapper for version-specific implementations of python.el helper
2functions """
3
4import sys
5
6if sys.version_info[0] == 3:
7 from emacs3 import *
8else:
9 from emacs2 import *
10
diff --git a/etc/emacs2.py b/etc/emacs2.py
deleted file mode 100644
index ed99a3a1409..00000000000
--- a/etc/emacs2.py
+++ /dev/null
@@ -1,236 +0,0 @@
1"""Definitions used by commands sent to inferior Python in python.el."""
2
3# Copyright (C) 2004-2012 Free Software Foundation, Inc.
4# Author: Dave Love <fx@gnu.org>
5
6# This file is part of GNU Emacs.
7
8# GNU Emacs is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
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
19# along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
20
21import os, sys, traceback, inspect, __main__
22
23try:
24 set
25except:
26 from sets import Set as set
27
28__all__ = ["eexecfile", "eargs", "complete", "ehelp", "eimport", "modpath"]
29
30def 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
57def 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
83def 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
111def 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
149def 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
193def 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
204def 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
224def modpath (module):
225 """Return the source file for the given MODULE (or None).
226Assumes 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
diff --git a/etc/emacs3.py b/etc/emacs3.py
deleted file mode 100644
index f0e4659bb6b..00000000000
--- a/etc/emacs3.py
+++ /dev/null
@@ -1,234 +0,0 @@
1# Copyright (C) 2004-2012 Free Software Foundation, Inc.
2# Author: Dave Love <fx@gnu.org>
3
4# This file is part of GNU Emacs.
5
6# GNU Emacs is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation, either version 3 of the License, or
9# (at your option) any later version.
10
11# GNU Emacs is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15
16# You should have received a copy of the GNU General Public License
17# along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
18
19import os, sys, traceback, inspect, imp, __main__
20
21try:
22 set
23except:
24 from sets import Set as set
25
26__all__ = ["eexecfile", "eargs", "complete", "ehelp", "eimport", "modpath"]
27
28def format_exception (filename, should_remove_self):
29 type, value, tb = sys.exc_info ()
30 sys.last_type = type
31 sys.last_value = value
32 sys.last_traceback = tb
33 if type is SyntaxError:
34 try: # parse the error message
35 msg, (dummy_filename, lineno, offset, line) = value
36 except:
37 pass # Not the format we expect; leave it alone
38 else:
39 # Stuff in the right filename
40 value = SyntaxError(msg, (filename, lineno, offset, line))
41 sys.last_value = value
42 res = traceback.format_exception_only (type, value)
43 # There are some compilation errors which do not provide traceback so we
44 # should not massage it.
45 if should_remove_self:
46 tblist = traceback.extract_tb (tb)
47 del tblist[:1]
48 res = traceback.format_list (tblist)
49 if res:
50 res.insert(0, "Traceback (most recent call last):\n")
51 res[len(res):] = traceback.format_exception_only (type, value)
52 # traceback.print_exception(type, value, tb)
53 for line in res: print(line, end=' ')
54
55def eexecfile (file):
56 """Execute FILE and then remove it.
57 Execute the file within the __main__ namespace.
58 If we get an exception, print a traceback with the top frame
59 (ourselves) excluded."""
60 # We cannot use real execfile since it has a bug where the file stays
61 # locked forever (under w32) if SyntaxError occurs.
62 # --- code based on code.py and PyShell.py.
63 try:
64 try:
65 source = open (file, "r").read()
66 code = compile (source, file, "exec")
67 # Other exceptions (shouldn't be any...) will (correctly) fall
68 # through to "final".
69 except (OverflowError, SyntaxError, ValueError):
70 # FIXME: When can compile() raise anything else than
71 # SyntaxError ????
72 format_exception (file, False)
73 return
74 try:
75 exec(code, __main__.__dict__)
76 except:
77 format_exception (file, True)
78 finally:
79 os.remove (file)
80
81def eargs (name, imports):
82 "Get arglist of NAME for Eldoc &c."
83 try:
84 if imports: exec(imports)
85 parts = name.split ('.')
86 if len (parts) > 1:
87 exec('import ' + parts[0]) # might fail
88 func = eval (name)
89 if inspect.isbuiltin (func) or type(func) is type:
90 doc = func.__doc__
91 if doc.find (' ->') != -1:
92 print('_emacs_out', doc.split (' ->')[0])
93 else:
94 print('_emacs_out', doc.split ('\n')[0])
95 return
96 if inspect.ismethod (func):
97 func = func.im_func
98 if not inspect.isfunction (func):
99 print('_emacs_out ')
100 return
101 (args, varargs, varkw, defaults) = inspect.getargspec (func)
102 # No space between name and arglist for consistency with builtins.
103 print('_emacs_out', \
104 func.__name__ + inspect.formatargspec (args, varargs, varkw,
105 defaults))
106 except:
107 print("_emacs_out ")
108
109def all_names (object):
110 """Return (an approximation to) a list of all possible attribute
111 names reachable via the attributes of OBJECT, i.e. roughly the
112 leaves of the dictionary tree under it."""
113
114 def do_object (object, names):
115 if inspect.ismodule (object):
116 do_module (object, names)
117 elif inspect.isclass (object):
118 do_class (object, names)
119 # Might have an object without its class in scope.
120 elif hasattr (object, '__class__'):
121 names.add ('__class__')
122 do_class (object.__class__, names)
123 # Probably not a good idea to try to enumerate arbitrary
124 # dictionaries...
125 return names
126
127 def do_module (module, names):
128 if hasattr (module, '__all__'): # limited export list
129 names.update(module.__all__)
130 for i in module.__all__:
131 do_object (getattr (module, i), names)
132 else: # use all names
133 names.update(dir (module))
134 for i in dir (module):
135 do_object (getattr (module, i), names)
136 return names
137
138 def do_class (object, names):
139 ns = dir (object)
140 names.update(ns)
141 if hasattr (object, '__bases__'): # superclasses
142 for i in object.__bases__: do_object (i, names)
143 return names
144
145 return do_object (object, set([]))
146
147def complete (name, imports):
148 """Complete TEXT in NAMESPACE and print a Lisp list of completions.
149 Exec IMPORTS first."""
150 import __main__, keyword
151
152 def class_members(object):
153 names = dir (object)
154 if hasattr (object, '__bases__'):
155 for super in object.__bases__:
156 names = class_members (super)
157 return names
158
159 names = set([])
160 base = None
161 try:
162 dict = __main__.__dict__.copy()
163 if imports: exec(imports, dict)
164 l = len (name)
165 if not "." in name:
166 for src in [dir (__builtins__), keyword.kwlist, list(dict.keys())]:
167 for elt in src:
168 if elt[:l] == name: names.add(elt)
169 else:
170 base = name[:name.rfind ('.')]
171 name = name[name.rfind('.')+1:]
172 try:
173 object = eval (base, dict)
174 names = set(dir (object))
175 if hasattr (object, '__class__'):
176 names.add('__class__')
177 names.update(class_members (object))
178 except: names = all_names (dict)
179 except:
180 print(sys.exc_info())
181 names = []
182
183 l = len(name)
184 print('_emacs_out (', end=' ')
185 for n in names:
186 if name == n[:l]:
187 if base: print('"%s.%s"' % (base, n), end=' ')
188 else: print('"%s"' % n, end=' ')
189 print(')')
190
191def ehelp (name, imports):
192 """Get help on string NAME.
193 First try to eval name for, e.g. user definitions where we need
194 the object. Otherwise try the string form."""
195 locls = {}
196 if imports:
197 try: exec(imports, locls)
198 except: pass
199 try: help (eval (name, globals(), locls))
200 except: help (name)
201
202def eimport (mod, dir):
203 """Import module MOD with directory DIR at the head of the search path.
204 NB doesn't load from DIR if MOD shadows a system module."""
205 from __main__ import __dict__
206
207 path0 = sys.path[0]
208 sys.path[0] = dir
209 try:
210 try:
211 if mod in __dict__ and inspect.ismodule (__dict__[mod]):
212 imp.reload (__dict__[mod])
213 else:
214 __dict__[mod] = __import__ (mod)
215 except:
216 (type, value, tb) = sys.exc_info ()
217 print("Traceback (most recent call last):")
218 traceback.print_exception (type, value, tb.tb_next)
219 finally:
220 sys.path[0] = path0
221
222def modpath (module):
223 """Return the source file for the given MODULE (or None).
224Assumes that MODULE.py and MODULE.pyc are in the same directory."""
225 try:
226 path = __import__ (module).__file__
227 if path[-4:] == '.pyc' and os.path.exists (path[0:-1]):
228 path = path[:-1]
229 print("_emacs_out", path)
230 except:
231 print("_emacs_out ()")
232
233# print '_emacs_ok' # ready for input and can call continuation
234