Function: buffer-size

buffer-size is a function defined in editfns.c.

Signature

(buffer-size &optional BUFFER)

Documentation

Return the number of characters in the current buffer.

If BUFFER is not nil, return the number of characters in that buffer instead.

This does not take narrowing into account; to count the number of characters in the accessible portion of the current buffer, use
(- (point-max) (point-min)), and to count the number of characters
in the accessible portion of some other BUFFER, use
(with-current-buffer BUFFER (- (point-max) (point-min))).

Other relevant functions are documented in the buffer group.

View in manual

Probably introduced at or before Emacs version 21.1.

Shortdoc

;; buffer
(buffer-size)
    => 94

Source Code

// Defined in /usr/src/emacs/src/editfns.c
{
  if (NILP (buffer))
    return make_fixnum (Z - BEG);
  else
    {
      CHECK_BUFFER (buffer);
      return make_fixnum (BUF_Z (XBUFFER (buffer))
			  - BUF_BEG (XBUFFER (buffer)));
    }
}