summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--doc/ranger.122
-rw-r--r--doc/ranger.pod15
-rw-r--r--doc/rifle.111
-rw-r--r--doc/rifle.pod8
-rwxr-xr-xranger/config/commands.py13
-rw-r--r--ranger/config/rc.conf5
-rw-r--r--ranger/config/rifle.conf6
-rw-r--r--ranger/container/settings.py2
-rwxr-xr-xranger/ext/rifle.py4
-rw-r--r--ranger/gui/widgets/view_miller.py8
-rwxr-xr-xtests/manpage_completion_test.py54
11 files changed, 115 insertions, 33 deletions
diff --git a/doc/ranger.1 b/doc/ranger.1
index bb7114a2..508c2972 100644
--- a/doc/ranger.1
+++ b/doc/ranger.1
@@ -1,4 +1,4 @@
-.\" Automatically generated by Pod::Man 4.07 (Pod::Simple 3.32)
+.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35)
 .\"
 .\" Standard preamble:
 .\" ========================================================================
@@ -129,7 +129,7 @@
 .\" ========================================================================
 .\"
 .IX Title "RANGER 1"
-.TH RANGER 1 "ranger-1.9.0b6" "12/07/2017" "ranger manual"
+.TH RANGER 1 "ranger-1.9.0b6" "2018-01-25" "ranger manual"
 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
 .\" way too many mistakes in technical documents.
 .if n .ad l
@@ -508,7 +508,7 @@ Redraw the screen
 Inspect the current file in a bigger window.
 .IP "E" 14
 .IX Item "E"
