Function: buffer-substring

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

Signature

(buffer-substring START END)

Documentation

Return the contents of part of the current buffer as a string.

The two arguments START and END are character positions; they can be in either order. The string returned is multibyte if the buffer is multibyte.

This function copies the text properties of that part of the buffer into the result string; if you don't want the text properties, use buffer-substring-no-properties instead.

Other relevant functions are documented in the buffer group.

View in manual

Probably introduced at or before Emacs version 17.

Shortdoc

;; buffer
(buffer-substring (point-min) (+ (point-min) 10))
    => #("(buffer-su" 0 1 (face shortdoc-section shortdoc-function buffer-substring outline-level 2) 1 10 (help-echo "mouse-1, RET: show function's documentation in the Info manual" follow-link t action #[257 "\301\300\302\"\207" [buffer-substring info-lookup-symbol emacs-lisp-mode] 4 "\n\n(fn _)"] face (button shortdoc-section) category default-button button (t)))

Source Code

// Defined in /usr/src/emacs/src/editfns.c
{
  register ptrdiff_t b, e;

  validate_region (&start, &end);
  b = XFIXNUM (start);
  e = XFIXNUM (end);

  return make_buffer_string (b, e, 1);
}