Next: , Previous: Further commands, Up: Top



5 Refactoring using Languide

Some more sophisticated commands, replacing long sequences of manual keyboard labour by the programmer, are provided by the companion package, Languide. As described here, they are accessed through some wrapper functions which apply them to the versor selection. You can also access these directly to act on GNUemacs region; See Overview (Languide: Language-guided editing).

A typical action (probably the one the author uses most often) is converting an expression to a local variable (so that the value can be re-used), involving the following steps:

  1. examine the expression for the variables it needs
  2. find the nearest scoping point, or (with a prefix arg) the widest scoping point at which all the variables needed are defined
  3. deduce the type of the expression (in statically typed languages only)
  4. insert a declaration for a variable (with the name supplied by the user) at the chosen scoping point, and initialize it using the original expression
  5. replace the original expression with a use of the new variable
  6. leave the new variable at the top of the kill ring, ready to be inserted somewhere else

Likewise, there is a function to turn a block of code into a function (working out automatically what needs to be passed in as the argument list), and replace its original occurrence with a call to the new function.

To draw attention to what they have done, these functions highlight, with an orange background, any changes they make away from the selection. The highlighting is not the Versor selection, and is removed on your next input to GNUemacs.

These commands are divided into two groups, one of them acting on expressions (as used in both functional and imperative languages) and one acting on statements, as used in imperative languages.

There are also facilities by which languide can tell you when it has spotted something it knows about.


SourceForge.net Logo