parent
563bf266a3
commit
c104583d90
14
README
14
README
|
@ -2,14 +2,18 @@ Pmacs version 0.1
|
|||
|
||||
Released june 27, 2007 by Erik Osheim <erik@osheim.org>
|
||||
|
||||
Explanation paragraph goes here.
|
||||
Pmacs is an Emacs-like editor written entirely in Python. It is designed to have
|
||||
maximally correct and powerful support for syntax highlighting, indenting, etc.
|
||||
and to be extensible in python.
|
||||
|
||||
Requirements:
|
||||
=============
|
||||
1. python 2.3 or higher
|
||||
2. ncurses
|
||||
3. ispell (optional, for spell-as-you-type)
|
||||
4. perl (optional, for perl-mode)
|
||||
5. etc, etc, etc...
|
||||
|
||||
Basic usage stuff should go here.
|
||||
Optional Dependencies:
|
||||
======================
|
||||
1. ispell
|
||||
2. aespipe
|
||||
3. perl
|
||||
4. ctags
|
||||
|
|
|
@ -365,7 +365,7 @@ class PerlViewWordPerldoc(method.Method):
|
|||
# then try it as a function
|
||||
data = self._try(w, word, asfunc=True)
|
||||
if data:
|
||||
self._show(w, data, parts[0])
|
||||
self._show(w, data, word)
|
||||
else:
|
||||
w.application.set_error('nothing found for %r' % word)
|
||||
|
||||
|
|
|
@ -71,9 +71,11 @@ class PythonTabber(tab2.StackTabber):
|
|||
y -= 1
|
||||
|
||||
# ok, so clear out our stack and then loop over each line
|
||||
self.popped = False
|
||||
self.markers = []
|
||||
while y <= target:
|
||||
self.continued = False
|
||||
self.last_popped = self.popped
|
||||
self.popped = False
|
||||
tokens = self.get_tokens(y)
|
||||
currlvl = self.get_curr_level()
|
||||
|
@ -101,6 +103,12 @@ class PythonTabber(tab2.StackTabber):
|
|||
self.record[y] = tuple(self.markers)
|
||||
y += 1
|
||||
|
||||
def _handle_close_token(self, currlvl, y, i):
|
||||
try:
|
||||
return tab2.StackTabber._handle_close_token(self, currlvl, y, i)
|
||||
except:
|
||||
return currlvl
|
||||
|
||||
def _handle_other_token(self, currlvl, y, i):
|
||||
token = self.get_token(y, i)
|
||||
fqname = token.fqname()
|
||||
|
@ -131,24 +139,26 @@ class PythonTabber(tab2.StackTabber):
|
|||
if token.string in self.endlevel_names:
|
||||
# we know we'll unindent at least once
|
||||
self._pop()
|
||||
self.popped = True
|
||||
elif token.string in self.startlevel_names and self.is_leftmost_token(y, i):
|
||||
# we know we will indent exactly once
|
||||
self._append(token.string, currlvl + 4)
|
||||
elif token.string in ('elif', 'else') and self.is_leftmost_token(y, i):
|
||||
# we know we'll unindent at least to the first if/elif
|
||||
if not self.popped:
|
||||
if not self.popped and not self.last_popped:
|
||||
raise Exception, "junka"
|
||||
self._pop_until('if', 'elif')
|
||||
currlvl = self.get_curr_level()
|
||||
self._append(token.string, currlvl + 4)
|
||||
elif token.string == 'except' and self.is_leftmost_token(y, i):
|
||||
# we know we'll unindent at least to the first try
|
||||
if not self.popped:
|
||||
if not self.popped and not self.last_popped:
|
||||
self._pop_until('try')
|
||||
currlvl = self.get_curr_level()
|
||||
self._append(token.string, currlvl + 4)
|
||||
elif token.string == 'finally' and self.is_leftmost_token(y, i):
|
||||
# we know we'll unindent at least to the first try/except
|
||||
if not self.popped:
|
||||
if not self.popped and not self.last_popped:
|
||||
self._pop_until('try', 'except')
|
||||
currlvl = self.get_curr_level()
|
||||
self._append(token.string, currlvl + 4)
|
||||
|
@ -192,19 +202,23 @@ class Python(mode2.Fundamental):
|
|||
'continuation': color.build('red', 'default'),
|
||||
'system_identifier': color.build('cyan', 'default'),
|
||||
}
|
||||
self.pythonlib = "."
|
||||
def name(self):
|
||||
return "Python"
|
||||
|
||||
class PythonCheckSyntax(method.Method):
|
||||
'''Check the syntax of the current python file'''
|
||||
class PythonSetLib(method.Method):
|
||||
'''Set the path(s) to find perl modules'''
|
||||
def _args(self):
|
||||
return [method.Argument("lib", type=type(""), prompt="Python Path: ",
|
||||
datatype='path',
|
||||
default=default.build_constant("."))]
|
||||
def _execute(self, w, **vargs):
|
||||
a = vargs['lib']
|
||||
w.mode.pythonlib = vargs['lib']
|
||||
|
||||
class PythonCheckSyntax(method.Method):
|
||||
'''Check the syntax of the current python file'''
|
||||
def _execute(self, w, **vargs):
|
||||
mod = os.path.splitext(os.path.basename(w.buffer.path))[0]
|
||||
cmd = "PYTHONPATH=%s python -c 'import %s'" % (a, mod)
|
||||
cmd = "PYTHONPATH=%s python -c 'import %s'" % (w.mode.pythonlib, mod)
|
||||
(status, output) = commands.getstatusoutput(cmd)
|
||||
if status == 0:
|
||||
w.application.set_error("Syntax OK")
|
||||
|
@ -362,4 +376,4 @@ class PythonDictCleanup(method.Method):
|
|||
start_p = Point(0, start)
|
||||
end_p = Point(0, end + 1)
|
||||
w.kill(start_p, end_p)
|
||||
w.insert(start_p, data)
|
||||
w.insert_string(start_p, data)
|
||||
|
|
2
tab2.py
2
tab2.py
|
@ -145,7 +145,7 @@ class StackTabber(Tabber):
|
|||
if not self.markers:
|
||||
raise Exception, "unmatched closing token %r" % s1
|
||||
s2 = self.markers[-1].name
|
||||
if s1 == self.mode.opentags[s2]:
|
||||
if self.mode.closetags[s1] == s2:
|
||||
self._pop()
|
||||
if self.is_leftmost_token(y, i):
|
||||
currlvl = self.get_curr_level()
|
||||
|
|
Loading…
Reference in New Issue