From 4718ba3003af2c7e6dac34772a99040188af84e2 Mon Sep 17 00:00:00 2001 From: Erik Osheim Date: Wed, 10 Jun 2009 23:53:51 -0400 Subject: [PATCH] improved some mode.dir method names --HG-- branch : pmacs2 --- mode/dir.py | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/mode/dir.py b/mode/dir.py index a4d2def..f27301c 100644 --- a/mode/dir.py +++ b/mode/dir.py @@ -59,13 +59,13 @@ class SortName(FsSettingBase): msg = "Sorting files by name, type" def _doit(self, w, **vargs): w.buffer.settings['type-sort'] = False -class RefreshView(Method): +class DirRefresh(Method): def _execute(self, w, **vargs): t = dirutil.resolve_token(w) s = t.string w.buffer.reload() dirutil.find_name(w, s) -class OpenPath(Method): +class DirOpen(Method): def _execute(self, w, **vargs): path = dirutil.resolve_path(w) w.set_error("opening %r" % path) @@ -104,7 +104,7 @@ class DirCmd(Method): w.set_error("%s failed (exit %d)" % (self.name, status)) dirutil.find_name(w, basename) -class Chmod(DirCmd): +class DirChmod(DirCmd): args = [Argument('mode', type=type(''), prompt="New Mode: ")] octal_re = re.compile('^[0-7]{1,4}$') symbolic_re = re.compile('(?:[ugoa]*(?:[-+=](?:[rwxXst]*|[ugo]))+ *,?)+') @@ -118,7 +118,7 @@ class Chmod(DirCmd): else: w.set_error("Not a valid mode: %r" % vargs['mode']) self._run(w, **vargs) -class Chown(DirCmd): +class DirChown(DirCmd): args = [Argument('owner', type=type(''), prompt="New Owner: ")] def _make_cmd(self, w, path, **vargs): return 'chown %r %r' % (vargs['owner'], path) @@ -138,7 +138,7 @@ class Chown(DirCmd): w.set_error('Group %r does not exist' % group) return self._run(w, **vargs) -class Chgrp(DirCmd): +class DirChgrp(DirCmd): args = [Argument('group', type=type(''), prompt="New Group: ")] def _make_cmd(self, w, path, **vargs): return 'chgrp %r %r' % (vargs['group'], path) @@ -148,17 +148,17 @@ class Chgrp(DirCmd): return self._run(w, **vargs) -class TouchPath(Method): +class DirTouch(Method): args = [Argument('filename', datatype="path", prompt="Touch File: ")] def _execute(self, w, **vargs): basename = vargs['filename'] path = os.path.join(w.buffer.path, basename) retval = os.system('touch %r' % path) - w.application.methods['refresh-view'].execute(w, filename=path) + w.application.methods['dir-refresh'].execute(w, filename=path) dirutil.find_name(w, basename) if retval != 0: w.set_error("touch %r failed (exit %d)" % (path, retval)) -class RemovePath(Method): +class DirRemove(Method): def _execute(self, w, **vargs): self._old_window = w self._old_path = dirutil.resolve_path(w) @@ -183,7 +183,7 @@ class RemovePath(Method): w.application.methods['previous-line'].execute(w) os.remove(path) w.set_error("deleted %r " % path) - w.application.methods['refresh-view'].execute(w, filename=path) + w.application.methods['dir-refresh'].execute(w, filename=path) except: w.set_error("failed to delete %r" % path) @@ -217,17 +217,18 @@ class Dir(mode.Fundamental): 'dir_size': ('yellow', 'default', 'bold'), 'dir_mtime': ('green', 'default', 'bold'), } - actions = [RefreshView, OpenPath, DirGrep, Chmod, Chown, Chgrp, TouchPath, - RemovePath, HideDotFiles, ShowDotFiles, SortName, SortType] + actions = [DirRefresh, DirOpen, DirGrep, DirChmod, DirChown, DirChgrp, + DirTouch, DirRemove, HideDotFiles, ShowDotFiles, SortName, + SortType] def __init__(self, w): mode.Fundamental.__init__(self, w) - self.add_bindings('refresh-view', ('C-c r',)) - self.add_bindings('open-path', ('RETURN',)) + self.add_bindings('dir-refresh', ('C-c r',)) + self.add_bindings('dir-open', ('RETURN',)) self.add_bindings('dir-grep', ('C-c G',)) - self.add_bindings('chmod', ('C-c m',)) - self.add_bindings('chown', ('C-c o',)) - self.add_bindings('chgrp', ('C-c g',)) - self.add_bindings('touch-path', ('C-c t',)) - self.add_bindings('remove-path', ('DELETE', 'BACKSPACE', 'C-d')) + self.add_bindings('dir-chmod', ('C-c m',)) + self.add_bindings('dir-chown', ('C-c o',)) + self.add_bindings('dir-chgrp', ('C-c g',)) + self.add_bindings('dir-touch', ('C-c t',)) + self.add_bindings('dir-remove', ('DELETE', 'BACKSPACE', 'C-d')) install = Dir.install