about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lepus.uberspace.de>2014-12-05 17:24:26 +0100
committerhut <hut@lepus.uberspace.de>2014-12-05 17:29:56 +0100
commit3db19975a410c201032f7ca2da7db27746c32b48 (patch)
treedae3a8f22c966c0559c7ab55e9172339cf5e213c
parentc82a8a76989c87381a4e7a676f93ad4bf701c58b (diff)
downloadranger-3db19975a410c201032f7ca2da7db27746c32b48.tar.gz
update doc/examples/plugin_filter_file.py
The filter_by_filetype branch of Milan Svoboda changed the
interface to the accept_file function, so this example plugin broke.
-rw-r--r--doc/examples/plugin_file_filter.py18
1 files changed, 10 insertions, 8 deletions
diff --git a/doc/examples/plugin_file_filter.py b/doc/examples/plugin_file_filter.py
index bad5a368..b9bea1f3 100644
--- a/doc/examples/plugin_file_filter.py
+++ b/doc/examples/plugin_file_filter.py
@@ -1,18 +1,20 @@
-# Compatible with ranger 1.6.*
+# Compatible since ranger 1.6.1, git commit c82a8a76989c
 #
-# This plugin hides the directories "boot", "sbin", "proc" and "sys" in the
-# root directory.
+# This plugin hides the directories "/boot", "/sbin", "/proc" and "/sys" unless
+# the "show_hidden" option is activated.
 
 # Save the original filter function
 import ranger.container.directory
 old_accept_file = ranger.container.directory.accept_file
 
+HIDE_FILES = ("/boot", "/sbin", "/proc", "/sys")
+
 # Define a new one
-def custom_accept_file(fname, directory, hidden_filter, name_filter):
-       if hidden_filter and directory.path == '/' and fname in ('boot', 'sbin', 'proc', 'sys'):
-               return False
-       else:
-               return old_accept_file(fname, directory, hidden_filter, name_filter)
+def custom_accept_file(file, filters):
+    if not file.fm.settings.show_hidden and file.path in HIDE_FILES:
+        return False
+    else:
+        return old_accept_file(file, filters)
 
 # Overwrite the old function
 import ranger.container.directory
: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
discard """
  nimout: '''
t8314.nim(8, 7) Hint: BEGIN [User]
t8314.nim(19, 7) Hint: END [User]
  '''
"""

{.hint: "BEGIN".}
proc foo(x: range[1..10]) =
  block:
    var (y,) = (x,)
    echo y
  block:
    var (_,y) = (1,x)
    echo y
  block:
    var (y,_,) = (x,1,)
    echo y
{.hint: "END".}

foo(1)