29 |
# |
# |
30 |
|
|
31 |
from Base import BaseCommand |
from Base import BaseCommand |
32 |
|
import tempfile, os, sys, string |
33 |
|
|
34 |
class Command(BaseCommand): |
class Command(BaseCommand): |
35 |
|
SHORT = "Opens the current buffer in an external editor" |
36 |
def call(self, args): |
def call(self, args): |
37 |
pass |
file = tempfile.mktemp() |
38 |
|
|
39 |
|
f = open(file,"w") |
40 |
|
f.writelines(self.instance.lastbuffer) |
41 |
|
f.close() |
42 |
|
|
43 |
|
if len(args): |
44 |
|
command = string.join(args) |
45 |
|
elif os.environ.has_key('EDITOR'): |
46 |
|
command = os.environ['EDITOR'] |
47 |
|
else: |
48 |
|
command = 'vi' |
49 |
|
|
50 |
|
os.system('%s "%s"' % (command, file)) |
51 |
|
|
52 |
|
self.instance.commands['get'].call([file]) |
53 |
|
os.unlink(file) |
54 |
|
return |
55 |
|
|
56 |
|
|
57 |
|
|
58 |
|
|