# !force(4)

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

## NAME

!force - Ignore command or macro status

## SYNOPSIS

!force [n] command

## DESCRIPTION

!force ignores the return status of a command while executing a macro. When MicroEmacs 2009 executes a macro, if any command fails, the macro is terminated at that point. If a line is preceded by a !force directive, execution continues whether the command succeeds or not. $status(5) may be used following !force to determine if the command failed or not.

A double !force can be used to catch a user termination (via the abort-command(2) bound to `C-g`). A macro command aborted by the user will be terminated even with a single !force directive, but not with two. See the example below.

When specifying a numerical argument with a command, it is placed after the !force directive and before the command i.e.

    !force 1 forward-char

## EXAMPLE

The following example shows how !force is used in conjunction with $status.

    ;	Merge the top two windows

    push-position           ;remember where we are
    1 next-window           ;go to the top window
    delete-window           ;merge it with the second window
    !force pop-position     ;This will continue regardless
    !if $status
        ml-write "Call PASSED"
    !else
        ml-write "Call FAILED"
    !endif

The following example creates an infinite loop that can only be broken out of by a user abort. The calling macro catches this by using a double !force and continues. This concept is used by commands which take a considerable amount of time yet cannot be simply aborted by the user such as the spell-checker's best guess list generator.

    define-macro infinite-loop
        set-variable #l0 1
        !while 1
            ml-write &cat "In loop, C-g to exit: " &pinc #l0 1
        !done
    !emacro

    define-macro catch-abort
        !force !force infinite-loop
        ml-write "You will see this"
    !emacro

## SEE ALSO

$status(5).

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

</HMTL>