Next: , Previous: , Up: Buffers   [Contents][Index]


3.2 Buffer Functions

Hemlock Variable: Make Buffer Hook
Hemlock Variable: Default Modeline Fields
Function: make-buffer name &key :modes :modeline-fields :delete-hook

make-buffer creates and returns a buffer with the given name. If a buffer named name already exists, nil is returned. Modes is a list of modes which should be in effect in the buffer, major mode first, followed by any minor modes. If this is omitted then the buffer is created with the list of modes contained in Default Modes. Modeline-fields is a list of modeline-field objects (see section modelines) which may be nil. delete-hook is a list of delete hooks specific to this buffer, and delete-buffer invokes these along with Delete Buffer Hook.

Buffers created with make-buffer are entered into the list buffer-list, and their names are inserted into the string-table buffer-names. When a buffer is created the hook Make Buffer Hook is invoked with the new buffer.

Function: bufferp buffer

Returns t if buffer is a buffer object, otherwise nil.

Hemlock Variable: Buffer Name Hook
Function: buffer-name buffer

buffer-name returns the name, which is a string, of the given buffer. The corresponding setf method invokes Buffer Name Hook with buffer and the new name and then sets the buffer’s name. When the user supplies a name for which a buffer already exists, the setf method signals an error.

Function: buffer-region buffer

Returns the buffer’s region. This can be set with setf. Note, this returns the region that contains all the text in a buffer, not the current-region.

Hemlock Variable: Buffer Pathname Hook
Function: buffer-pathname buffer

buffer-pathname returns the pathname of the file associated with the given buffer, or nil if it has no associated file. This is the truename of the file as of the most recent time it was read or written. There is a setf form to change the pathname. When the pathname is changed the hook Buffer Pathname Hook is invoked with the buffer and new value.

Function: buffer-write-date buffer

Returns the write date for the file associated with the buffer in universal time format. When this the buffer-pathname is set, use setf to set this to the corresponding write date, or to nil if the date is unknown or there is no file.

Function: buffer-point buffer

Returns the mark which is the current location within buffer. To move the point, use move-mark or move-to-position rather than setting buffer-point with setf.

Function: buffer-mark buffer

This function returns the top of buffer’s mark stack. There always is at least one mark at the beginning of buffer’s region, and all marks returned are right-inserting.

Function: buffer-start-mark buffer
Function: buffer-end-mark buffer

These functions return the start and end marks of buffer’s region:

(buffer-start-mark buffer)  <==>
  (region-start (buffer-region buffer))
and
(buffer-end-mark buffer)  <==>
  (region-end (buffer-region buffer))
Hemlock Variable: Buffer Writable Hook
Function: buffer-writable buffer

This function returns t if you can modify the buffer, nil if you cannot. If a buffer is not writable, then any attempt to alter text in the buffer results in an error. There is a setf method to change this value.

The setf method invokes the functions in Buffer Writable Hook on the buffer and new value before storing the new value.

Hemlock Variable: Buffer Modified Hook
Function: buffer-modified buffer

buffer-modified returns t if the buffer has been modified, nil if it hasn’t. This attribute is set whenever a text-altering operation is performed on a buffer. There is a setf method to change this value.

The setf method invokes the functions in Buffer Modified Hook with the buffer whenever the value of the modified flag changes.

Macro: with-writable-buffer (buffer) &rest forms

This macro executes forms with buffer’s writable status set. After forms execute, this resets the buffer’s writable and modified status.

Function: buffer-signature buffer

This function returns an arbitrary number which reflects the buffer’s current signature. The result is eql to a previous result if and only if the buffer has not been modified between the calls.

Function: buffer-variables buffer

This function returns a string-table (page string-tables) containing the names of the buffer’s local variables. See chapter variables.

Function: buffer-modes buffer

This function returns the list of the names of the modes active in buffer. The major mode is first, followed by any minor modes. See chapter modes.

Function: buffer-windows buffer

This function returns the list of all the windows in which the buffer may be displayed. This list may include windows which are not currently visible. See page windows for a discussion of windows.

Function: buffer-delete-hook buffer

This function returns the list of buffer specific functions delete-buffer invokes when deleting a buffer. This is setf’able.

Hemlock Variable: Delete Buffer Hook
Function: delete-buffer buffer

delete-buffer removes buffer from buffer-list and its name from buffer-names. Before buffer is deleted, this invokes the functions on buffer returned by buffer-delete-hook and those found in Delete Buffer Hook. If buffer is the current-buffer, or if it is displayed in any windows, then this function signals an error.

Function: delete-buffer-if-possible buffer

This uses delete-buffer to delete buffer if at all possible. If buffer is the current-buffer, then this sets the current-buffer to the first distinct buffer in buffer-history. If buffer is displayed in any windows, then this makes each window display the same distinct buffer.


Next: Modelines, Previous: The Current Buffer, Up: Buffers   [Contents][Index]