omc-context.lsp

Manage function execution context. Automates the assignment and resetting of system variables, error catching and grouping calls to command for undoing between the enter and exit functions.

To use it, follow these steps:

  1. Define variables *error* and context as local to the function;
  2. Call omc-context-enter with an association list of system variables and their values desired during the execution of the function: (omc-context-enter '((var1 . value1) (var2 . value2) ... ))). Use (omc-context-enter nil) if you don’t need any.
  3. Continue the function code normally.
  4. Call omc-context-exit to reset the system variables to their previous values and ends the undo grouping. If it is the last call in a function, it is not necessary to call princ to exit quietly.

If you need to process errors somehow, define the *error* function after omc-context-enter, but keep in mind the procedures in omc-context-error to avoid inconsistencies with the context management functions.

Functions

(omc-context-enter options)

Enter function execution context: set system variables, start undo group and define error catcher.

(omc-context-exit)

Exit function execution context: reset variables to previous values and end undo group.

(omc-context-error msg)

Catch errors and exit function execution context: reset system variables to previous values and end undo group.

Global variables

  • *error* assigned in

    • omc-context-enter
  • *omc-context-undo-stack-size* assigned in

    • Top level
    • omc-context-enter
    • omc-context-error
    • omc-context-exit
  • context assigned in

    • omc-context-enter

Functions called on load

  • princ