Go to the previous, next section.

Body of  mark-whole-buffer

The body of the  mark-whole-buffer function consists of three lines of code:

(push-mark (point))
(push-mark (point-max))
(goto-char (point-min))

The first of these lines is the expression,  (push-mark (point)) .

This line does exactly the same job as the first line of the body of the  simplified-beginning-of-buffer function, which is written  (push-mark) . In both cases, the Lisp interpreter sets a mark at the current position of the cursor.

I don't know why the expression in  mark-whole-buffer is written  (push-mark (point)) and the expression in  beginning-of-buffer is written  (push-mark) . Perhaps whoever wrote the code did not know that the argument for  push-mark is optional and that if  push-mark is not passed an argument, the function automatically sets mark at the location of point by default. Or perhaps the expression was written so as to parallel the structure of the next line. In any case, the line causes Emacs to determine the position of point and set a mark there.

The next line of  mark-whole-buffer is  (push-mark (point-max)) . This expression sets a mark at the point in the buffer that has the highest number. This will be the end of the buffer (or, if the buffer is narrowed, the end of the accessible portion of the buffer. See section Narrowing and Widening, for more about narrowing.) After this mark has been set, the previous mark, the one set at point, is no longer set, but Emacs remembers its position, just as all other recent marks are always remembered. This means that you can, if you wish, go back to that position by typing C-u C-SPC twice.

Finally, the last line of the function is  (goto-char (point-min))) . This is written exactly the same way as it is written in  beginning-of-buffer . The expression moves the cursor to the minimum point in the buffer, that is, to the beginning of the buffer (or to the beginning of the accessible portion of the buffer). As a result of this, point is placed at the beginning of the buffer and mark is set at the end of the buffer. The whole buffer is, therefore, the region.

Go to the previous, next section.