summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--doc/ranger.110
-rw-r--r--doc/ranger.pod7
-rw-r--r--ranger/api/commands.py2
-rw-r--r--ranger/config/commands.py31
-rw-r--r--ranger/config/rc.conf9
5 files changed, 54 insertions, 5 deletions
diff --git a/doc/ranger.1 b/doc/ranger.1
index 194b81b6..c0cf6b1f 100644
--- a/doc/ranger.1
+++ b/doc/ranger.1
@@ -726,6 +726,7 @@ ranger.  For your convenience, this is a list of the \*(L"public\*(R" commands i
 \& search pattern
 \& search_inc pattern
 \& set option value
+\& setlocal [path=<path>] option value
 \& shell [\-FLAGS] command
 \& terminal
 \& tmap key command
@@ -908,6 +909,11 @@ doesn't work for functions and regular expressions. Valid values are:
 \& list           | 1,2,3,4
 \& none           | none
 .Ve
+.IP "setlocal [path=\fIpath\fR] \fIoption\fR \fIvalue\fR" 2
+.IX Item "setlocal [path=path] option value"
+Assigns a new value to an option, but locally for the directory given by
+\&\fIpath\fR. This means, that this option only takes effect when visiting that
+directory. If no path is given, uses the current directory.
 .IP "shell [\-\fIflags\fR] \fIcommand\fR" 2
 .IX Item "shell [-flags] command"
 Run a shell command.  \fIflags\fR are discussed in their own section.
@@ -1034,8 +1040,8 @@ that is provided along with the source code.
 \&\s-1GNU\s0 General Public License 3 or (at your option) any later version.
 .SH "LINKS"
 .IX Header "LINKS"
-.IP "Download:  <http://ranger.nongnu.org/ranger-stable.tar.gz>" 4
-.IX Item "Download: <http://ranger.nongnu.org/ranger-stable.tar.gz>"
+.IP "Download: http://ranger.nongnu.org/ranger\-stable.tar.gz <http://ranger.nongnu.org/ranger-stable.tar.gz>" 4
+.IX Item "Download: http://ranger.nongnu.org/ranger-stable.tar.gz <http://ranger.nongnu.org/ranger-stable.tar.gz>"
 .PD 0
 .IP "The project page: <http://ranger.nongnu.org/>" 4
 .IX Item "The project page: <http://ranger.nongnu.org/>"
diff --git a/doc/ranger.pod b/doc/ranger.pod
index e240771e..366e0bdc 100644
--- a/doc/ranger.pod
+++ b/doc/ranger.pod
@@ -734,6 +734,7 @@ ranger.  For your convenience, this is a list of the "public" commands including
  search pattern
  search_inc pattern
  set option value
+ setlocal [path=<path>] option value
  shell [-FLAGS] command
  terminal
  tmap key command
@@ -949,6 +950,12 @@ doesn't work for functions and regular expressions. Valid values are:
  list           | 1,2,3,4
  none           | none
 
+=item setlocal [path=I<path>] I<option> I<value>
+
+Assigns a new value to an option, but locally for the directory given by
+I<path>. This means, that this option only takes effect when visiting that
+directory. If no path is given, uses the current directory.
+   
 =item shell [-I<flags>] I<command>
 
 Run a shell command.  I<flags> are discussed in their own section.
diff --git a/ranger/api/commands.py b/ranger/api/commands.py
index aaadde5d..15816247 100644
--- a/ranger/api/commands.py
+++ b/ranger/api/commands.py
@@ -146,6 +146,8 @@ class Command(FileManagerAware):
 
 	def shift(self):
 		del self.args[0]
+		del self.argspos[0]
+		self._setting_line = None
 		self._shifted += 1
 
 	def tabinsert(self, word):
diff --git a/ranger/config/commands.py b/ranger/config/commands.py
index 489f2426..3a3b84c4 100644
--- a/ranger/config/commands.py
+++ b/ranger/config/commands.py
@@ -76,6 +76,8 @@
 # of ranger.
 # ===================================================================
 
+import os
+
 from ranger.api.commands import *
 from ranger.ext.get_executables import get_executables
 from ranger.core.runner import ALLOWED_FLAGS
@@ -89,7 +91,7 @@ class alias(Command):
 
 	context = 'browser'
 	resolve_macros = False
-	
+
 	def execute(self):
 		if not self.arg(1) or not self.arg(2):
 			self.fm.notify('Syntax: alias <newcommand> <oldcommand>', bad=True)
@@ -406,6 +408,29 @@ class set_(Command):
 				return self.firstpart + 'False'
 
 
+class setlocal(set_):
+	"""
+	:setlocal path=<python string> <option name>=<python expression>
+
+	Gives an option a new value.
+	"""
+	PATH_RE=re.compile(r'^\s*path="?(.*?)"?\s*$')
+	def execute(self):
+		match = self.PATH_RE.match(self.arg(1))
+		if match:
+			path = os.path.normpath(os.path.expanduser(match.group(1)))
+			self.shift()
+		elif self.fm.thisdir:
+			path = self.fm.thisdir.path
+		else:
+			path = None
+
+		if path:
+			name = self.arg(1)
+			name, value, _ = self.parse_setting_line()
+			self.fm.set_option_from_string(name, value, localpath=path)
+
+
 class quit(Command):
 	"""
 	:quit
@@ -514,7 +539,7 @@ class mark(Command):
 		input = self.rest(1)
 		searchflags = re.UNICODE
 		if input.lower() == input: # "smartcase"
-			searchflags |= re.IGNORECASE 
+			searchflags |= re.IGNORECASE
 		pattern = re.compile(input, searchflags)
 		for fileobj in cwd.files:
 			if pattern.search(fileobj.basename):
@@ -851,7 +876,7 @@ class relink(Command):
 class help_(Command):
 	"""
 	:help
-	
+
 	Display ranger's manual page.
 	"""
 	name = 'help'
diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf
index 88e242fd..b2ffa725 100644
--- a/ranger/config/rc.conf
+++ b/ranger/config/rc.conf
@@ -134,6 +134,14 @@ set sort_directories_first true
 # (Especially on xterm)
 set xterm_alt_key true
 
+# ===================================================================
+# == Local Options
+# ===================================================================
+# You can set local options that only affect a single directory.
+
+# Examples:
+# setlocal path=~/downloads sort mtime
+# setlocal path="~/dir with spaces" use_preview_script false
 
 # ===================================================================
 # == Command Aliases in the Console
@@ -143,6 +151,7 @@ alias e    edit
 alias q    quit
 alias q!   quitall
 alias qall quitall
+alias setl setlocal
 
 # ===================================================================
 # == Define keys for the browser