summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/container/tags.py39
-rw-r--r--ranger/core/actions.py6
-rwxr-xr-xranger/data/scope.sh5
-rw-r--r--ranger/defaults/keys.py2
-rw-r--r--ranger/gui/widgets/pager.py2
5 files changed, 30 insertions, 24 deletions
diff --git a/ranger/container/tags.py b/ranger/container/tags.py
index ed015d16..c2fe3067 100644
--- a/ranger/container/tags.py
+++ b/ranger/container/tags.py
@@ -19,6 +19,7 @@ import string
 ALLOWED_KEYS = string.ascii_letters + string.digits + string.punctuation
 
 class Tags(object):
+	default_tag = '*'
 
 	def __init__(self, filename):
 
@@ -33,13 +34,13 @@ class Tags(object):
 		return item in self.tags
 
 	def add(self, *items, **others):
-		if 'mark' in others:
-			mark = others['mark']
+		if 'tag' in others:
+			tag = others['tag']
 		else:
-			mark = '*'
+			tag = self.defautag
 		self.sync()
 		for item in items:
-			self.tags[item] = mark
+			self.tags[item] = tag
 		self.dump()
 
 	def remove(self, *items):
@@ -52,17 +53,17 @@ class Tags(object):
 		self.dump()
 
 	def toggle(self, *items, **others):
-		if 'mark' in others:
-			mark = others['mark']
+		if 'tag' in others:
+			tag = others['tag']
 		else:
-			mark = '*'
+			tag = self.default_tag
 		self.sync()
 		for item in items:
 			try:
-				if item in self and self.tags[item] == mark:
+				if item in self and tag in (self.tags[item], self.default_tag):
 					del(self.tags[item])
 				else:
-					self.tags[item] = mark
+					self.tags[item] = tag
 			except KeyError:
 				pass
 		self.dump()
@@ -71,7 +72,7 @@ class Tags(object):
 		if item in self.tags:
 			return self.tags[item]
 		else:
-			return '*'
+			return self.default_tag
 
 	def sync(self):
 		try:
@@ -92,20 +93,24 @@ class Tags(object):
 			f.close()
 
 	def _compile(self, f):
-		for path, mark in self.tags.items():
-			if mark in ALLOWED_KEYS:
-				f.write('{0}:{1}\n'.format(mark, path))
+		for path, tag in self.tags.items():
+			if tag == self.default_tag:
+				# COMPAT: keep the old format if the default tag is used
+				f.write(path + '\n')
+			elif tag in ALLOWED_KEYS:
+				f.write('{0}:{1}\n'.format(tag, path))
 
 	def _parse(self, f):
 		result = dict()
 		for line in f:
 			line = line.strip()
 			if len(line) > 2 and line[1] == ':':
-				mark, path = line[0], line[2:]
-				if mark in ALLOWED_KEYS:
-					result[path] = mark
+				tag, path = line[0], line[2:]
+				if tag in ALLOWED_KEYS:
+					result[path] = tag
 			else:
-				result[line] = '*'
+				result[line] = self.default_tag
+
 		return result
 
 	def __nonzero__(self):
diff --git a/ranger/core/actions.py b/ranger/core/actions.py
index 7bb80343..96a2ad38 100644
--- a/ranger/core/actions.py
+++ b/ranger/core/actions.py
@@ -430,7 +430,7 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware):
 	# Tags are saved in ~/.config/ranger/tagged and simply mark if a
 	# file is important to you in any context.
 
-	def tag_toggle(self, paths=None, value=None, movedown=None, mark='*'):
+	def tag_toggle(self, paths=None, value=None, movedown=None, tag=None):
 		if not self.tags:
 			return
 		if paths is None:
@@ -438,11 +438,11 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware):
 		else:
 			tags = [realpath(path) for path in paths]
 		if value is True:
-			self.tags.add(*tags, mark=mark)
+			self.tags.add(*tags, tag=tag or self.tags.default_tag)
 		elif value is False:
 			self.tags.remove(*tags)
 		else:
-			self.tags.toggle(*tags, mark=mark)
+			self.tags.toggle(*tags, tag=tag or self.tags.default_tag)
 
 		if movedown is None:
 			movedown = len(tags) == 1 and paths is None
diff --git a/ranger/data/scope.sh b/ranger/data/scope.sh
index 9f212cae..ca1f7e67 100755
--- a/ranger/data/scope.sh
+++ b/ranger/data/scope.sh
@@ -30,14 +30,15 @@ extension=$(echo "$path" | grep '\.' | grep -o '[^.]\+$')
 # Functions:
 # "have $1" succeeds if $1 is an existing command/installed program
 function have { type -P "$1" > /dev/null; }
-# "sucess" returns the exit code of the first program in the last pipe chain
+# "success" returns the exit code of the first program in the last pipe chain
 function success { test ${PIPESTATUS[0]} = 0; }
 
 case "$extension" in
 	# Archive extensions:
 	7z|a|ace|alz|arc|arj|bz|bz2|cab|cpio|deb|gz|jar|lha|lz|lzh|lzma|lzo|\
 	rar|rpm|rz|t7z|tar|tbz|tbz2|tgz|tlz|txz|tZ|tzo|war|xpi|xz|Z|zip)
-		atool -l "$path" | head -n $maxln && exit 3
+		als "$path" | head -n $maxln
+		success && exit 0 || acat "$path" | head -n $maxln && exit 3
 		exit 1;;
 	# PDF documents:
 	pdf)
diff --git a/ranger/defaults/keys.py b/ranger/defaults/keys.py
index 15aab318..cd1c5d07 100644
--- a/ranger/defaults/keys.py
+++ b/ranger/defaults/keys.py
@@ -160,7 +160,7 @@ map('L', fm.history_go(1))
 map('t', fm.tag_toggle())
 map('T', fm.tag_remove())
 for key in ALLOWED_TAGS_KEYS:
-		map('"' + key, fm.tag_toggle(mark=key))
+		map('"' + key, fm.tag_toggle(tag=key))
 
 map(' ', fm.mark(toggle=True))
 map('v', fm.mark(all=True, toggle=True))
diff --git a/ranger/gui/widgets/pager.py b/ranger/gui/widgets/pager.py
index d851de3f..05485189 100644
--- a/ranger/gui/widgets/pager.py
+++ b/ranger/gui/widgets/pager.py
@@ -213,7 +213,7 @@ class Pager(Widget):
 						self.lines.append(l)
 						if len(self.lines) > n:
 							break
-				except UnicodeError:
+				except (UnicodeError, IOError):
 					pass
 				return self._get_line(n, attempt_to_read=False)
 			return ""