www.delorie.com/gnu/docs/emacs-lisp-intro/emacs-lisp-intro_43.html   search  
Buy the book!

Programming in Emacs Lisp

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2.4 Buffer Size and the Location of Point

Finally, let's look at several rather simple functions, buffer-size, point, point-min, and point-max. These give information about the size of a buffer and the location of point within it.

The function buffer-size tells you the size of the current buffer; that is, the function returns a count of the number of characters in the buffer.


You can evaluate this in the usual way, by positioning the cursor after the expression and typing C-x C-e.

In Emacs, the current position of the cursor is called point. The expression (point) returns a number that tells you where the cursor is located as a count of the number of characters from the beginning of the buffer up to point.

You can see the character count for point in this buffer by evaluating the following expression in the usual way:


As I write this, the value of point is 65724. The point function is frequently used in some of the examples later in this book.

The value of point depends, of course, on its location within the buffer. If you evaluate point in this spot, the number will be larger:


For me, the value of point in this location is 66043, which means that there are 319 characters (including spaces) between the two expressions.

The function point-min is somewhat similar to point, but it returns the value of the minimum permissible value of point in the current buffer. This is the number 1 unless narrowing is in effect. (Narrowing is a mechanism whereby you can restrict yourself, or a program, to operations on just a part of a buffer. See section Narrowing and Widening.) Likewise, the function point-max returns the value of the maximum permissible value of point in the current buffer.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003