diff options
author | randnobx <randynobx@gmail.com> | 2015-03-20 21:02:30 -0400 |
---|---|---|
committer | randnobx <randynobx@gmail.com> | 2015-04-11 13:46:14 -0400 |
commit | c56bf8705f75301d4dabf49991e4c509b71d5901 (patch) | |
tree | 07cbf372bf27c59054c858e291bb2ed991a5f72c /ranger | |
parent | 3160c4a7ebedf85c068baa4bae6747cafc123d4b (diff) | |
download | ranger-c56bf8705f75301d4dabf49991e4c509b71d5901.tar.gz |
added tag management for rename, delete, bulkrename, and moving of files
fixed typo in rename added recursive checking to move, rename, and delete; refactored previos code bugfix: moved recursive tag checking for delete to commands.py
Diffstat (limited to 'ranger')
-rw-r--r-- | ranger/config/commands.py | 26 | ||||
-rw-r--r-- | ranger/core/loader.py | 7 |
2 files changed, 33 insertions, 0 deletions
diff --git a/ranger/config/commands.py b/ranger/config/commands.py index 8797cb6b..38b4f598 100644 --- a/ranger/config/commands.py +++ b/ranger/config/commands.py @@ -523,10 +523,16 @@ class delete(Command): self._question_callback, ('n', 'N', 'y', 'Y')) else: # no need for a confirmation, just delete + for f in self.fm.tags.tags: + if str(f).startswith(self.fm.thisfile.path): + self.fm.tags.remove(f) self.fm.delete() def _question_callback(self, answer): if answer == 'y' or answer == 'Y': + for f in self.fm.tags.tags: + if str(f).startswith(self.fm.thisfile.path): + self.fm.tags.remove(f) self.fm.delete() @@ -725,6 +731,13 @@ class rename(Command): new_name = self.rest(1) + tagged = {} + old_name = self.fm.thisfile.basename + for f in self.fm.tags.tags: + if str(f).startswith(self.fm.thisfile.path): + tagged[f] = self.fm.tags.tags[f] + self.fm.tags.remove(f) + if not new_name: return self.fm.notify('Syntax: rename <newname>', bad=True) @@ -738,6 +751,9 @@ class rename(Command): f = File(new_name) self.fm.thisdir.pointed_obj = f self.fm.thisfile = f + for t in tagged: + self.fm.tags.tags[t.replace(old_name,new_name)] = tagged[t] + self.fm.tags.dump() def tab(self): return self._tab_directory_content() @@ -813,6 +829,11 @@ class bulkrename(Command): # Create and edit the file list filenames = [f.relative_path for f in self.fm.thistab.get_selection()] + tagged = {} + for f in self.fm.thistab.get_selection(): + if f.path in self.fm.tags: + tagged[f.relative_path] = self.fm.tags.tags[f.path] + self.fm.tags.remove(f.path) listfile = tempfile.NamedTemporaryFile(delete=False) listpath = listfile.name @@ -846,6 +867,11 @@ class bulkrename(Command): self.fm.run(['/bin/sh', cmdfile.name], flags='w') cmdfile.close() + for old,new in zip(filenames, new_filenames): + if old != new and old in tagged: + newpath = self.fm.thisdir.path + '/' + new + self.fm.tags.tags[newpath] = tagged[old] + self.fm.tags.dump() class relink(Command): """:relink <newpath> diff --git a/ranger/core/loader.py b/ranger/core/loader.py index 86a591f0..8eda544f 100644 --- a/ranger/core/loader.py +++ b/ranger/core/loader.py @@ -85,6 +85,13 @@ class CopyLoader(Loadable, FileManagerAware): else: self.description = "moving files from: " + self.one_file.dirname for f in self.copy_buffer: + for tf in self.fm.tags.tags: + if tf == f.path or str(tf).startswith(f.path): + tag = self.fm.tags.tags[tf] + self.fm.tags.remove(tf) + self.fm.tags.tags[tf.replace(f.path, self.original_path \ + + '/' + f.basename)] = tag + self.fm.tags.dump() for _ in shutil_g.move(src=f.path, dst=self.original_path, overwrite=self.overwrite): |