GNU Info

Info Node: (emacs-lisp-intro.info)beginning-of-buffer complete

(emacs-lisp-intro.info)beginning-of-buffer complete


Prev: beginning-of-buffer opt arg Up: beginning-of-buffer
Enter node , (file) or (file)node

The Complete `beginning-of-buffer'
----------------------------------

   Here is the complete text of the `beginning-of-buffer' function:

     (defun beginning-of-buffer (&optional arg)
       "Move point to the beginning of the buffer;
     leave mark at previous position.
     With arg N, put point N/10 of the way
     from the true beginning.
     Don't use this in Lisp programs!
     \(goto-char (point-min)) is faster
     and does not set the mark."
       (interactive "P")
       (push-mark)
       (goto-char
        (if arg
            (if (> (buffer-size) 10000)
                ;; Avoid overflow for large buffer sizes!
                (* (prefix-numeric-value arg)
                   (/ (buffer-size) 10))
              (/ (+ 10 (* (buffer-size)
                          (prefix-numeric-value arg)))
                 10))
          (point-min)))
       (if arg (forward-line 1)))

Except for two small points, the previous discussion shows how this
function works.  The first point deals with a detail in the
documentation string, and the second point concerns the last line of
the function.

   In the documentation string, there is reference to an expression:

     \(goto-char (point-min))

A `\' is used before the first parenthesis of this expression.  This
`\' tells the Lisp interpreter that the expression should be printed as
shown in the documentation rather than evaluated as a symbolic
expression, which is what it looks like.

   Finally, the last line of the `beginning-of-buffer' command says to
move point to the beginning of the next line if the command is invoked
with an argument:

     (if arg (forward-line 1)))

This puts the cursor at the beginning of the first line after the
appropriate tenths position in the buffer.  This is a flourish that
means that the cursor is always located _at least_ the requested tenths
of the way through the buffer, which is a nicety that is, perhaps, not
necessary, but which, if it did not occur, would be sure to draw
complaints.


automatically generated by info2www version 1.2.2.9