GNU Info

Info Node: (elisp)Buffer Contents

(elisp)Buffer Contents


Next: Comparing Text Prev: Near Point Up: Text
Enter node , (file) or (file)node

Examining Buffer Contents
=========================

   This section describes two functions that allow a Lisp program to
convert any portion of the text in the buffer into a string.

 - Function: buffer-substring start end
     This function returns a string containing a copy of the text of the
     region defined by positions START and END in the current buffer.
     If the arguments are not positions in the accessible portion of
     the buffer, `buffer-substring' signals an `args-out-of-range'
     error.

     It is not necessary for START to be less than END; the arguments
     can be given in either order.  But most often the smaller argument
     is written first.

     If the text being copied has any text properties, these are copied
     into the string along with the characters they belong to.  Note:
     Text Properties.  However, overlays (Note: Overlays) in the
     buffer and their properties are ignored, not copied.

          ---------- Buffer: foo ----------
          This is the contents of buffer foo
          
          ---------- Buffer: foo ----------
          
          (buffer-substring 1 10)
          => "This is t"
          (buffer-substring (point-max) 10)
          => "he contents of buffer foo
          "

 - Function: buffer-substring-no-properties start end
     This is like `buffer-substring', except that it does not copy text
     properties, just the characters themselves.  Note: Text
     Properties.

 - Function: buffer-string
     This function returns the contents of the entire accessible
     portion of the current buffer as a string.  It is equivalent to

          (buffer-substring (point-min) (point-max))

          ---------- Buffer: foo ----------
          This is the contents of buffer foo
          
          ---------- Buffer: foo ----------
          
          (buffer-string)
               => "This is the contents of buffer foo
          "

 - Function: thing-at-point thing
     Return the THING around or next to point, as a string.

     The argument THING is a symbol which specifies a kind of syntactic
     entity.  Possibilities include `symbol', `list', `sexp', `defun',
     `filename', `url', `word', `sentence', `whitespace', `line',
     `page', and others.

          ---------- Buffer: foo ----------
          Gentlemen may cry ``Pea-!-ce! Peace!,''
          but there is no peace.
          ---------- Buffer: foo ----------
          
          (thing-at-point 'word)
               => "Peace"
          (thing-at-point 'line)
               => "Gentlemen may cry ``Peace! Peace!,''\n"
          (thing-at-point 'whitespace)
               => nil


automatically generated by info2www version 1.2.2.9