-Edit the current file in \f(CW$EDITOR\fR (\*(L"nano\*(R" by default)
+Edit the current file in \f(CW$VISUAL\fR otherwise \f(CW$EDITOR\fR otherwise \*(L"vim\*(R"
 .IP "S" 14
 .IX Item "S"
 Open a shell in the current directory
@@ -599,7 +599,7 @@ Toggle the mark-status of all files
 .IP "V" 14
 .IX Item "V"
 Starts the visual mode, which selects all files between the starting point and
-the cursor until you press \s-1ESC. \s0 To unselect files in the same way, use \*(L"uV\*(R".
+the cursor until you press \s-1ESC.\s0  To unselect files in the same way, use \*(L"uV\*(R".
 .IP "/" 14
 Search for files in the current directory.
 .IP ":" 14
@@ -729,9 +729,10 @@ Changes case sensitivity for the \*(L"cd\*(R" command tab completion. Possible v
 \& insensitive
 \& smart
 .Ve
-.IP "cd_tab_smart [bool]" 4
-.IX Item "cd_tab_smart [bool]"
-Use smart tab completion with less typing? E.g. \*(L":cd /f/b/b<tab>\*(R" yields \*(L":cd /foo/bar/baz\*(R".
+.IP "cd_tab_fuzzy [bool]" 4
+.IX Item "cd_tab_fuzzy [bool]"
+Use fuzzy tab completion with the \*(L"cd\*(R" command. For example,
+\&\fB:cd /u/lo/b<\s-1TAB\s0>\fR expands to \fB:cd /usr/local/bin\fR.
 .IP "clear_filters_on_dir_change [bool]" 4
 .IX Item "clear_filters_on_dir_change [bool]"
 If set to 'true', persistent filters would be cleared upon leaving the directory
@@ -1457,9 +1458,14 @@ by checking for this variable.
 If this variable is set to \s-1FALSE,\s0 ranger will not load the default rc.conf.
 This can save time if you copied the whole rc.conf to ~/.config/ranger/ and
 don't need the default one at all.
+.IP "\s-1VISUAL\s0" 8
+.IX Item "VISUAL"
+Defines the editor to be used for the \*(L"E\*(R" key.  Falls back to \s-1EDITOR\s0 if
+undefined or empty.
 .IP "\s-1EDITOR\s0" 8
 .IX Item "EDITOR"
-Defines the editor to be used for the \*(L"E\*(R" key.  Defaults to \*(L"nano\*(R".
+Defines the editor to be used for the \*(L"E\*(R" key if \s-1VISUAL\s0 is undefined or empty.
+Defaults to \*(L"vim\*(R".
 .IP "\s-1SHELL\s0" 8
 .IX Item "SHELL"
 Defines the shell that ranger is going to use with the :shell command and
diff --git a/doc/ranger.pod b/doc/ranger.pod
index 43926f46..72386efc 100644
--- a/doc/ranger.pod
+++ b/doc/ranger.pod
@@ -423,7 +423,7 @@ Inspect the current file in a bigger window.
 
 =item E
 
-Edit the current file in $EDITOR ("nano" by default)
+Edit the current file in $VISUAL otherwise $EDITOR otherwise "vim"
 
 =item S
 
@@ -708,9 +708,10 @@ Changes case sensitivity for the "cd" command tab completion. Possible values ar
  insensitive
  smart
 
-=item cd_tab_smart [bool]
+=item cd_tab_fuzzy [bool]
 
-Use smart tab completion with less typing? E.g. ":cd /f/b/b<tab>" yields ":cd /foo/bar/baz".
+Use fuzzy tab completion with the "cd" command. For example,
+B<:cd /u/lo/b<TABE<gt>> expands to B<:cd /usr/local/bin>.
 
 =item clear_filters_on_dir_change [bool]
 
@@ -1566,9 +1567,15 @@ If this variable is set to FALSE, ranger will not load the default rc.conf.
 This can save time if you copied the whole rc.conf to ~/.config/ranger/ and
 don't need the default one at all.
 
+=item VISUAL
+
+Defines the editor to be used for the "E" key.  Falls back to EDITOR if
+undefined or empty.
+
 =item EDITOR
 
-Defines the editor to be used for the "E" key.  Defaults to "nano".
+Defines the editor to be used for the "E" key if VISUAL is undefined or empty.
+Defaults to "vim".
 
 =item SHELL
 
diff --git a/doc/rifle.1 b/doc/rifle.1
index 8531d69c..0441f37a 100644
--- a/doc/rifle.1
+++ b/doc/rifle.1
@@ -1,4 +1,4 @@
-.\" Automatically generated by Pod::Man 4.07 (Pod::Simple 3.32)
+.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35)
 .\"
 .\" Standard preamble:
 .\" ========================================================================
@@ -129,7 +129,7 @@
 .\" ========================================================================
 .\"
 .IX Title "RIFLE 1"
-.TH RIFLE 1 "rifle-1.9.0b6" "12/07/2017" "rifle manual"
+.TH RIFLE 1 "rifle-1.9.0b6" "2018-01-25" "rifle manual"
 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
 .\" way too many mistakes in technical documents.
 .if n .ad l
@@ -188,9 +188,14 @@ The syntax is described in the comments of the default \fIrifle.conf\fR that shi
 with ranger.  To obtain it, you need to run: \f(CW\*(C`ranger \-\-copy\-config=rifle\*(C'\fR
 .SH "ENVIRONMENT"
 .IX Header "ENVIRONMENT"
+.IP "\s-1VISUAL\s0" 8
+.IX Item "VISUAL"
+Determines which editor to use for editing files.
 .IP "\s-1EDITOR\s0" 8
 .IX Item "EDITOR"
-Determines which editor to use for editing files (in the default \fIrifle.conf\fR).
+Determines which editor to use for editing files if \s-1VISUAL\s0 is undefined or
+empty (in the default \fIrifle.conf\fR). If both are undefined or empty, \*(L"vim\*(R" is
+used instead.
 .IP "\s-1PAGER\s0" 8
 .IX Item "PAGER"
 Determines which pager to use for displaying files (in the default \fIrifle.conf\fR).
diff --git a/doc/rifle.pod b/doc/rifle.pod
index 7241f6b5..b4d76287 100644
--- a/doc/rifle.pod
+++ b/doc/rifle.pod
@@ -84,9 +84,15 @@ with ranger.  To obtain it, you need to run: C<ranger --copy-config=rifle>
 
 =over 8
 
+=item VISUAL
+
+Determines which editor to use for editing files.
+
 =item EDITOR
 
-Determines which editor to use for editing files (in the default F<rifle.conf>).
+Determines which editor to use for editing files if VISUAL is undefined or
+empty (in the default F<rifle.conf>). If both are undefined or empty, "vim" is
+used instead.
 
 =item PAGER
 
diff --git a/ranger/config/commands.py b/ranger/config/commands.py
index b61974ac..3d5340dd 100755
--- a/ranger/config/commands.py
+++ b/ranger/config/commands.py
@@ -200,7 +200,7 @@ class cd(Command):
 
         return [os.path.join(dest_dir, d) for d in dirnames if self._tab_match(dest_base, d)], ''
 
-    def _tab_smart_match(self, basepath, tokens):
+    def _tab_fuzzy_match(self, basepath, tokens):
         """ Find directories matching tokens recursively """
         if not tokens:
             tokens = ['']
@@ -221,7 +221,7 @@ class cd(Command):
 
         return None
 
-    def _tab_smart(self, dest, dest_abs):
+    def _tab_fuzzy(self, dest, dest_abs):
         tokens = []
         basepath = dest_abs
         while True:
@@ -234,7 +234,7 @@ class cd(Command):
                 break
             tokens.append(token)
 
-        paths = self._tab_smart_match(basepath, tokens)
+        paths = self._tab_fuzzy_match(basepath, tokens)
         if not os.path.isabs(dest):
             paths_rel = basepath
             paths = [os.path.relpath(path, paths_rel) for path in paths]
@@ -249,8 +249,8 @@ class cd(Command):
 
         paths, paths_rel = self._tab_paths(dest, dest_abs, ends_with_sep)
         if paths is None:
-            if self.fm.settings.cd_tab_smart:
-                paths, paths_rel = self._tab_smart(dest, dest_abs)
+            if self.fm.settings.cd_tab_fuzzy:
+                paths, paths_rel = self._tab_fuzzy(dest, dest_abs)
             else:
                 paths, paths_rel = self._tab_normal(dest, dest_abs)
 
@@ -939,7 +939,8 @@ class eval_(Command):
                 if result and not quiet:
                     p(result)
         except Exception as err:  # pylint: disable=broad-except
-            p(err)
+            fm.notify("The error `%s` was caused by evaluating the "
+                      "following code: `%s`" % (err, code), bad=True)
 
 
 class rename(Command):
diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf
index 6bb8f0d0..388e56e6 100644
--- a/ranger/config/rc.conf
+++ b/ranger/config/rc.conf
@@ -207,8 +207,9 @@ set cd_bookmarks true
 # Changes case sensitivity for the cd command tab completion
 set cd_tab_case sensitive
 
-# Use smart tab completion with less typing? E.g. ":cd /f/b/b<tab>" yields ":cd /foo/bar/baz".
-set cd_tab_smart false
+# Use fuzzy tab completion with the "cd" command. For example,
+# ":cd /u/lo/b<tab>" expands to ":cd /usr/local/bin".
+set cd_tab_fuzzy false
 
 # Avoid previewing files larger than this size, in bytes.  Use a value of 0 to
 # disable this feature.
diff --git a/ranger/config/rifle.conf b/ranger/config/rifle.conf
index 2c081479..564fff8d 100644
--- a/ranger/config/rifle.conf
+++ b/ranger/config/rifle.conf
@@ -85,9 +85,9 @@ ext x?html?, has w3m,               terminal = w3m "$@"
 # Misc
 #-------------------------------------------
 # Define the "editor" for text files as first action
-mime ^text,  label editor = $EDITOR -- "$@"
+mime ^text,  label editor = ${VISUAL:-$EDITOR} -- "$@"
 mime ^text,  label pager  = "$PAGER" -- "$@"
-!mime ^text, label editor, ext xml|json|csv|tex|py|pl|rb|js|sh|php = $EDITOR -- "$@"
+!mime ^text, label editor, ext xml|json|csv|tex|py|pl|rb|js|sh|php = ${VISUAL:-$EDITOR} -- "$@"
 !mime ^text, label pager,  ext xml|json|csv|tex|py|pl|rb|js|sh|php = "$PAGER" -- "$@"
 
 ext 1                         = man "$1"
@@ -218,7 +218,7 @@ label wallpaper, number 14, mime ^image, has feh, X = feh --bg-fill "$1"
 
 # Define the editor for non-text files + pager as last action
               !mime ^text, !ext xml|json|csv|tex|py|pl|rb|js|sh|php  = ask
-label editor, !mime ^text, !ext xml|json|csv|tex|py|pl|rb|js|sh|php  = $EDITOR -- "$@"
+label editor, !mime ^text, !ext xml|json|csv|tex|py|pl|rb|js|sh|php  = ${VISUAL:-$EDITOR} -- "$@"
 label pager,  !mime ^text, !ext xml|json|csv|tex|py|pl|rb|js|sh|php  = "$PAGER" -- "$@"
 
 # The very last action, so that it's never triggered accidentally, is to execute a program:
diff --git a/ranger/container/settings.py b/ranger/container/settings.py
index 2f38a2b6..d0b094d0 100644
--- a/ranger/container/settings.py
+++ b/ranger/container/settings.py
@@ -29,7 +29,7 @@ ALLOWED_SETTINGS = {
     'autoupdate_cumulative_size': bool,
     'cd_bookmarks': bool,
     'cd_tab_case': str,
-    'cd_tab_smart': bool,
+    'cd_tab_fuzzy': bool,
     'clear_filters_on_dir_change': bool,
     'collapse_preview': bool,
     'colorscheme': str,
diff --git a/ranger/ext/rifle.py b/ranger/ext/rifle.py
index a6c0b9f0..c664423a 100755
--- a/ranger/ext/rifle.py
+++ b/ranger/ext/rifle.py
@@ -343,7 +343,9 @@ class Rifle(object):  # pylint: disable=too-many-instance-attributes
         else:
             if 'PAGER' not in os.environ:
                 os.environ['PAGER'] = DEFAULT_PAGER
-            if 'EDITOR' not in os.environ:
+            if 'VISUAL' not in os.environ and 'EDITOR' not in os.environ:
+                os.environ['VISUAL'] = DEFAULT_EDITOR
+                # necessary for compatibility with old rifle.conf
                 os.environ['EDITOR'] = DEFAULT_EDITOR
             command = self.hook_command_postprocessing(command)
             self.hook_before_executing(command, self._mimetype, self._app_flags)
diff --git a/ranger/gui/widgets/view_miller.py b/ranger/gui/widgets/view_miller.py
index 1f08e1af..e138ee4b 100644
--- a/ranger/gui/widgets/view_miller.py
+++ b/ranger/gui/widgets/view_miller.py
@@ -26,10 +26,6 @@ class ViewMiller(ViewBase):  # pylint: disable=too-many-ancestors,too-many-insta
         self.preview = True
         self.columns = []
 
-        self.pager = Pager(self.win, embedded=True)
-        self.pager.visible = False
-        self.add_child(self.pager)
-
         self.rebuild()
 
         for option in ('preview_directories', 'preview_files'):
@@ -48,6 +44,10 @@ class ViewMiller(ViewBase):  # pylint: disable=too-many-ancestors,too-many-insta
                 self.remove_child(child)
                 child.destroy()
 
+        self.pager = Pager(self.win, embedded=True)
+        self.pager.visible = False
+        self.add_child(self.pager)
+
         ratios = self.settings.column_ratios
 
         for column in self.columns:
diff --git a/tests/manpage_completion_test.py b/tests/manpage_completion_test.py
new file mode 100755
index 00000000..bfc8fa22
--- /dev/null
+++ b/tests/manpage_completion_test.py
@@ -0,0 +1,54 @@
+#!/usr/bin/python
+
+import os.path
+import re
+import sys
+
+
+# Add relevant ranger module to PATH... there surely is a better way to do this...
+sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
+
+
+def test(boolean, errormessage):
+    if not boolean:
+        sys.stderr.write('TEST FAILURE: ')
+        sys.stderr.write(errormessage)
+        sys.stderr.write('\n')
+        sys.stderr.flush()
+
+
+def get_path_of_man_page():
+    dirpath_of_this_file = os.path.dirname(__file__)
+    return os.path.join(dirpath_of_this_file, '..', 'doc', 'ranger.pod')
+
+
+def read_manpage():
+    path = get_path_of_man_page()
+    return open(path, 'r').read()
+
+
+def get_sections():
+    manpage = read_manpage()
+    parts = manpage.split('=head1 ')
+    sections = dict()
+    for part in parts:
+        if '\n' in part:
+            section_name, section_content = part.split('\n', 1)
+            sections[section_name] = section_content
+        else:
+            pass
+    return sections
+
+
+def check_if_settings_are_documented():
+    from ranger.container.settings import ALLOWED_SETTINGS
+    sections = get_sections()
+    setting_section = sections['SETTINGS']
+    matcher_pattern = r'^=item [\w\d_, ]*{setting}'
+    for setting in ALLOWED_SETTINGS:
+        matcher = re.compile(matcher_pattern.format(setting=setting), re.M)
+        test(matcher.search(setting_section), ('Setting %s is not documented in the man page!' % setting))
+
+
+if __name__ == '__main__':
+    check_if_settings_are_documented()