about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--doc/ranger.15
-rw-r--r--doc/ranger.pod3
-rw-r--r--doc/rifle.12
-rwxr-xr-xranger/config/commands.py35
-rw-r--r--ranger/container/settings.py2
5 files changed, 31 insertions, 16 deletions
diff --git a/doc/ranger.1 b/doc/ranger.1
index 095e061a..a26043ce 100644
--- a/doc/ranger.1
+++ b/doc/ranger.1
@@ -129,7 +129,7 @@
 .\" ========================================================================
 .\"
 .IX Title "RANGER 1"
-.TH RANGER 1 "ranger-1.8.1" "01/08/2017" "ranger manual"
+.TH RANGER 1 "ranger-1.8.1" "2017-01-24" "ranger manual"
 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
 .\" way too many mistakes in technical documents.
 .if n .ad l
@@ -1241,6 +1241,9 @@ directory. If no path is given, uses the current directory.
 \&\fIpath\fR is a regular expression.  This means that \f(CW\*(C`path=~/dl\*(C'\fR applies to all
 paths that start with \fI~/dl\fR, e.g. \fI~/dl2\fR and \fI~/dl/foo\fR. To avoid this,
 use \f(CW\*(C`path=~/dl$\*(C'\fR.
+.Sp
+\&\fIpath\fR can be quoted with either single or double quotes to prevent unwanted
+splitting. \fIpath='~/dl dl$'\fR or \fIpath=\*(L"~/dl dl$\*(R"\fR
 .IP "shell [\-\fIflags\fR] \fIcommand\fR" 2
 .IX Item "shell [-flags] command"
 Run a shell command.  \fIflags\fR are discussed in their own section.
diff --git a/doc/ranger.pod b/doc/ranger.pod
index fe2b45eb..e7f7acdc 100644
--- a/doc/ranger.pod
+++ b/doc/ranger.pod
@@ -1296,6 +1296,9 @@ I<path> is a regular expression.  This means that C<path=~/dl> applies to all
 paths that start with I<~/dl>, e.g. I<~/dl2> and I<~/dl/foo>. To avoid this,
 use C<path=~/dl$>.
 
+I<path> can be quoted with either single or double quotes to prevent unwanted
+splitting. I<path='~/dl dl$'> or I<path="~/dl dl$">
+
 =item shell [-I<flags>] I<command>
 
 Run a shell command.  I<flags> are discussed in their own section.
diff --git a/doc/rifle.1 b/doc/rifle.1
index 1e75474f..66d5627f 100644
--- a/doc/rifle.1
+++ b/doc/rifle.1
@@ -129,7 +129,7 @@
 .\" ========================================================================
 .\"
 .IX Title "RIFLE 1"
-.TH RIFLE 1 "rifle-1.8.1" "01/08/2017" "rifle manual"
+.TH RIFLE 1 "rifle-1.8.1" "2017-01-24" "rifle manual"
 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
 .\" way too many mistakes in technical documents.
 .if n .ad l
diff --git a/ranger/config/commands.py b/ranger/config/commands.py
index eba94e19..cd9e0444 100755
--- a/ranger/config/commands.py
+++ b/ranger/config/commands.py
@@ -387,25 +387,34 @@ class setlocal(set_):
 
     Gives an option a new value.
     """
-    PATH_RE = re.compile(r'^\s*path="?(.*?)"?\s*$')
+    PATH_RE_DQUOTED = re.compile(r'^setlocal\s+path="(.*?)"')
+    PATH_RE_SQUOTED = re.compile(r"^setlocal\s+path='(.*?)'")
+    PATH_RE_UNQUOTED = re.compile(r'^path=(.*?)$')
+
+    def _re_shift(self, match):
+        if not match:
+            return None
+        path = os.path.expanduser(match.group(1))
+        for _ in range(len(path.split())):
+            self.shift()
+        return path
 
     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._re_shift(self.PATH_RE_DQUOTED.match(self.line))
+        if path is None:
+            path = self._re_shift(self.PATH_RE_SQUOTED.match(self.line))
+        if path is None:
+            path = self._re_shift(self.PATH_RE_UNQUOTED.match(self.arg(1)))
+        if path is None and self.fm.thisdir:
             path = self.fm.thisdir.path
-        else:
-            path = None
+        if not path:
+            return
 
-        if path:
-            name = self.arg(1)
-            name, value, _ = self.parse_setting_line()
-            self.fm.set_option_from_string(name, value, localpath=path)
+        name, value, _ = self.parse_setting_line()
+        self.fm.set_option_from_string(name, value, localpath=path)
 
 
-class setintag(setlocal):
+class setintag(set_):
     """:setintag <tag or tags> <option name>=<option value>
 
     Sets an option for directories that are tagged with a specific tag.
diff --git a/ranger/container/settings.py b/ranger/container/settings.py
index 012b5a2c..4744de4d 100644
--- a/ranger/container/settings.py
+++ b/ranger/container/settings.py
@@ -167,7 +167,7 @@ class Settings(SignalDispatcher, FileManagerAware):
             try:
                 localpath = self.fm.thisdir.path
             except AttributeError:
-                localpath = path
+                localpath = None
 
         if localpath:
             for pattern, regex in self._localregexes.items():