[previous] [up] [next]     [contents] [index]
Next: Selecting a Mode for Up: Files Previous: Selecting a Filename

Opening a File and Selecting a Format Handler

The function mred:edit-file takes a filename and dispatches it to an appropriate format handler. A format handler takes a filename and opens a frame for the user to view or edit the file. If no handler is found for a particular format, then the file is opened as a text file (and an appropriate mode is installed in the editing buffer; see section [cross-reference] for more information on modes).

The function mred:open-file lets the user select a filename using mred:get-file, and then passes the name to mred:edit-file.

Both mred:open-file and mred:edit-file return a frame on success or #f otherwise. Both procedures take optional arguments for working with frame groups:

A new format handler is installed with

  (mred:insert-format-handler name ext handler) 
The name argument is a string that names the format handler; e.g. ``Text'' or ``Picture''. The ext argument specifies when the handler should be invoked. It can be either: The handler argument is a procedure that takes one argument: a filename. The return value is a frame opened to edit or display the file or #f if there was an error.

  (mred:find-format-handler filename) 
returns a format handler procedure for filename, or #f if no handler can be found.

  (mred:find-named-format-handler name) 
returns a format handler with the name name (a format name, not a filename) or #f if no format by that name exists.


[previous] [up] [next]     [contents] [index]
Next: Selecting a Mode for Up: Files Previous: Selecting a Filename

PLT