v2.6 clean-up

--HG--
branch : pmacs2
This commit is contained in:
moculus 2008-03-16 20:26:32 +00:00
parent bcb11ed386
commit 1bc1b24170
6 changed files with 12 additions and 40 deletions

View File

@ -629,7 +629,7 @@ class AboutBuffer(DataBuffer):
************ ***** ***** **** ************* ********** *********** ************ ***** ***** **** ************* ********** ***********
********** ***** ***** **** ****** **** ******** ********* ********** ***** ***** **** ****** **** ******** *********
*** ***
*** pmacs is a python-based text editor by Erik Osheim, (c) 2005-2007 *** pmacs is a python-based text editor by Erik Osheim, (c) 2005-2008
***** pmacs is available to you under the GNU General Public License v2 ***** pmacs is available to you under the GNU General Public License v2
***** *****
***** to see all available commands use: C-c M-h (show-bindings-buffer) ***** to see all available commands use: C-c M-h (show-bindings-buffer)

View File

@ -1,4 +1,4 @@
import os, popen2 import os
from subprocess import Popen, PIPE, STDOUT from subprocess import Popen, PIPE, STDOUT
import cache import cache
@ -21,17 +21,12 @@ class Speller(object):
def start(self): def start(self):
assert self.pipe is None assert self.pipe is None
self.pipe = popen2.Popen3('%s -a' % self.cmd, 'rw') self.pipe = Popen('%s -a' % self.cmd, shell=True, stdin=PIPE, stdout=PIPE)
self.pipe.childerr.close() self.pipe.stdout.readline()
self.pipe.fromchild.readline()
#self.pipe = Popen('%s -a' % self.cmd, stdin=PIPE, stdout=PIPE)
#self.pipe.stdout.readline()
def stop(self): def stop(self):
self.pipe.tochild.close() self.pipe.stdin.close()
self.pipe.fromchild.close() self.pipe.stdout.close()
#self.pipe.stdin.close()
#self.pipe.stdout.close()
self.pipe = None self.pipe = None
def restart(self): def restart(self):
@ -61,17 +56,13 @@ class Speller(object):
if self.pipe.poll() >= 0: if self.pipe.poll() >= 0:
self.pipe = None self.pipe = None
self.start() self.start()
#self.pipe.tochild.write("%s\n" % (word))
#self.pipe.tochild.flush()
self.pipe.stdin.write("%s\n" % (word)) self.pipe.stdin.write("%s\n" % (word))
self.pipe.stdin.flush() self.pipe.stdin.flush()
l = self.pipe.fromchild.readline() l = self.pipe.stdout.readline()
#l = self.pipe.stdout.readline()
if l.startswith("*") or l.startswith("+") or l.startswith("-"): if l.startswith("*") or l.startswith("+") or l.startswith("-"):
result = True result = True
while True: while True:
l = self.pipe.fromchild.readline() l = self.pipe.stdout.readline()
#l = self.pipe.stdout.readline()
if l == "\n": if l == "\n":
break break
self.cache[word] = result self.cache[word] = result
@ -81,9 +72,8 @@ class Speller(object):
if self.pipe.poll() >= 0: if self.pipe.poll() >= 0:
self.pipe = None self.pipe = None
self.start() self.start()
self.pipe.tochild.write("*%s\n" % (word)) self.pipe.stdin.write("*%s\n" % (word))
#self.pipe.stdin.write("*%s\n" % (word)) self.pipe.stdin.flush()
self.pipe.tochild.flush()
self.flush(word) self.flush(word)
if _can_spell: if _can_spell:

View File

