-Lisp_Object
-list_buffers_1 (files)
- Lisp_Object files;
-{
- register Lisp_Object tail, tem, buf;
- Lisp_Object col1, col2, col3, minspace;
- register struct buffer *old = current_buffer, *b;
- Lisp_Object desired_point;
- Lisp_Object other_file_symbol;
-
- desired_point = Qnil;
- other_file_symbol = intern ("list-buffers-directory");
-
- XFASTINT (col1) = 19;
- XFASTINT (col2) = 25;
- XFASTINT (col3) = 40;
- XFASTINT (minspace) = 1;
-
- Fset_buffer (Vstandard_output);
-
- tail = intern ("Buffer-menu-mode");
- if (!EQ (tail, current_buffer->major_mode)
- && (tem = Ffboundp (tail), !NILP (tem)))
- call0 (tail);
- Fbuffer_disable_undo (Vstandard_output);
- current_buffer->read_only = Qnil;
-
- write_string ("\
- MR Buffer Size Mode File\n\
- -- ------ ---- ---- ----\n", -1);
-
- for (tail = Vbuffer_alist; !NILP (tail); tail = Fcdr (tail))
- {
- buf = Fcdr (Fcar (tail));
- b = XBUFFER (buf);
- /* Don't mention the minibuffers. */
- if (XSTRING (b->name)->data[0] == ' ')
- continue;
- /* Optionally don't mention buffers that lack files. */
- if (!NILP (files) && NILP (b->filename))
- continue;
- /* Identify the current buffer. */
- if (b == old)
- XFASTINT (desired_point) = point;
- write_string (b == old ? "." : " ", -1);
- /* Identify modified buffers */
- write_string (BUF_MODIFF (b) > b->save_modified ? "*" : " ", -1);
- write_string (NILP (b->read_only) ? " " : "% ", -1);
- Fprinc (b->name, Qnil);
- Findent_to (col1, make_number (2));
- XFASTINT (tem) = BUF_Z (b) - BUF_BEG (b);
- Fprin1 (tem, Qnil);
- Findent_to (col2, minspace);
- Fprinc (b->mode_name, Qnil);
- Findent_to (col3, minspace);
-
- if (!NILP (b->filename))
- Fprinc (b->filename, Qnil);
- else
- {
- /* No visited file; check local value of list-buffers-directory. */
- Lisp_Object tem;
- set_buffer_internal (b);
- tem = Fboundp (other_file_symbol);
- if (!NILP (tem))
- {
- tem = Fsymbol_value (other_file_symbol);
- Fset_buffer (Vstandard_output);
- if (XTYPE (tem) == Lisp_String)
- Fprinc (tem, Qnil);
- }
- else
- Fset_buffer (Vstandard_output);
- }
- write_string ("\n", -1);
- }
-
- current_buffer->read_only = Qt;
- set_buffer_internal (old);
- return desired_point;
-}
-
-DEFUN ("list-buffers", Flist_buffers, Slist_buffers, 0, 1, "P",
- "Display a list of names of existing buffers.\n\
-The list is displayed in a buffer named `*Buffer List*'.\n\
-Note that buffers with names starting with spaces are omitted.\n\
-Non-null optional arg FILES-ONLY means mention only file buffers.\n\
-\n\
-The M column contains a * for buffers that are modified.\n\
-The R column contains a % for buffers that are read-only.")
- (files)
- Lisp_Object files;
-{
- Lisp_Object desired_point;
-
- desired_point
- = internal_with_output_to_temp_buffer ("*Buffer List*",
- list_buffers_1, files);
-
- if (NUMBERP (desired_point))
- {
- int count = specpdl_ptr - specpdl;
- record_unwind_protect (Fset_buffer, Fcurrent_buffer ());
- Fset_buffer (build_string ("*Buffer List*"));
- SET_PT (XINT (desired_point));
- return unbind_to (count, Qnil);
- }
- return Qnil;
-}
-