🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.bug
Article #88102

[19.25.92] too tight buffer list display

#88102
From: Erik Naggum
Date: Wed, 03 Aug 1994 19:28
214 lines
8807 bytes
In GNU Emacs 19.25.92.1 (sparc-sun-sunos4shr) of Wed Aug  3 1994 on naggum.no

this applies to all emacs 19 and possibly even emacs 18.

the buffer list display is a bit tight.  the five columns for the size of
the buffer is often not enough, and the next Mode column gets pushed over
to the right.  the Mode name is also too long sometimes.  the buffer list
looks messy quite often for me because of this.  so in the course of trying
to find the optimal spacing, I decided to make it variable.  hope this can
be useful to others as well.  (the line numbers may be off, other changes
have been made, too, but not included here.)  not sure if the way I have
done this is the best.  improvements are encouraged, as always.

I now use (setq list-buffer-column-widths '(16 -6 16 0)).

this patch is released unencumbered.

best regards,
</Erik>

---------------------------------------------------------------------------
Wed Aug  3 12:03:38 1994  Erik Naggum  <erik@naggum.no>

	* buffer.c: add variable Vlist_buffer_column_widths
	(list_buffers_1): use it to separate columns
	(syms_of_buffer): default it to '(14 5 14 0)

*** src/buffer.c.~1~	Sat Jul  2 19:50:13 1994
--- src/buffer.c	Wed Aug  3 12:03:01 1994
***************
*** 123,128 ****
--- 123,131 ----
     If any of these functions returns nil, we don't kill it.  */
  Lisp_Object Vkill_buffer_query_functions;

+ /* List of widths of Buffer, Size, Mode, and File columns for list_buffers_1 */
+ Lisp_Object Vlist_buffer_column_widths;
+
  /* List of functions to call before changing an unmodified buffer.  */
  Lisp_Object Vfirst_change_hook;
  Lisp_Object Qfirst_change_hook;
***************
*** 1096,1121 ****
       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);
    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))
      {
--- 1099,1157 ----
       Lisp_Object files;
  {
    register Lisp_Object tail, tem, buf;
!   Lisp_Object width_buffer, width_size, width_mode, width_file, minspace;
!   int widB, widS, widM, widF, colB, colS, colM, colF;
    register struct buffer *old = current_buffer, *b;
    Lisp_Object desired_point;
    Lisp_Object other_file_symbol;

!   width_buffer = Fcar (Vlist_buffer_column_widths);
!   width_size = Fcar (Fcdr (Vlist_buffer_column_widths));
!   width_mode = Fcar (Fcdr (Fcdr (Vlist_buffer_column_widths)));
!   width_file = Fcar (Fcdr (Fcdr (Fcdr (Vlist_buffer_column_widths))));
!
!   CHECK_NUMBER (width_buffer, 0);
!   CHECK_NUMBER (width_size, 1);
!   CHECK_NUMBER (width_mode, 2);
!   CHECK_NUMBER (width_file, 3);
!
!   widB = XINT (width_buffer);
!   widS = XINT (width_size);
!   widM = XINT (width_mode);
!   widF = XINT (width_file);
!
!   colB = 4;
!   colS = colB + abs (widB) + 1;
!   colM = colS + abs (widS) + 1;
!   colF = colM + abs (widM) + 1;

    XFASTINT (minspace) = 1;

+   desired_point = Qnil;
+   other_file_symbol = intern ("list-buffers-directory");
+
    Fset_buffer (Vstandard_output);
    Fbuffer_disable_undo (Vstandard_output);
    current_buffer->read_only = Qnil;

!   write_string (" MR", -1);
!   Findent_to (make_number (widB < 0 ? colB - widB - 6 : colB), minspace);
!   write_string ("Buffer", -1);
!   Findent_to (make_number (widS < 0 ? colS - widS - 4 : colS), minspace);
!   write_string ("Size", -1);
!   Findent_to (make_number (widM < 0 ? colM - widM - 4 : colM), minspace);
!   write_string ("Mode", -1);
!   Findent_to (make_number (widF < 0 ? colF - widF - 4 : colF), minspace);
!   write_string ("File\n", -1);
!   write_string (" --", -1);
!   Findent_to (make_number (widB < 0 ? colB - widB - 6 : colB), minspace);
!   write_string ("------", -1);
!   Findent_to (make_number (widS < 0 ? colS - widS - 4 : colS), minspace);
!   write_string ("----", -1);
!   Findent_to (make_number (widM < 0 ? colM - widM - 4 : colM), minspace);
!   write_string ("----", -1);
!   Findent_to (make_number (widF < 0 ? colF - widF - 4 : colF), minspace);
!   write_string ("----\n", -1);

    for (tail = Vbuffer_alist; !NILP (tail); tail = Fcdr (tail))
      {
***************
*** 1133,1164 ****
        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);
      }
--- 1169,1198 ----
        write_string (b == old ? "." : " ", -1);
        /* Identify modified buffers */
        write_string (BUF_MODIFF (b) > b->save_modified ? "*" : " ", -1);
!       write_string (NILP (b->read_only) ? " " : "%", -1);
!       Findent_to (make_number (widB < 0 ? colB - widB - XFASTINT (Flength (b->name)) : colB), minspace);
        Fprinc (b->name, Qnil);
!       tem = format1 ("%d", BUF_Z (b) - BUF_BEG (b));
!       Findent_to (make_number (widS < 0 ? colS - widS - XFASTINT (Flength (tem)) : colS), minspace);
!       Fprinc (tem, Qnil);
!       Findent_to (make_number (widM < 0 ? colM - widM - XFASTINT (Flength (b->mode_name)) : colM), minspace);
        Fprinc (b->mode_name, Qnil);

        if (!NILP (b->filename))
! 	tem = b->filename;
        else
  	{
  	  /* No visited file; check local value of list-buffers-directory.  */
  	  set_buffer_internal (b);
  	  tem = Fboundp (other_file_symbol);
  	  if (!NILP (tem))
! 	    tem = Fsymbol_value (other_file_symbol);
! 	  Fset_buffer (Vstandard_output);
! 	}
!       if (STRINGP (tem))
! 	{
! 	  Findent_to (make_number (widF < 0 ? colF - widF - XFASTINT (Flength (tem)) : colF), minspace);
! 	  Fprinc (tem, Qnil);
  	}
        write_string ("\n", -1);
      }
