Coder Social home page Coder Social logo

drracket-collapse-atomic's Introduction

drracket-collapse-atomic

This tool adds a keybinding to DrRacket that collapses the S-expression touching or containing the text cursor. The default keybinding is c:s:space (temporary), but it can be changed via the Collapse Atomic Keybinding option in the Edit menu. Invoking the keybinding on an expression that has been collapsed expands it again. S-expressions can be expanded with their child compound S-expressions collapsed by pressing c:s:% (also temporary) instead.

The placeholders for collapsed expressions are the same as those used in the more limited DrRacket collapsing functionality, so they can also be expanding using the existing right-click menu item, and S-expressions collapsed using the built-in functionality can be expanded using c:s:space or c:s:%. Several S-expressions can be collapsed individually at once by selecting them and pressing c:s:$ (also also temporary).

Unlike the functionality of the default Collapse S-expression item in the right-click menu of DrRacket, S-expressions collapsed using this tool can be atomic:

screenshot screenshot

Sequences of S-expressions can also be collapsed as one unit by selecting them and then invoking the tool:

screenshot screenshot

For compound S-expressions, the expression that will be collapsed by the tool is the same one indicated by DrRacket's default parenthesis highlighting:

screenshot screenshot

If the text cursor is touching two different S-expressions, the one collapsed will be the earlier one.

Installation

  • From the command line:

    $ raco pkg install https://github.com/adhameer/drracket-collapse-atomic.git
    
  • Within DrRacket: Select the Install Package... option under the File menu, then enter

    https://github.com/adhameer/drracket-collapse-atomic.git
    

    as the package source. You may need to restart DrRacket for the changes to take effect. You can confirm that the tool is installed by looking at Preferences > Tools:

    screenshot

Notes

Selections are expanded to contain entire S-expressions before collapsing as follows: the start position of the selection is moved over to the start of the S-expression touching/containing the start of the selection, and the end position of the selection is moved over to the end of the S-expression touching/containing the end of the selection. As a result, one can get strange results that straddle S-expressions if the start and end of one's selection are not located in sibling S-expressions.

The collapse/expand function is installed into DrRacket's keymap under the name "collapse atomic s-expression", and it can be remapped using that name; see Defining Custom Keybindings in DrRacket.

When using the built-in Collapse S-expression function, quotes, quasiquotes, and unquotes (using the shorthand ', `, and ,) are not collapsed when the contained expression is. They are collapsed with the contained expression when collapsed using this tool. A visually similar effect to the built-in behaviour can be achieved by selecting the elements of the quoted expression (as in the second example above) and collapsing them all as a unit.

drracket-collapse-atomic's People

Contributors

adhameer avatar

Stargazers

Turab Jafri avatar andrew blinn avatar Gary Baumgartner avatar Michael Guerzhoy avatar

Watchers

Gary Baumgartner avatar  avatar Michael Guerzhoy 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.