# $command-names(5)

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

## NAME

$command-names - Filtered command name list

## SYNOPSIS

$command-names CommandName

## DESCRIPTION

$command-names must first be initialized to the required filter string, if the variable is evaluated before it is initialized the value will be set to "ABORT" and the command will fail. The filter takes the form of a regex.

Once initialized, evaluating $command-names returns the name of the next command which matches the filter until no more commands are found, in which case an empty string is returned.

## EXAMPLE

The following example prints out the name of all commands to the massage line one at a time. Note that &set(4) is used on the !while(4) statement to avoid evaluating $command-names twice per loop.

    set-variable $command-names ".*"
    !while &not &seq &set #l0 $command-names ""
        100 ml-write &cat "command: " #l0
    !done

The following example is an alternative implementation of command-apropos(2).

    define-macro alt-commad-apropos
        set-variable #l1 @ml "Apropos string"
        set-variable $command-names &cat &cat ".*" #l1 ".*"
        !force 0 delete-buffer "*commands*"
        1 popup-window "*commands*"
        !while &not &seq &set #l0 $command-names ""
            insert-string &spr "    %s\n" #l0
        !done
        beginning-of-buffer
        -1 buffer-mode "edit"
        1 buffer-mode "view"
    !emacro

## NOTES

$command-names does not differentiate between built in commands and macros.

The list of commands is evaluated when the variable is initialized, macros created after the initialization will not be included in the list.

## SEE ALSO

list-commands(2), command-apropos(2), $buffer-names(5), $file-names(5), $mode-names(5), $variable-names(5), Regular Expressions.

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

</HMTL>