Each buffer has a package associated with it, known as the primary package. If there is an in-package
form in a file when it is first read in, this is taken to specify the primary package; otherwise it is taken to be CL-USER
. If the primary package has not already been seen by the environment, you are prompted for its creation. The primary package is shown in the message line at the bottom of the editor window.
When evaluating parts of the current buffer (as opposed to all of it), the environment only uses the buffer's primary package if no in-package
form is found in the selected regions. It tries to find the current package within the section of code which is being evaluated. This is done so that any occurrences of in-package
in the buffer (other than on the first occurence) can be allowed for--if the current package was always assumed to be the primary package of the current buffer, many sections of code would evaluate wrongly.
This means that you do not have to worry about setting the package explicitly before evaluating part of a buffer.