# CurrentBufferVariables(4)

[Home] [Commands] [Variables] [Macro-Dev] [Glossary]

## NAME

@wc, @wl - Extract characters from the current buffer

## SYNOPSIS

@wl
@wc

## DESCRIPTION

Buffer variables allow text to be taken from the current buffer and placed into a variable. Two types of extraction are provided @wl provides a line extraction method, @wc provides a character extraction method.

For example, if the current buffer contains the following text:

    Richmond
    Lafayette
    <*>Bloomington                (where <*> is the current point)
    Indianapolis
    Gary
    =* me (BE..) == rigel2 == (c:/data/rigel2.txt) ===================

The @wl variable allows text from the current buffer to be accessed, a command such as:-

    set-variable %line @wl

would start at the current point in the current buffer and grab all the text up to the end of that line and pass that back. Then it would advance the point to the beginning of the next line. Thus, after the set-variable command executes, the string "`Bloomington`" is placed in the variable %line and the buffer rigel2 now looks like this:

    Richmond
    Lafayette
    Bloomington
    <*>Indianapolis               (where <*> is the current point)
    Gary
    =* me (BE..) == rigel2 == (c:/data/rigel2.txt) ===================

The buffer command @wc gets the current character in the buffer, it does not change the buffer position. It is important to stress that the cursor position is not modified, in general a macro will interrogate the character under the cursor and then affect the buffer (i.e. by moving the cursor, deleting the character etc.) dependent upon the value of the character returned.

Assignment of the variables causes the buffer contents to be modified, deleting the pervious contents and setting the new value. This can be useful in certain situations but should be performed with care.

## EXAMPLE

The @wc variable provides the most useful mechanism to modify the current buffer. The following example is a macro called super-delete which is bound to `<CTRL-del>`. The macro deletes characters under the cursor in blocks. If a white space character is under the cursor then all characters up until the next non-white space character are deleted. If a non-white space character is under the cursor then all non-white space characters up until the next white space character are deleted, then the white space is deleted. White space in this context is a `SPACE`, `tab` or `CR` character.

    ;
    ;---    Macro to delete the white space, or if an a word all of the
    ;       word until the next word is reached.
    ;
    define-macro super-delete
        !while &not &sin @wc " \t\n"
            forward-delete-char
        !done
        !repeat
            forward-delete-char
        !until &or &seq @wc "" &not &sin @wc " \t\n"
        !return
    !emacro

    global-bind-key super-delete "C-delete"

## SEE ALSO

define-macro(2).

(c) Copyright JASSPA 2009
Last Modified: 2009/08/29
Generated On: 2009/10/12

</HMTL>