# define-macro-file(2)

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

## NAME

define-macro-file - Define macro file location

## SYNOPSIS

define-macro-file "file-name" ["macro-name" "macro2-name" ...]

## DESCRIPTION

Macros are loaded as late as possible using an on-demand mechanism, this speeds up the load time of MicroEmacs 2009, it also keeps the startup file clean since macros are not defined within the start-up file. Only when the user first executes a macro defined via define-macro-file is the file loaded, the macro becomes defined and is executed. Subsequent calls to the macro will not reload the file as the macro will now be fully defined.

define-macro-file binds macros (macro-name ...) to a file name (file-name). This operation informs MicroEmacs 2009 which file should be loaded when macro-name is first executed. The macro-name arguments may be omitted if the file contains only one exported macro which has the same name as file-name.

Alternatively the macro file may contain many macros all of which can be defined by a single call to define-macro-file, listing all macros on the same line after the file-name. If a macro-name is given then the default macro file-name is not created, if a macro of that name does exist it must be added to the macro-name list.

## EXAMPLE

The following definitions are found in the `me.emf` start-up file:-

    0 define-macro-file utils ascii-time
    define-macro-file format clean sort-lines-ignore-case tabs-to-spaces ...
    define-macro-file cvs cvs cvs-state cvs-update cvs-commit cvs-log ...
    define-macro-file abbrev expand-abbrev-handle expand-iso-accents ...
    define-macro-file misc symbol check-line-length alarm time
    define-macro-file search replace-all-string query-replace-all-string
    define-macro-file tools compile grep rgrep which diff diff-changes
    define-macro-file hkdirlst file-browser file-browser-close
    define-macro-file comment comment-line uncomment-line comment-to-end-of-line
    define-macro-file spell spell-word spell-buffer spell-edit-word find-word
    define-macro-file games Metris Patience Triangle Mahjongg Match-It
    define-macro-file fattrib file-attrib
    define-macro-file osd osd-main
    define-macro-file gdiff
    define-macro-file calc
    define-macro-file draw

Hilighting a number of entries as examples; macro file calc is defined with no macro definition, the macro is assumed to be calc. The file tools.emf contains multiple macros compile, grep, diff and diff-changes; all can be defined by a single define-macro-file entry.

## NOTES

- Macro files are searched for in the current directory and along the $search-path(5).
- The macro file is not loaded unless a binding has been defined using define-macro-file.
- Any other macros that exist in the file-name macro file become defined when the entry point macro is loaded and are available for use. This is potentially useful as a single entry macro may be defined using define-macro-file, when invoked other helper macros become available.

## SEE ALSO

add-file-hook(2), define-macro(2), $search-path(5), start-up(3).

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

</HMTL>