All Manuals > LispWorks Editor User Guide > 4 Editing Lisp Programs

NextPrevUpTopContentsIndex

4.9 Evaluation and compilation

The commands described below allow the user to evaluate (interpret) or compile Lisp code that exists as text in a buffer. In some cases, the code may be used to modify the performance of the Editor itself.

4.9.1 General Commands

current-package

Editor Variable

Default value: nil

If non-nil, defines the value of the current package.

Set Buffer Package

Editor Command

Argument: package
Key sequence: None

Set the package to be used by Lisp evaluation and compilation while in this buffer. Not to be used in the Listener, which uses the value of *package* instead.

Set Buffer Output

Editor Command

Argument: stream
Key sequence: None

Sets the output stream that evaluation results in the current buffer are sent to.

4.9.2 Evaluation commands

Evaluate Defun

Editor Command

Argument: None
Key sequence: Alt+Ctrl+X

Evaluates the current top-level form. If the current point is between two forms, the previous form is evaluated.

If the form is a defvar form, then the command may first make the variable unbound, according to the value of evaluate-defvar-action, and hence assign the new value. This is useful because cl:defvar does not reassign the value of a bound variable but when editing a program it is likely that you do want the new value.

evaluate-defvar-action

Editor Variable

Default value: :reevaluate-and-warn

This affects the behavior of Evaluate Defun and Compile Defun when they are invoked on a defvar form. The allowed values are:

:evaluate-and-warn

Do not make the variable unbound before evaluating the form, and warn that it was not redefined.

:evaluate

Do not make the variable unbound before evaluating the form, but do not warn that it was not redefined.

:reevaluate-and-warn

Make the variable unbound before evaluating the form, and warn that it was therefore redefined.

:reevaluate

Make the variable unbound before evaluating the form, but do not warn that it was therefore redefined.

Reevaluate Defvar

Editor Command

Argument: None
Key sequence: None

Evaluates the current top-level form if it is a defvar. If the current point is between two forms, the previous form is evaluated. The form is treated as if the variable is not bound.

Re-evaluate Defvar is a synonym for Reevaluate Defvar.

Evaluate Expression

Editor Command

Argument: expression
Key sequence: Esc Esc expression
Key sequence: Alt+Esc expression

Evaluates expression. The expression to be evaluated is typed into the Echo Area and the result of the evaluation is displayed there also.

Evaluate Last Form

Editor Command

Argument: None
Key sequence: Ctrl+X Ctrl+E

Evaluates the Lisp form preceding the current point.

Without a prefix argument, prints the result in the Echo Area. With a non-nil prefix argument, inserts the result into the current buffer.

Evaluate Region

Editor Command

Argument: None
Key sequence: Ctrl+Shift+E

Evaluates the Lisp forms in the region between the current point and the mark.

Evaluate Buffer

Editor Command

Argument: None
Key sequence: None

Evaluates the Lisp forms in the current buffer.

Load File

Editor Command

Argument: file
Key sequence: None

Loads file into the current eval server, so that all Lisp forms in the file are evaluated.

Toggle Error Catch

Editor Command

Argument: None
Key sequence: None

Toggles error catching for expressions evaluated in the editor. By default, if there is an error in an expression evaluated in the editor, a Notifier window is opened which provides the user with a number of options, including debug, re-evaluation and aborting of the editor command. However, this behavior can be changed by using Toggle Error Catch, so that in the event of an error, the error message is printed in the Echo Area, and the user is given no restart or debug options.

Evaluate Buffer Changed Definitions

Editor Command

Argument: None
Key sequence: None

Evaluates definitions that have been changed in the current buffer during the current LispWorks session (use Buffer Changed Definitions on Buffer Changed Definitions to see which definitions have changed). A prefix argument equal to the value of prefix-argument-default causes evaluation of definitions changed since last evaluated. A prefix argument of 1 causes evaluation of definitions changed since last saved.

Evaluate Changed Definitions

Editor Command

Argument: None
Key sequence: None

Evaluates definitions in all Lisp buffers that have been changed during the current LispWorks session. The effect of prefixes is the same as for Evaluate Buffer Changed Definitions.

Evaluate System Changed Definitions

Editor Command

Argument: system
Key sequence: None

Evaluates definitions that have been changed in system during the current LispWorks session.

4.9.3 Evaluation in Listener commands

Evaluate Defun In Listener

Editor Command

Argument: editp
Key sequence: None

This command works rather like Evaluate Defun in that it evaluates the current top-level form and handles defvar forms usefully. However, instead of doing the evaluation in the Editor window, it copies the form into a Listener window as if you had entered it there.

Normally the evaluation is done immediately, but if a prefix argument is given, the text is inserted into the Listener for you to edit before pressing Return to evaluate it.

An in-package form is inserted before the form when necessary, so this will change the current package in the Listener.

Evaluate Last Form In Listener

