Git Product home page Git Product logo

fnmate's Introduction

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 two addins that do pretty much what their names suggest:

  • Create function definition file
  • 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.

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!

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.

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.

fnmate's People

Contributors

milesmcbain avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.