# fold-create(3)

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

## NAME

fold-create - Create a new fold (C-f2)
fold-close - Close an open fold (in-line) (C-f2)
fold-enter - Enter fold (f3)
fold-exit - Exit a fold (esc f3)
fold-exit-all - Exit all folds (esc C-f3)
fold-kill - Delete the fold and all its contents (C-x C-k)
fold-open - Open fold (in-line) (f2)
fold-remove - Remove the fold, maintaining content (esc C-f3)

## SYNOPSIS

fold-create (C-f2)
fold-close (C-f2)
fold-enter (f3)
fold-exit (esc f3)
fold-exit-all (esc C-f3)
fold-kill (C-x C-k)
fold-open (f2)
fold-remove (esc C-f3)

## INTRODUCTION

MicroEmacs supports folding editor type features that allow folds to be created, deleted and traversed. Folded regions of the file may be entered and edited whilst hiding information in other folds. Folds may also be opened in-line such that more than one fold is visible at any time.

The fold operation has different semantics than collapse which simply hides information with a single narrow and does not provide features such as entering the fold.

## DESCRIPTION

fold-create creates a new fold from the text defined between the cursor and the set-mark position. The text between the mark line and the cursor line inclusive are then folded and fold markers are inserted into the buffer. The folded line may be commented with a fold comment. The fold may be subsequently removed with fold-remove which removes the fold under the cursor, deleting any fold annotations.

fold-open opens the fold under the cursor, the fold is expanded in line such that the contents of the fold are visible. The fold may be subsequently closed using fold-close when the body of the text is hidden underneath a fold marker.

fold-enter enters a fold under the cursor and the contents of the fold are reveled the rest of the buffer is narrowed out. The previous fold level may be restored with fold-exit. Where the fold nesting is deep then fold-exit-all may be used to return to the top level.

fold-kill deletes the fold under the cursor and all of the information contained within the fold. undo(2) will restore the fold if this was not the required action.

## DEFINITION

Any file may be folded provided that the opening and closing fold strings are defined. Folding may be defined and initialized for a file type using buffer-init(3) by defining the fhopok-XXX.fold variable to define the opening and closing fold markers. i.e.

    set-variable .fhook-XXX.fold "<open> <close>"

Where <open> and <close> are the opening and closing fold strings.

Folding may also be introduced on a file basis by defining the sold markers in the magic string by assignment of the open and close fold strings through the variables fold-open: and fold-close:. The macro file `fold.emf` does this to fold a MicroEmacs macro file as follows:-

    ; -!- emf: fold-open: ";OPEN" ; fold-close: ";CLOSE" ; -!-

    ;OPEN fold-idle
    0 define-macro fold-idle
        !if &lfind "|yank|reyank|" @cl
            fold-region
            2 screen-update
        !endif
        !if &exi :fold-idle
            execute-line :fold-idle
        !endif
    !emacro
    ;CLOSE

## SEE ALSO

$line-flags(5), buffer-init(3), collapse-all(3), collapse-current(3), narrow(2m), narrow-buffer(2), set-mark(2).

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

</HMTL>