Editor Command

Argument: editp
Key sequence: None

This command works rather like Evaluate Last Form in that it evaluates the Lisp form preceding the current point. However, instead of doing the evaluation in the Editor window, it copies the form into a Listener window as if you had entered it there.

Normally the evaluation is done immediately, but if a prefix argument is given, the text is inserted into the Listener for you to edit before pressing Return to evaluate it.

An in-package form is inserted before the form when necessary, so this will change the current package in the Listener.

Evaluate Region In Listener

Editor Command

Argument: editp
Key sequence: None

This command works rather like Evaluate Region in that it evaluates the Lisp forms in the current region. However, instead of doing the evaluation in the Editor window, it copies the forms into a Listener window as if you had entered them there.

Normally the evaluation is done immediately, but if a prefix argument is given, the forms are inserted into the Listener for you to edit before pressing Return to evaluate them.

An in-package form is inserted before the forms when necessary, so this will change the current package in the Listener.

4.9.4 Compilation commands

Compile Defun

Editor Command

Argument: None
Key sequence: Ctrl+Shift+C

Compiles the current top-level form. If the current point is between two forms, the previous form is evaluated.

If the form is a defvar form, then the command may first make the variable unbound, according to the value of evaluate-defvar-action, and hence assign the new value.This is useful because cl:defvar does not reassign the value of a bound variable but when editing a program it is likely that you do want the new value.

Compile Region

Editor Command

Argument: None
Key sequence: Ctrl+Shift+R

Compiles the Lisp forms in the region between the current point and the mark.

Compile File

Editor Command

Argument: file
Key sequence: None

Compiles file unconditionally, with cl:compile-file.

No checking is done on write dates for the source and binary files, to see if the file needs to be compiled. Also, no checking is done to see if there is a buffer for the file that should first be saved.

Compile Buffer

Editor Command

Argument: None
Key sequence: Ctrl+Shift+B

Reads, compiles and then executes in turn each of the Lisp forms in the current buffer.

Compile Buffer File

Editor Command

Argument: None
Key sequence: None

Compiles the source file in the current buffer as if by Compile File, but checks the buffer and file first.

If the buffer is modified it is saved (updating the source file) before compilation, although if compile-buffer-file-confirm is true the command prompts for confirmation before saving and compiling.

If its associated binary (fasl) file is older than the source file or does not exist or the prefix argument is supplied then the file is compiled, although if compile-buffer-file-confirm is t the command prompts for confirmation before compiling.

If the binary file is up to date, command prompts for confirmation before compiling, although this prompt can be avoided by supplying the prefix argument.

Compile and Load Buffer File

Editor Command

Arguments: None
Key sequence: None

The command Compile and Load Buffer File compiles the source file in the current buffer just like Compile Buffer File, with the same checks.

It then loads the compiled file. In the case that the binary file is up to date and the user declines to compile, the command first prompts for confirmation before loading the existing binary file.

Compile and Load File

Editor Command

Arguments: filename
Key sequence: None

The command Compile and Load File prompts for a filename, and then compiles and loads that file.

compile-buffer-file-confirm

Editor Variable

Default value: t

Determines whether Compile Buffer File should prompt for a compilation to proceed. If the value is true, the user is always prompted for confirmation.

Compile Buffer Changed Definitions

Editor Command

Argument: None
Key sequence: None

Compiles definitions that have been changed in the current buffer during the current LispWorks session (use Buffer Changed Definitions to see which definitions have changed). A prefix argument equal to the value of prefix-argument-default causes compilation of definitions changed since last compiled. A prefix argument of 1 causes compilation of definitions changed since last saved.

Compile Changed Definitions

Editor Command

Argument: None
Key sequence: None

Compiles definitions in all Lisp buffers that have been changed during the current LispWorks session. The effect of prefixes is the same as for Compile Buffer Changed Definitions.

Compile System

Editor Command

Argument: system
Key sequence: None

Compiles all files in the system system.

If ASDF is loaded and the LispWorks tools are configured to use it, then this command works with ASDF systems as well as those defined by lispworks:defsystem.

Compile System Changed Definitions

Editor Command

Argument: system
Key sequence: None

Compiles definitions that have been changed in system during the current LispWorks session.

Disassemble Definition

Editor Command

Argument: definition
Key sequence: None

Outputs assembly code for definition to the Output window, compiling it first if necessary. The name of the current top-level definition is offered as a default value for definition .

Edit Recognized Source

Editor Command

Argument: None
Key sequence: Ctrl+X ,

Edit the source of the next compiler message, warning or error. It should be used while viewing the Output window. Without a prefix argument, it searches forwards in the Output window until it finds text which it recognizes as a compiler message, warning or error, and then shows the source code associated with that message. With a prefix argument, it searches backwards.


LispWorks Editor User Guide (Windows version) - 9 Dec 2014

NextPrevUpTopContentsIndex