For Development HEAD DRAFTSearch (procedure/syntax/module):

Next: , Previous: , Up: Library modules - Utilities   [Contents][Index]

12.63 text.external-editor - Running external editor

Module: text.external-editor

A convenience module to invoke external editor program. This is mainly to be used from REPL, but can be useful for other purposes.

Function: ed path-or-proc :key editor load-after

{text.external-editor} Starts an external editor. The editor program path is determined in the following order:

Returns #t for normal termination.

The editor program may be called in one of the following way:

EDITOR filename
EDITOR +lineno filename

The latter expects to locate the cursor on the specified line number in the filename.

The file to open is determined by calling the generic function ed-pick-file on the argument path-or-proc. It should return (filename lineno), or #f to indicate that it couldn’t determine the file to edit. Methods for <string> and <procedure> are already defined; see the entry of ed-pick-file below.

The load-after argument controls whether the file is loaded into the process after the file is modified. It must be one of the following values:

#t

Load the file once editor exits and the file is modified.

#f

Do not load the file.

ask

Ask the user if the file should be loaded or not if the file is modified. (default)

NB: Common Lisp’s ed can be invoked without argument. For our usage, though, that feature doesn’t seem too useful—it’s more likely that repl IS inside an editor so we only need to open a specific file in a buffer. Emacsclient requires filename, so it further complicates things. For now we just require one argument.

Function: ed-string string :key editor

{text.external-editor} Invoke an external editor (as described in ed) on a temporary file whose content is string. Once editor exits, returns the edited content as a string.

Generic Function: ed-pick-file obj

{text.external-editor} Determine what to edit. It must return a list of filename and line number, or #f if it can’t find appropriate file to edit.

Methods for strings, procedures and <top> are already defined. If obj is a string, it is taken as a filename. If obj is a procedure and its source location is available, the source file and the location is returned. Otherwise, #f is returned.


Next: , Previous: , Up: Library modules - Utilities   [Contents][Index]


For Development HEAD DRAFTSearch (procedure/syntax/module):
DRAFT