@ -618,7 +618,6 @@ class InsertTab(Method):
i = None i = None
if i is None: if i is None:
#w.insert_string_at_cursor(' ')
w.insert_string_at_cursor(' ' * w.mode.tabwidth) w.insert_string_at_cursor(' ' * w.mode.tabwidth)
else: else:
j = w.buffer.count_leading_whitespace(cursor.y) j = w.buffer.count_leading_whitespace(cursor.y)
@ -705,7 +704,6 @@ class WrapLine(Method):
i -= 1 i -= 1
return i, x, y return i, x, y
def _clear_preceeding_spaces(self, tokens, x, y): def _clear_preceeding_spaces(self, tokens, x, y):
#while tokens and tokens[0].isspace():
while tokens and self.space_re.match(tokens[0]): while tokens and self.space_re.match(tokens[0]):
if x > 0: if x > 0:
x = max(0, x - len(tokens[0])) x = max(0, x - len(tokens[0]))
@ -737,7 +735,6 @@ class WrapLine(Method):
lines, x, y = self._wrap_line(w.buffer.lines[y], x, y) lines, x, y = self._wrap_line(w.buffer.lines[y], x, y)
if lines is None: if lines is None:
return return
#w.buffer.delete_line(cursor.y)
p1 = Point(0, cursor.y) p1 = Point(0, cursor.y)
p2 = Point(len(w.buffer.lines[cursor.y]), cursor.y) p2 = Point(len(w.buffer.lines[cursor.y]), cursor.y)
w.buffer.delete(p1, p2) w.buffer.delete(p1, p2)
@ -1087,18 +1084,13 @@ class FileDiff(Method):
args = [Argument("path", type=type(""), prompt="Filename: ", datatype='path')] args = [Argument("path", type=type(""), prompt="Filename: ", datatype='path')]
def _execute(self, w, **vargs): def _execute(self, w, **vargs):
cmd = ("/usr/bin/diff", '-u', '-', vargs['path']) cmd = ("/usr/bin/diff", '-u', '-', vargs['path'])
#pipe = popen2.Popen3(cmd, capturestderr=True)
pipe = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) pipe = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)
pid = pipe.pid pid = pipe.pid
indata = w.buffer.make_string() indata = w.buffer.make_string()
#pipe.tochild.write(indata)
#pipe.tochild.close()
pipe.stdin.write(indata) pipe.stdin.write(indata)
pipe.stdin.close() pipe.stdin.close()
#outdata = pipe.fromchild.read()
#errdata = pipe.childerr.read()
outdata = pipe.stdout.read() outdata = pipe.stdout.read()
errdata = pipe.stderr.read() errdata = pipe.stderr.read()
status = pipe.wait() >> 8 status = pipe.wait() >> 8
@ -1138,11 +1130,9 @@ class SvnBlame(Method):
return return
cmd = ("/usr/bin/svn", 'blame', '-v', w.buffer.path) cmd = ("/usr/bin/svn", 'blame', '-v', w.buffer.path)
#pipe = popen2.Popen3(cmd)
pipe = Popen(cmd, stdin=PIPE, stdout=PIPE) pipe = Popen(cmd, stdin=PIPE, stdout=PIPE)
lines = [] lines = []
#for line in pipe.fromchild:
for line in pipe.stdout: for line in pipe.stdout:
m = self.line_re.match(line) m = self.line_re.match(line)
if not m: if not m:
@ -1347,13 +1337,11 @@ class CvsBlame(Method):
path = path[len(cwd):] path = path[len(cwd):]
cmd = ("/usr/bin/cvs", 'annotate', path) cmd = ("/usr/bin/cvs", 'annotate', path)
#pipe = popen2.Popen3(cmd, capturestderr=True)
pipe = Popen(cmd, stdout=PIPE) pipe = Popen(cmd, stdout=PIPE)
tokens = [] tokens = []
max_rev = 0 max_rev = 0
max_user = 0 max_user = 0
#for line in pipe.fromchild:
for line in pipe.stdout: for line in pipe.stdout:
m = self.line_re.match(line) m = self.line_re.match(line)
if not m: if not m:
@ -1664,17 +1652,13 @@ class Pipe(Method):
if prog is None: if prog is None:
return return
#pipe = popen2.Popen4(cmd)
pipe = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=STDOUT) pipe = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=STDOUT)
pid = pipe.pid pid = pipe.pid
indata = w.buffer.make_string() indata = w.buffer.make_string()
#pipe.tochild.write(indata)
#pipe.tochild.close()
pipe.stdin.write(indata) pipe.stdin.write(indata)
pipe.stdin.close() pipe.stdin.close()
#outdata = pipe.fromchild.read()
outdata = pipe.stdout.read() outdata = pipe.stdout.read()
status = pipe.wait() >> 8 status = pipe.wait() >> 8

View File

@ -10,7 +10,7 @@ class MiniBuffer(buffer.Buffer):
def __new__(cls, *args, **kwargs): def __new__(cls, *args, **kwargs):
global mini global mini
if mini is None: if mini is None:
mini = object.__new__(MiniBuffer, *args, **kwargs) mini = object.__new__(MiniBuffer)
return mini return mini
# the callback function should take one argument (window) # the callback function should take one argument (window)
def __init__(self, func, method=None, tabber=None, modename=None): def __init__(self, func, method=None, tabber=None, modename=None):

View File

@ -7,7 +7,7 @@ class AboutGrammar(Grammar):
PatternRule(r'about_equals', r'=+'), PatternRule(r'about_equals', r'=+'),
PatternRule(r'about_pmacs', r'pmacs'), PatternRule(r'about_pmacs', r'pmacs'),
PatternRule(r'about_author', r'Erik Osheim'), PatternRule(r'about_author', r'Erik Osheim'),
PatternRule(r'about_copyright', r'\(c\) 2005-2007'), PatternRule(r'about_copyright', r'\(c\) 2005-2008'),
PatternRule(r'about_license', r'GNU General Public License v2'), PatternRule(r'about_license', r'GNU General Public License v2'),
PatternRule(r'about_binding', r'C-c M-h'), PatternRule(r'about_binding', r'C-c M-h'),
PatternRule(r'about_command', r'\(show-bindings-buffer\)'), PatternRule(r'about_command', r'\(show-bindings-buffer\)'),

View File

@ -225,9 +225,7 @@ class CSetMake(method.Method):
class CMake(method.Method): class CMake(method.Method):
'''Check the syntax of the current python file''' '''Check the syntax of the current python file'''
def _execute(self, w, **vargs): def _execute(self, w, **vargs):
#p = popen2.Popen4(w.mode.makecmd)
p = Popen(w.mode.makecmd, stdout=PIPE) p = Popen(w.mode.makecmd, stdout=PIPE)
#output = p.fromchild.read()
output = p.stdout.read() output = p.stdout.read()
result = p.wait() result = p.wait()