Skip to content
hut edited this page Jun 20, 2016 · 4 revisions

Hooks

There are a few functions/methods in ranger’s code specifically designed to be overwritten, or “monkey patched” by the user:

  • ranger.api.hook_init
  • ranger.api.hook_ready
  • ranger.container.directory.accept_file

And there is ranger.api.register_linemode(), a function that enables the user to add custom linemodes.

See pydoc ranger.api and doc/examples/plugin_hello_world.py for more information.

Signals

There are certain objects which emit signals. You can bind your own functions to those signals with e.g. <object>.signal_bind("<signal>", <function>) and they will be run whenever that signal is emitted. See pydoc ranger.ext.signals for details.

This is a list of all signals. See also grep "signal_emit" -Inr ranger/*

object signal when
fm execute.before before a file is executed
fm execute.after after a file is executed
fm tab.change moving to a different tab
fm runner.execute.before before fm.run()
fm runner.execute.after after fm.run()
fm move when moving cursor to another file
fm cd when changing the directory
fm loader.before before adding a Loadable object
fm loader.after after finishing a Loadable object, possibly with errors, but without manually canceling it
fm loader.destroy after manually canceling a Loadable object (e.g. by typing `Ctrl+C` or `dd` in the task view (`W`))
fm.settings setopt when changing any option
fm.settings setopt.<settingname> when changing a specific option
CommandLoader before right after starting a command with CommandLoader
CommandLoader after after finishing a command with CommandLoader
CommandLoader pause on pausing a command execution
CommandLoader unpause on resuming a command execution
CommandLoader destroy on finishing or stopping a command execution