Hut no longer actively manages contributions so people should use Github or the mailing list. Unfortunately we don't have a good setup for PGP-based communication about security issues with all maintainers.
3.1 KiB
Guidelines for Code Modification
Coding Style
- Use syntax compatible with Python
2.6+and3.1+. - Use docstrings with
pydocin mind - Follow the PEP8 style guide: https://www.python.org/dev/peps/pep-0008/
- Always run
make testbefore submitting a new PR.pylint,flake8,pytest,doctestandshellcheckneed to be installed. (If you don't change any shell scripts you can runmake test_pyand you don't need theshellcheckdependency but it's an awesome tool, so check it out : ) - When breaking backward compatibility with old configuration files or plugins,
please include a temporary workaround code that provides a compatibility
layer and mark it with a comment that includes the word
COMPAT. For examples, grep the code for the wordCOMPAT. :)
Patches
Send patches, created with git format-patch, to the email address
ranger-users@nongnu.org
or open a pull request on GitHub.
Please use PGP-encryption for security-relevant patches or messages. PGP key IDs are shared along with releases on https://ranger.github.io and can be attempted in reverse chronological order in case a maintainer is unresponsive.
Version Numbering
Three numbers, A.B.C, where
Achanges on a rewriteBchanges when major configuration incompatibilities occurCchanges with each release
Starting Points
Good places to read about ranger internals are:
ranger/core/actions.pyranger/container/fsobject.py
About the UI:
ranger/gui/widgets/browsercolumn.pyranger/gui/widgets/view_miller.pyranger/gui/ui.py
Common Changes
Adding options
- Add a default value in
rc.conf, along with a comment that describes the option. - Add the option to the
ALLOWED_SETTINGSdictionary in the fileranger/container/settings.pyin alphabetical order. - Add an entry in the man page by editing
doc/ranger.pod, then rebuild the man page by runningmake manin the ranger root directory
The setting is now accessible with self.settings.my_option, assuming self is a
subclass of ranger.core.shared.SettingsAware.
Adding colorschemes
-
Copy
ranger/colorschemes/default.pytoranger/colorschemes/myscheme.pyand modify it according to your needs. Alternatively, create a subclass ofranger.colorschemes.default.Defaultand override theusemethod, as it is done in theJunglecolorscheme. -
Add this line to your
~/.config/ranger/rc.conf:set colorscheme myscheme
Change which programs start which file types
Edit the configuration file ~/.config/ranger/rifle.conf. The default one can
be obtained by running ranger --copy-config rifle.
Change which file extensions have which mime type
Modify ranger/data/mime.types. You may also add your own entries to ~/.mime.types
Change which files are previewed in the auto preview
In ranger/container/file.py, change the constant PREVIEW_BLACKLIST