Function: buffer-list

buffer-list is a function defined in buffer.c.

Signature

(buffer-list &optional FRAME)

Documentation

Return a list of all live buffers.

If the optional arg FRAME is a frame, return the buffer list in the proper order for that frame: the buffers shown in FRAME come first, followed by the rest of the buffers.

View in manual

Probably introduced at or before Emacs version 1.1.

Source Code

// Defined in /usr/src/emacs/src/buffer.c
{
  Lisp_Object general;
  general = Fmapcar (Qcdr, Vbuffer_alist);

  if (FRAMEP (frame))
    {
      Lisp_Object framelist, prevlist, tail;

      framelist = Fcopy_sequence (XFRAME (frame)->buffer_list);
      prevlist = Fnreverse (Fcopy_sequence
			    (XFRAME (frame)->buried_buffer_list));

      /* Remove from GENERAL any buffer that duplicates one in
         FRAMELIST or PREVLIST.  */
      tail = framelist;
      while (CONSP (tail))
	{
	  general = Fdelq (XCAR (tail), general);
	  tail = XCDR (tail);
	}
      tail = prevlist;
      while (CONSP (tail))
	{
	  general = Fdelq (XCAR (tail), general);
	  tail = XCDR (tail);
	}

      return CALLN (Fnconc, framelist, general, prevlist);
    }
  else
    return general;
}