Go to the first, previous, next, last section, table of contents.

The Definition of mark-whole-buffer

The mark-whole-buffer function is no harder to understand than the simplified-beginning-of-buffer function. In this case, however, we will look at the complete function, not a shortened version.

The mark-whole-buffer function is not as commonly used as the beginning-of-buffer function, but is useful nonetheless: it marks a whole buffer as a region by putting point at the beginning and a mark at the end of the buffer. It is generally bound to C-x h.

The code for the complete function looks like this:

(defun mark-whole-buffer ()
  "Put point at beginning and mark at end of buffer."
  (push-mark (point))
  (push-mark (point-max))
  (goto-char (point-min)))

Like all other functions, the mark-whole-buffer function fits into the template for a function definition. The template looks like this:

(defun name-of-function (argument-list)

Here is how the function works: the name of the function is mark-whole-buffer; it is followed by an empty argument list, `()', which means that the function does not require arguments. The documentation comes next.

The next line is an (interactive) expression that tells Emacs that the function will be used interactively. These details are similar to the simplified-beginning-of-buffer function described in the previous section.

Go to the first, previous, next, last section, table of contents.