This is excellent, thank you to everyone who contributed on this!

On Mon, 17 Jun 2019 at 20:48, Bram Moolenaar <[email protected]> wrote:
>
>
> Patch 8.1.1564
> Problem:    Sign column takes up space.  (Adam Stankiewicz)
> Solution:   Optionally put signs in the number column. (Yegappan Lakshmanan,
>             closes #4555, closes #4515)
> Files:      runtime/doc/options.txt, src/option.c, src/screen.c,
>             src/testdir/test_signs.vim
>
>
> *** ../vim-8.1.1563/runtime/doc/options.txt     2019-05-26 19:20:33.024744457 
> +0200
> --- runtime/doc/options.txt     2019-06-17 21:39:05.973354220 +0200
> ***************
> *** 6803,6808 ****
> --- 6803,6810 ----
>            "auto"       only when there is a sign to display
>            "no"         never
>            "yes"        always
> +          "number"     display signs in the 'number' column. If the number
> +                       column is not present, then behaves like 'auto'.
>
>
>                         *'smartcase'* *'scs'* *'nosmartcase'* *'noscs'*
> *** ../vim-8.1.1563/src/option.c        2019-06-16 16:41:36.460010888 +0200
> --- src/option.c        2019-06-17 21:40:51.489062014 +0200
> ***************
> *** 3231,3237 ****
>   static char *(p_cot_values[]) = {"menu", "menuone", "longest", "preview", 
> "noinsert", "noselect", NULL};
>   #endif
>   #ifdef FEAT_SIGNS
> ! static char *(p_scl_values[]) = {"yes", "no", "auto", NULL};
>   #endif
>   #if defined(MSWIN) && defined(FEAT_TERMINAL)
>   static char *(p_twt_values[]) = {"winpty", "conpty", "", NULL};
> --- 3231,3237 ----
>   static char *(p_cot_values[]) = {"menu", "menuone", "longest", "preview", 
> "noinsert", "noselect", NULL};
>   #endif
>   #ifdef FEAT_SIGNS
> ! static char *(p_scl_values[]) = {"yes", "no", "auto", "number", NULL};
>   #endif
>   #if defined(MSWIN) && defined(FEAT_TERMINAL)
>   static char *(p_twt_values[]) = {"winpty", "conpty", "", NULL};
> ***************
> *** 13556,13561 ****
> --- 13556,13567 ----
>        int
>   signcolumn_on(win_T *wp)
>   {
> +     // If 'signcolumn' is set to 'number', signs are displayed in the 
> 'number'
> +     // column (if present). Otherwise signs are to be displayed in the sign
> +     // column.
> +     if (*wp->w_p_scl == 'n' && *(wp->w_p_scl + 1) == 'u')
> +       return wp->w_buffer->b_signlist != NULL && !wp->w_p_nu && 
> !wp->w_p_rnu;
> +
>       if (*wp->w_p_scl == 'n')
>         return FALSE;
>       if (*wp->w_p_scl == 'y')
> *** ../vim-8.1.1563/src/screen.c        2019-06-16 19:05:08.714676794 +0200
> --- src/screen.c        2019-06-17 21:43:25.788589314 +0200
> ***************
> *** 3037,3042 ****
> --- 3037,3127 ----
>   }
>   #endif
>
> + #ifdef FEAT_SIGNS
> + /*
> +  * Get information needed to display the sign in line 'lnum' in window 'wp'.
> +  * If 'nrcol' is TRUE, the sign is going to be displayed in the number 
> column.
> +  * Otherwise the sign is going to be displayed in the sign column.
> +  */
> +     static void
> + get_sign_display_info(
> +       int             nrcol,
> +       win_T           *wp,
> +       linenr_T        lnum,
> +       int             wcr_attr,
> +       int             row,
> +       int             startrow,
> +       int             filler_lines,
> +       int             filler_todo,
> +       int             *c_extrap,
> +       int             *c_finalp,
> +       char_u          *extra,
> +       char_u          **pp_extra,
> +       int             *n_extrap,
> +       int             *char_attrp)
> + {
> +     int       text_sign;
> + # ifdef FEAT_SIGN_ICONS
> +     int       icon_sign;
> + # endif
> +
> +     // Draw two cells with the sign value or blank.
> +     *c_extrap = ' ';
> +     *c_finalp = NUL;
> +     if (nrcol)
> +       *n_extrap = number_width(wp) + 1;
> +     else
> +     {
> +       *char_attrp = hl_combine_attr(wcr_attr, HL_ATTR(HLF_SC));
> +       *n_extrap = 2;
> +     }
> +
> +     if (row == startrow
> + #ifdef FEAT_DIFF
> +           + filler_lines && filler_todo <= 0
> + #endif
> +        )
> +     {
> +       text_sign = buf_getsigntype(wp->w_buffer, lnum, SIGN_TEXT);
> + # ifdef FEAT_SIGN_ICONS
> +       icon_sign = buf_getsigntype(wp->w_buffer, lnum, SIGN_ICON);
> +       if (gui.in_use && icon_sign != 0)
> +       {
> +           // Use the image in this position.
> +           *c_extrap = SIGN_BYTE;
> +           *c_finalp = NUL;
> + #  ifdef FEAT_NETBEANS_INTG
> +           if (buf_signcount(wp->w_buffer, lnum) > 1)
> +           {
> +               *c_extrap = MULTISIGN_BYTE;
> +               *c_finalp = NUL;
> +           }
> + #  endif
> +           *char_attrp = icon_sign;
> +       }
> +       else
> + # endif
> +           if (text_sign != 0)
> +           {
> +               *pp_extra = sign_get_text(text_sign);
> +               if (*pp_extra != NULL)
> +               {
> +                   if (nrcol)
> +                   {
> +                       sprintf((char *)extra, "%-*s ", number_width(wp),
> +                                                               *pp_extra);
> +                       *pp_extra = extra;
> +                   }
> +                   *c_extrap = NUL;
> +                   *c_finalp = NUL;
> +                   *n_extrap = (int)STRLEN(*pp_extra);
> +               }
> +               *char_attrp = sign_get_attr(text_sign, FALSE);
> +           }
> +     }
> + }
> + #endif
> +
>   /*
>    * Display line "lnum" of window 'wp' on the screen.
>    * Start at row "startrow", stop when "endrow" is reached.
> ***************
> *** 3876,3933 ****
>                 /* Show the sign column when there are any signs in this
>                  * buffer or when using Netbeans. */
>                 if (signcolumn_on(wp))
> !               {
> !                   int text_sign;
> ! # ifdef FEAT_SIGN_ICONS
> !                   int icon_sign;
> ! # endif
> !
> !                   /* Draw two cells with the sign value or blank. */
> !                   c_extra = ' ';
> !                   c_final = NUL;
> !                   char_attr = hl_combine_attr(wcr_attr, HL_ATTR(HLF_SC));
> !                   n_extra = 2;
> !
> !                   if (row == startrow
> ! #ifdef FEAT_DIFF
> !                           + filler_lines && filler_todo <= 0
> ! #endif
> !                           )
> !                   {
> !                       text_sign = buf_getsigntype(wp->w_buffer, lnum,
> !                                                                  SIGN_TEXT);
> ! # ifdef FEAT_SIGN_ICONS
> !                       icon_sign = buf_getsigntype(wp->w_buffer, lnum,
> !                                                                  SIGN_ICON);
> !                       if (gui.in_use && icon_sign != 0)
> !                       {
> !                           /* Use the image in this position. */
> !                           c_extra = SIGN_BYTE;
> !                           c_final = NUL;
> ! #  ifdef FEAT_NETBEANS_INTG
> !                           if (buf_signcount(wp->w_buffer, lnum) > 1)
> !                           {
> !                               c_extra = MULTISIGN_BYTE;
> !                               c_final = NUL;
> !                           }
> ! #  endif
> !                           char_attr = icon_sign;
> !                       }
> !                       else
> ! # endif
> !                           if (text_sign != 0)
> !                       {
> !                           p_extra = sign_get_text(text_sign);
> !                           if (p_extra != NULL)
> !                           {
> !                               c_extra = NUL;
> !                               c_final = NUL;
> !                               n_extra = (int)STRLEN(p_extra);
> !                           }
> !                           char_attr = sign_get_attr(text_sign, FALSE);
> !                       }
> !                   }
> !               }
>             }
>   #endif
>
> --- 3961,3969 ----
>                 /* Show the sign column when there are any signs in this
>                  * buffer or when using Netbeans. */
>                 if (signcolumn_on(wp))
> !                   get_sign_display_info(FALSE, wp, lnum, wcr_attr, row,
> !                           startrow, filler_lines, filler_todo, &c_extra,
> !                           &c_final, extra, &p_extra, &n_extra, &char_attr);
>             }
>   #endif
>
> ***************
> *** 3943,3955 ****
>   #endif
>                             || vim_strchr(p_cpo, CPO_NUMCOL) == NULL))
>                 {
> !                   /* Draw the line number (empty space after wrapping). */
> !                   if (row == startrow
>   #ifdef FEAT_DIFF
>                             + filler_lines
>   #endif
>                             )
> !                   {
>                         long num;
>                         char *fmt = "%*ld ";
>
> --- 3979,4005 ----
>   #endif
>                             || vim_strchr(p_cpo, CPO_NUMCOL) == NULL))
>                 {
> ! #ifdef FEAT_SIGNS
> !                   // If 'signcolumn' is set to 'number' and a sign is 
> present
> !                   // in 'lnum', then display the sign instead of the line
> !                   // number.
> !                   if ((*wp->w_p_scl == 'n' && *(wp->w_p_scl + 1) == 'u')
> !                           && buf_findsign_id(wp->w_buffer, lnum,
> !                                                       (char_u *)"*") != 0)
> !                       get_sign_display_info(TRUE, wp, lnum, wcr_attr, row,
> !                               startrow, filler_lines, filler_todo, &c_extra,
> !                               &c_final, extra, &p_extra, &n_extra,
> !                               &char_attr);
> !                   else
> ! #endif
> !                   {
> !                     /* Draw the line number (empty space after wrapping). */
> !                     if (row == startrow
>   #ifdef FEAT_DIFF
>                             + filler_lines
>   #endif
>                             )
> !                     {
>                         long num;
>                         char *fmt = "%*ld ";
>
> ***************
> *** 3992,4014 ****
>                         p_extra = extra;
>                         c_extra = NUL;
>                         c_final = NUL;
> !                   }
> !                   else
> !                   {
>                         c_extra = ' ';
>                         c_final = NUL;
> !                   }
> !                   n_extra = number_width(wp) + 1;
> !                   char_attr = hl_combine_attr(wcr_attr, HL_ATTR(HLF_N));
>   #ifdef FEAT_SYN_HL
> !                   /* When 'cursorline' is set highlight the line number of
> !                    * the current line differently.
> !                    * TODO: Can we use CursorLine instead of CursorLineNr
> !                    * when CursorLineNr isn't set? */
> !                   if ((wp->w_p_cul || wp->w_p_rnu)
>                                                  && lnum == wp->w_cursor.lnum)
>                         char_attr = hl_combine_attr(wcr_attr, 
> HL_ATTR(HLF_CLN));
>   #endif
>                 }
>             }
>
> --- 4042,4065 ----
>                         p_extra = extra;
>                         c_extra = NUL;
>                         c_final = NUL;
> !                     }
> !                     else
> !                     {
>                         c_extra = ' ';
>                         c_final = NUL;
> !                     }
> !                     n_extra = number_width(wp) + 1;
> !                     char_attr = hl_combine_attr(wcr_attr, HL_ATTR(HLF_N));
>   #ifdef FEAT_SYN_HL
> !                     /* When 'cursorline' is set highlight the line number of
> !                      * the current line differently.
> !                      * TODO: Can we use CursorLine instead of CursorLineNr
> !                      * when CursorLineNr isn't set? */
> !                     if ((wp->w_p_cul || wp->w_p_rnu)
>                                                  && lnum == wp->w_cursor.lnum)
>                         char_attr = hl_combine_attr(wcr_attr, 
> HL_ATTR(HLF_CLN));
>   #endif
> +                   }
>                 }
>             }
>
> *** ../vim-8.1.1563/src/testdir/test_signs.vim  2019-06-16 13:55:13.888995469 
> +0200
> --- src/testdir/test_signs.vim  2019-06-17 21:21:05.425126639 +0200
> ***************
> *** 1736,1738 ****
> --- 1736,1795 ----
>     call StopVimInTerminal(buf)
>     call delete('XtestSigncolumn')
>   endfunc
> +
> + " Return the 'len' characters in screen starting from (row,col)
> + func s:ScreenLine(row, col, len)
> +   let s = ''
> +   for i in range(a:len)
> +     let s .= nr2char(screenchar(a:row, a:col + i))
> +   endfor
> +   return s
> + endfunc
> +
> + " Test for 'signcolumn' set to 'number'.
> + func Test_sign_numcol()
> +   new
> +   call append(0, "01234")
> +   " With 'signcolumn' set to 'number', make sure sign is displayed in the
> +   " number column and line number is not displayed.
> +   set numberwidth=2
> +   set number
> +   set signcolumn=number
> +   sign define sign1 text==>
> +   sign place 10 line=1 name=sign1
> +   redraw!
> +   call assert_equal("=> 01234", s:ScreenLine(1, 1, 8))
> +
> +   " With 'signcolumn' set to 'number', when there is no sign, make sure line
> +   " number is displayed in the number column
> +   sign unplace 10
> +   redraw!
> +   call assert_equal("1 01234", s:ScreenLine(1, 1, 7))
> +
> +   " Disable number column. Check whether sign is displayed in the sign 
> column
> +   set numberwidth=4
> +   set nonumber
> +   sign place 10 line=1 name=sign1
> +   redraw!
> +   call assert_equal("=>01234", s:ScreenLine(1, 1, 7))
> +
> +   " Enable number column. Check whether sign is displayed in the number 
> column
> +   set number
> +   redraw!
> +   call assert_equal("=>  01234", s:ScreenLine(1, 1, 9))
> +
> +   " Disable sign column. Make sure line number is displayed
> +   set signcolumn=no
> +   redraw!
> +   call assert_equal("  1 01234", s:ScreenLine(1, 1, 9))
> +
> +   " Enable auto sign column. Make sure both sign and line number are 
> displayed
> +   set signcolumn=auto
> +   redraw!
> +   call assert_equal("=>  1 01234", s:ScreenLine(1, 1, 11))
> +
> +   sign undefine sign1
> +   set signcolumn&
> +   set number&
> +   enew!  | close
> + endfunc
> *** ../vim-8.1.1563/src/version.c       2019-06-17 21:18:37.857807061 +0200
> --- src/version.c       2019-06-17 21:22:20.688781138 +0200
> ***************
> *** 779,780 ****
> --- 779,782 ----
>   {   /* Add new patch number below this line */
> + /**/
> +     1564,
>   /**/
>
> --
> Don't be humble ... you're not that great.
>                       -- Golda Meir
>
>  /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
> ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
> \\\  an exciting new programming language -- http://www.Zimbu.org        ///
>  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
>
> --
> --
> You received this message from the "vim_dev" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> ---
> You received this message because you are subscribed to the Google Groups 
> "vim_dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/vim_dev/201906171948.x5HJmjO5000796%40masaka.moolenaar.net.
> For more options, visit https://groups.google.com/d/optout.

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/CACoUkn5eWiFQG%2BxkUbUb2NcM2vjy6SAnev2a47SYwSsWq%3D-j4A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui