From 1bc1b241707f36a6d5e03748498d0e1548eeea60 Mon Sep 17 00:00:00 2001 From: moculus Date: Sun, 16 Mar 2008 20:26:32 +0000 Subject: [PATCH] v2.6 clean-up --HG-- branch : pmacs2 --- buffer.py | 2 +- ispell.py | 28 +++++++++------------------- method/__init__.py | 16 ---------------- minibuffer.py | 2 +- mode/about.py | 2 +- mode/c.py | 2 -- 6 files changed, 12 insertions(+), 40 deletions(-) diff --git a/buffer.py b/buffer.py index 1761466..6db7b52 100644 --- a/buffer.py +++ b/buffer.py @@ -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 ***** ***** to see all available commands use: C-c M-h (show-bindings-buffer) diff --git a/ispell.py b/ispell.py index 73a6d13..8a9d7cb 100644 --- a/ispell.py +++ b/ispell.py @@ -1,4 +1,4 @@ -import os, popen2 +import os from subprocess import Popen, PIPE, STDOUT import cache @@ -21,17 +21,12 @@ class Speller(object): def start(self): assert self.pipe is None - self.pipe = popen2.Popen3('%s -a' % self.cmd, 'rw') - self.pipe.childerr.close() - self.pipe.fromchild.readline() - #self.pipe = Popen('%s -a' % self.cmd, stdin=PIPE, stdout=PIPE) - #self.pipe.stdout.readline() + self.pipe = Popen('%s -a' % self.cmd, shell=True, stdin=PIPE, stdout=PIPE) + self.pipe.stdout.readline() def stop(self): - self.pipe.tochild.close() - self.pipe.fromchild.close() - #self.pipe.stdin.close() - #self.pipe.stdout.close() + self.pipe.stdin.close() + self.pipe.stdout.close() self.pipe = None def restart(self): @@ -61,17 +56,13 @@ class Speller(object): if self.pipe.poll() >= 0: self.pipe = None self.start() - #self.pipe.tochild.write("%s\n" % (word)) - #self.pipe.tochild.flush() self.pipe.stdin.write("%s\n" % (word)) 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("-"): result = True while True: - l = self.pipe.fromchild.readline() - #l = self.pipe.stdout.readline() + l = self.pipe.stdout.readline() if l == "\n": break self.cache[word] = result @@ -81,9 +72,8 @@ class Speller(object): if self.pipe.poll() >= 0: self.pipe = None self.start() - self.pipe.tochild.write("*%s\n" % (word)) - #self.pipe.stdin.write("*%s\n" % (word)) - self.pipe.tochild.flush() + self.pipe.stdin.write("*%s\n" % (word)) + self.pipe.stdin.flush() self.flush(word) if _can_spell: diff --git a/method/__init__.py b/method/__init__.py index 16db776..4177bd9 100644 --- a/method/__init__.py +++ b/method/__init__.py @@ -618,7 +618,6 @@ class InsertTab(Method): i = None if i is None: - #w.insert_string_at_cursor(' ') w.insert_string_at_cursor(' ' * w.mode.tabwidth) else: j = w.buffer.count_leading_whitespace(cursor.y) @@ -705,7 +704,6 @@ class WrapLine(Method): i -= 1 return i, 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]): if x > 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) if lines is None: return - #w.buffer.delete_line(cursor.y) p1 = Point(0, cursor.y) p2 = Point(len(w.buffer.lines[cursor.y]), cursor.y) w.buffer.delete(p1, p2) @@ -1087,18 +1084,13 @@ class FileDiff(Method): args = [Argument("path", type=type(""), prompt="Filename: ", datatype='path')] def _execute(self, w, **vargs): cmd = ("/usr/bin/diff", '-u', '-', vargs['path']) - #pipe = popen2.Popen3(cmd, capturestderr=True) pipe = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE) pid = pipe.pid indata = w.buffer.make_string() - #pipe.tochild.write(indata) - #pipe.tochild.close() pipe.stdin.write(indata) pipe.stdin.close() - #outdata = pipe.fromchild.read() - #errdata = pipe.childerr.read() outdata = pipe.stdout.read() errdata = pipe.stderr.read() status = pipe.wait() >> 8 @@ -1138,11 +1130,9 @@ class SvnBlame(Method): return cmd = ("/usr/bin/svn", 'blame', '-v', w.buffer.path) - #pipe = popen2.Popen3(cmd) pipe = Popen(cmd, stdin=PIPE, stdout=PIPE) lines = [] - #for line in pipe.fromchild: for line in pipe.stdout: m = self.line_re.match(line) if not m: @@ -1347,13 +1337,11 @@ class CvsBlame(Method): path = path[len(cwd):] cmd = ("/usr/bin/cvs", 'annotate', path) - #pipe = popen2.Popen3(cmd, capturestderr=True) pipe = Popen(cmd, stdout=PIPE) tokens = [] max_rev = 0 max_user = 0 - #for line in pipe.fromchild: for line in pipe.stdout: m = self.line_re.match(line) if not m: @@ -1664,17 +1652,13 @@ class Pipe(Method): if prog is None: return - #pipe = popen2.Popen4(cmd) pipe = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=STDOUT) pid = pipe.pid indata = w.buffer.make_string() - #pipe.tochild.write(indata) - #pipe.tochild.close() pipe.stdin.write(indata) pipe.stdin.close() - #outdata = pipe.fromchild.read() outdata = pipe.stdout.read() status = pipe.wait() >> 8 diff --git a/minibuffer.py b/minibuffer.py index c74719d..e4620c2 100644 --- a/minibuffer.py +++ b/minibuffer.py @@ -10,7 +10,7 @@ class MiniBuffer(buffer.Buffer): def __new__(cls, *args, **kwargs): global mini if mini is None: - mini = object.__new__(MiniBuffer, *args, **kwargs) + mini = object.__new__(MiniBuffer) return mini # the callback function should take one argument (window) def __init__(self, func, method=None, tabber=None, modename=None): diff --git a/mode/about.py b/mode/about.py index 4996953..127d08f 100644 --- a/mode/about.py +++ b/mode/about.py @@ -7,7 +7,7 @@ class AboutGrammar(Grammar): PatternRule(r'about_equals', r'=+'), PatternRule(r'about_pmacs', r'pmacs'), 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_binding', r'C-c M-h'), PatternRule(r'about_command', r'\(show-bindings-buffer\)'), diff --git a/mode/c.py b/mode/c.py index b98d09f..dd5b499 100644 --- a/mode/c.py +++ b/mode/c.py @@ -225,9 +225,7 @@ class CSetMake(method.Method): class CMake(method.Method): '''Check the syntax of the current python file''' def _execute(self, w, **vargs): - #p = popen2.Popen4(w.mode.makecmd) p = Popen(w.mode.makecmd, stdout=PIPE) - #output = p.fromchild.read() output = p.stdout.read() result = p.wait()