patch 9.1.0890: %! item not allowed for 'rulerformat'

Commit: 
https://github.com/vim/vim/commit/ac023e8baae65584537aa3c11494dad6f71770af
Author: Yegappan Lakshmanan <yegap...@yahoo.com>
Date:   Wed Nov 27 20:55:45 2024 +0100

    patch 9.1.0890: %! item not allowed for 'rulerformat'
    
    Problem:  %! item not allowed for 'rulerformat'
              (yatinlala)
    Solution: also allow to use %! for rulerformat option
              (Yegappan Lakshmanan)
    
    fixes: #16091
    closes: #16118
    
    Signed-off-by: Yegappan Lakshmanan <yegap...@yahoo.com>
    Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index 57d4af882..e9f35e4f3 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -1,4 +1,4 @@
-*options.txt*  For Vim version 9.1.  Last change: 2024 Nov 24
+*options.txt*  For Vim version 9.1.  Last change: 2024 Nov 27
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -7870,6 +7870,7 @@ A jump table for the options with a short description can 
be found at |Q_op|.
        All fields except the {item} are optional.  A single percent sign can
        be given as "%%".
 
+                                                       *stl-%!*
        When the option starts with "%!" then it is used as an expression,
        evaluated and the result is used as the option value.  Example: >
                :set statusline=%!MyStatusLine()
diff --git a/runtime/doc/tags b/runtime/doc/tags
index f33988020..68465cc09 100644
--- a/runtime/doc/tags
+++ b/runtime/doc/tags
@@ -10222,6 +10222,7 @@ state() builtin.txt     /*state()*
 static-tag     tagsrch.txt     /*static-tag*
 status-line    windows.txt     /*status-line*
 statusmsg-variable     eval.txt        /*statusmsg-variable*
+stl-%! options.txt     /*stl-%!*
 stl-%{ options.txt     /*stl-%{*
 str2float()    builtin.txt     /*str2float()*
 str2list()     builtin.txt     /*str2list()*
diff --git a/runtime/doc/version9.txt b/runtime/doc/version9.txt
index 10e13f846..04d1a92bd 100644
--- a/runtime/doc/version9.txt
+++ b/runtime/doc/version9.txt
@@ -1,4 +1,4 @@
-*version9.txt*  For Vim version 9.1.  Last change: 2024 Nov 14
+*version9.txt*  For Vim version 9.1.  Last change: 2024 Nov 27
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -41607,6 +41607,8 @@ Changed~
   started via |:Tutor|
 - improve the |vimtutor| and add a second chapter for more advanced tips
 - allow to pass local Vim script variables to python interpreter |py3eval()|
+- |getwininfo()| now also returns the "leftcol" property for a window
+- 'rulerformat' now supports the |stl-%!| item
 
                                                        *added-9.2*
 Added ~
diff --git a/src/optionstr.c b/src/optionstr.c
index 7c589e917..d7cb38a3a 100644
--- a/src/optionstr.c
+++ b/src/optionstr.c
@@ -3330,7 +3330,12 @@ parse_statustabline_rulerformat(optset_T *args, int 
rulerformat)
        if (wid && *s == '(' && (errmsg = check_stl_option(p_ruf)) == NULL)
            ru_wid = wid;
        else
-           errmsg = check_stl_option(p_ruf);
+       {
+           // Validate the flags in 'rulerformat' only if it doesn't point to
+           // a custom function ("%!" flag).
+           if ((*varp)[1] != '!')
+               errmsg = check_stl_option(p_ruf);
+       }
     }
     // check 'statusline' or 'tabline' only if it doesn't start with "%!"
     else if (rulerformat || s[0] != '%' || s[1] != '!')
diff --git a/src/testdir/dumps/Test_rulerformat_function.dump 
b/src/testdir/dumps/Test_rulerformat_function.dump
new file mode 100644
index 000000000..a93fd3203
--- /dev/null
+++ b/src/testdir/dumps/Test_rulerformat_function.dump
@@ -0,0 +1,2 @@
+> +0&#ffffff0@39
+@22|1|0|,|2|0| @8|3|0|%| 
diff --git a/src/testdir/test_cmdline.vim b/src/testdir/test_cmdline.vim
index 9aec012ed..2fbce74ce 100644
--- a/src/testdir/test_cmdline.vim
+++ b/src/testdir/test_cmdline.vim
@@ -3867,6 +3867,27 @@ func Test_rulerformat_position()
   call StopVimInTerminal(buf)
 endfunc
 
+" Test for using "%!" in 'rulerformat' to use a function
+func Test_rulerformat_function()
+  CheckScreendump
+
+  let lines =<< trim END
+    func TestRulerFn()
+      return '10,20%=30%%'
+    endfunc
+  END
+  call writefile(lines, 'Xrulerformat_function', 'D')
+
+  let buf = RunVimInTerminal('-S Xrulerformat_function', #{rows: 2, cols: 40})
+  call term_sendkeys(buf, ":set ruler rulerformat=%!TestRulerFn()\<CR>")
+  call term_sendkeys(buf, ":redraw!\<CR>")
+  call term_wait(buf)
+  call VerifyScreenDump(buf, 'Test_rulerformat_function', {})
+
+  " clean up
+  call StopVimInTerminal(buf)
+endfunc
+
 func Test_getcompletion_usercmd()
   command! -nargs=* -complete=command TestCompletion echo <q-args>
 
diff --git a/src/version.c b/src/version.c
index 2416ad19d..243e348e9 100644
--- a/src/version.c
+++ b/src/version.c
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    890,
 /**/
     889,
 /**/

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1tGORJ-009YRE-7U%40256bit.org.

Raspunde prin e-mail lui