summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/api/commands.py20
1 files changed, 7 insertions, 13 deletions
diff --git a/ranger/api/commands.py b/ranger/api/commands.py
index 1997cde5..72af0ebd 100644
--- a/ranger/api/commands.py
+++ b/ranger/api/commands.py
@@ -17,10 +17,7 @@ from ranger.core.shared import FileManagerAware
 from ranger.ext.lazy_property import lazy_property
 
 _SETTINGS_RE = re.compile(r'^\s*([^\s]+?)=(.*)$')
-
-
-def _alias_line(full_command, line):
-    return full_command + ''.join(re.split(r'(\s+)', line)[1:])
+_ALIAS_LINE_RE = re.compile(r'(\s+)')
 
 
 class CommandContainer(FileManagerAware):
@@ -42,14 +39,11 @@ class CommandContainer(FileManagerAware):
         class CommandAlias(cmd):   # pylint: disable=too-few-public-methods
             def __init__(self, line, *args, **kwargs):
                 super(CommandAlias, self).__init__(
-                    _alias_line(self.full_command, line), *args, **kwargs)
-
-        cmd_alias = type(name, (CommandAlias, ), dict(full_command=full_command))
-        if issubclass(cmd_alias, FunctionCommand):
-            cmd_alias.based_function = name
-            cmd_alias.object_name = name
-            cmd_alias.function_name = name
-        self.commands[name] = cmd_alias
+                    self.full_command + ''.join(_ALIAS_LINE_RE.split(line)[1:]),
+                    *args,
+                    **kwargs,
+                )
+        self.commands[name] = type(name, (CommandAlias,), dict(full_command=full_command))
 
     def load_commands_from_module(self, module):
         for var in vars(module).values():
@@ -66,7 +60,7 @@ class CommandContainer(FileManagerAware):
                 continue
             attribute = getattr(obj, attribute_name)
             if hasattr(attribute, '__call__'):
-                cmd = type(attribute_name, (FunctionCommand, ), dict(__doc__=attribute.__doc__))
+                cmd = type(attribute_name, (FunctionCommand,), dict(__doc__=attribute.__doc__))
                 cmd.based_function = attribute
                 cmd.function_name = attribute.__name__
                 cmd.object_name = obj.__class__.__name__
kground-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 */
(selective-load "mu.arc" section-level)
(set allow-raw-addresses*)

(reset)
(new-trace "blocking-example")
(add-code
  '((function reader [
      (default-space:space-address <- new space:literal 30:literal/capacity)
      (x:tagged-value 1:channel-address/space:global <- read 1:channel-address/space:global)
     ])
    (function main [
      (default-space:space-address <- new space:literal 30:literal/capacity)
      (1:channel-address <- init-channel 3:literal)
      (2:integer/routine <- fork-helper reader:fn default-space:space-address/globals 50:literal/limit)
      ; write nothing to the channel
;?       (sleep until-routine-done:literal 2:integer/routine)
     ])))
;? (= dump-trace* (obj whitelist '("schedule" "run")))
(run 'main)
;? (prn "completed:")
;? (each r completed-routines*
;?   (prn " " r))
(when (ran-to-completion 'reader)
  (prn "F - reader waits for input"))

(reset)