***************
*** 2866,2871 ****
--- 2915,2931 ----
    DEFVAR_LISP ("kill-buffer-query-functions", &Vkill_buffer_query_functions,
      "List of functions called with no args to query before killing a buffer.");
    Vkill_buffer_query_functions = Qnil;
+
+   DEFVAR_LISP ("list-buffer-column-widths", &Vlist_buffer_column_widths,
+     "*List of four integers, the widths of the columns in the buffer list.\n\
+ The four are the Buffer, Size, Mode and File column widths, respectively.\n\
+ A positive value means a left-justified field of that many columns.\n\
+ A negative value means a right-justified field of minus that many columns.");
+   Vlist_buffer_column_widths =
+     Fcons (make_number (14),
+ 	   Fcons (make_number (5),
+ 		  Fcons (make_number (14),
+ 			 Fcons (make_number (0), Qnil))));

    defsubr (&Sbuffer_list);
    defsubr (&Sget_buffer);
Technical Details
Message-ID: <19940803.3948@naggum.no>
Path: arc1-ca.pugleaf.net!bga.com!news.sprintlink.net!redstone.interpath.net!ddsw1!news.kei.com!yeshua.marcam.com!zip.eecs.umich.edu!newsxfer.itd.umich.edu!europa.eng.gtefsd.com!howland.reston.ans.net!math.ohio-state.edu!magnus.acs.ohio-state.edu!cis.ohio-state.edu!naggum.no!erik

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fb2f1,1e770c74919e59c2,start
X-Google-Attributes: gidfb2f1,public
X-Google-ArrivalTime: 1994-08-04 01:40:11 PST
Path: arc1-ca.pugleaf.net!bga.com!news.sprintlink.net!redstone.interpath.net!ddsw1!news.kei.com!yeshua.marcam.com!zip.eecs.umich.edu!newsxfer.itd.umich.edu!europa.eng.gtefsd.com!howland.reston.ans.net!math.ohio-state.edu!magnus.acs.ohio-state.edu!cis.ohio-state.edu!naggum.no!erik
From: erik@naggum.no (Erik Naggum)
Newsgroups: gnu.emacs.bug
Subject: [19.25.92] too tight buffer list display
Date: 3 Aug 1994 15:28:39 -0400
Organization: Naggum Software; +47 2295 0313
Lines: 217
Sender: daemon@cis.ohio-state.edu
Approved: bug-gnu-emacs@prep.ai.mit.edu
Distribution: gnu
Message-ID: <19940803.3948@naggum.no>