All Projects → MilesMcBain → fnmate

MilesMcBain / fnmate

Licence: other
A function definition generator.

Programming Languages

r
7636 projects

Projects that are alternatives of or similar to fnmate

flowmapblue.R
Flowmap.blue widget for R
Stars: ✭ 42 (-43.24%)
Mutual labels:  rstats
rLandsat
R Package to make Landsat8 data accessible
Stars: ✭ 95 (+28.38%)
Mutual labels:  rstats
styles
Custom themes for base plots
Stars: ✭ 32 (-56.76%)
Mutual labels:  rstats
destatiscleanr
Imports and cleans data from official German statistical offices to jump-start the data analysis
Stars: ✭ 47 (-36.49%)
Mutual labels:  rstats
r-ladies-ML-1
⭐ Files for my R-Ladies ML workshop - Supervised Learning 101 ⭐
Stars: ✭ 35 (-52.7%)
Mutual labels:  rstats
mobileCharts
Mobile friendly charts with a familiar syntax
Stars: ✭ 23 (-68.92%)
Mutual labels:  rstats
heddlr
Bring a functional programming mindset to R Markdown document generation
Stars: ✭ 14 (-81.08%)
Mutual labels:  rstats
individual
R Package for individual based epidemiological models
Stars: ✭ 20 (-72.97%)
Mutual labels:  rstats
corrgram
Correlograms
Stars: ✭ 13 (-82.43%)
Mutual labels:  rstats
simputation
Making imputation easy
Stars: ✭ 71 (-4.05%)
Mutual labels:  rstats
koryphe
A flexible library for writing functional operations in Java
Stars: ✭ 18 (-75.68%)
Mutual labels:  functions
scclusteval
Single Cell Cluster Evaluation
Stars: ✭ 57 (-22.97%)
Mutual labels:  rstats
CENTIPEDE.tutorial
🐛 How to use CENTIPEDE to determine if a transcription factor is bound.
Stars: ✭ 23 (-68.92%)
Mutual labels:  rstats
messaging
Conveniently issue messages, warnings, and errors
Stars: ✭ 12 (-83.78%)
Mutual labels:  functions
attckr
⚔️MITRE ATT&CK Machinations in R
Stars: ✭ 22 (-70.27%)
Mutual labels:  rstats
agent
Store sensitive data such as API tokens
Stars: ✭ 19 (-74.32%)
Mutual labels:  rstats
openwhisk-runtime-dotnet
Apache OpenWhisk Runtime .Net supports Apache OpenWhisk functions written in .Net languages
Stars: ✭ 23 (-68.92%)
Mutual labels:  functions
meetup-presentations buenosaires
R-Ladies Buenos Aires recursos
Stars: ✭ 23 (-68.92%)
Mutual labels:  rstats
pkgreviewr
R package to facilitate rOpenSci package reviews.
Stars: ✭ 35 (-52.7%)
Mutual labels:  rstats
casewhen
Create reusable dplyr::case_when() functions
Stars: ✭ 64 (-13.51%)
Mutual labels:  rstats

Travis build status AppVeyor build status

Your fnmate

Type a call to a function and have a definition for that function appear with a keystroke. Lay the planks with your fnmate but leave the hammering til after smoko.

fnmate

Installation

remotes::install_github("milesmcbain/fnmate")

Usage

RStudio

There are three addins that do pretty much what their names suggest:

  • Create function definition file
  • Create function definition on clipboard
  • Create function definition below
    • as in appended to the end of the current file. Roxygen is not added in this case.

You can bind these to key combinations of your choosing, see here.

The function to be generated is determined by the cursor position. The function call at the most nested scope that encloses the cursor is the one that fnmate will generate a definition for.

There's another helper addin:

  • Jump to function definition which gives you a project-wide function definition jump (repository-wide). This is convenient in RStudio and VSCode where jumping to definitions in newly created files that haven't been opened is either not possible (VSCode) or prone to failure (RStudio). This addin depends on some third party software. The default (and best) option looks for rg on the PATH for ultra-fast definition grepping - install from ripgrep repo.
    • Alternately configure the addin to use git grep (built into git) by setting the option fnmate_searcher = "git_grep"

Emacs (ESS)

There is some Emacs lisp you can use to create bindings to fnmate contained in the vignette Using fnmate with ESS. If you have better ideas about how to distribute ESS 'addins' please let me know!

VSCode

The RStudio addin is supported in VSCode via {rstudioapi} emulation (needs to be turned on with option).

With emulation turned on, configure a keybinding like:

    {
        "description": "create function defintion",
        "key": "ctrl+;",
        "command": "r.runCommand",
        "when": "editorTextFocus",
        "args": "fnmate::rs_fnmate()"
    },
    {
        "description": "jump to function defintion",
        "key": "ctrl+shift+;",
        "command": "r.runCommand",
        "when": "editorTextFocus",
        "args": "fnmate::rs_fn_defn_jump()"
    }

Options

There are some options that affect how fnmate works:

  • fnmate_window determines how many lines above and below the current cursor position fnmate will look for a function call that encloses the cursor. Defaults to 20 which probably covers three standard deviations of coding styles.
  • fnmate_folder is the name of the folder in the current working directory to place created definition files. Defaults to "R".
  • fnmate_placeholder is the placeholder value that gets put in the function body. Defaults to NULL, can be set to any text.
  • fmate_searcher is the grep tool to use for the function definition jumping helper. Valid options are "rg" (ripgrep), and "git_grep".
  • fnmate_quote_jump_regex can be set to TRUE if Jump to function definiton is not working due to an error in the command. This seems necessary on MacOS.

Why does this exist?

A lot of the time when I attack a problem I find it helps to cruise over the gnarly bits requiring fiddly code by just claiming a function exits that will magically resolve that fiddly bit for me. After I have a high level solution described, I go back and fill in the blanks. This tool helps me clearly mark out the blanks without breaking my flow on the higher level algorithm.

Recently when developing R workflow plans with drake I've found myself wanting a tool like this so that my sketch of the workflow plan can be built, even though some of the targets are just placeholders.

Also realising this idea in a robust way turned out to be way more challenging than I anticipated and necessitated coopting the R parser and its parseData output. So it became a learning exercise.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].