On Do, 29 Aug 2019, Bram Moolenaar wrote:

> The <silent> argument means that the command won't be echoed.  But it
> does not suppress the output of the command like the ":silent" modifier
> does.

Yeah, but it felt natural to me, to only show the search index feature, 
if the command is echoed. I actually played with a simple patch 
yesterday, but then thought that <silent> works as expected.

> How about removing the check for cmd_silent in search.c, where
> search_stat() is called?

It's a bit more convoluted, since msgbuf needs to be properly allocated 
and initialized.

The attached patch does it. Let me know if you think that is okay. I can 
write a test then.

Mit freundlichen Grüßen
Christian
-- 
Fragt der Arzt:
"Rauchen Sie?"
"Nein."
"Trinken Sie?"
"Nein."
Darauf der Arzt:
"Grinsen Sie nicht so blöd, ich find schon noch was!"

-- 
-- 
You received this message from the "vim_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/20190830061958.GJ25942%40256bit.org.
From 6e56a15734d34a449235145265d5bff26466db93 Mon Sep 17 00:00:00 2001
From: Christian Brabandt <c...@256bit.org>
Date: Fri, 30 Aug 2019 08:17:07 +0200
Subject: [PATCH] Show the search_index feature also for silent mappings

---
 src/search.c | 106 ++++++++++++++++++++++++++-------------------------
 1 file changed, 55 insertions(+), 51 deletions(-)

diff --git a/src/search.c b/src/search.c
index 46273e11e..568b27ecc 100644
--- a/src/search.c
+++ b/src/search.c
@@ -1354,8 +1354,7 @@ do_search(
 	    pat = p;			    /* put pat after search command */
 	}
 
-	if ((options & SEARCH_ECHO) && messaging()
-					    && !cmd_silent && msg_silent == 0)
+	if ((options & SEARCH_ECHO) && messaging() && !msg_silent)
 	{
 	    char_u	*trunc;
 	    char_u	off_buf[40];
@@ -1409,62 +1408,67 @@ do_search(
 	    if (msgbuf != NULL)
 	    {
 		vim_memset(msgbuf, ' ', len);
-		msgbuf[0] = dirc;
 		msgbuf[len - 1] = NUL;
-
-		if (enc_utf8 && utf_iscomposing(utf_ptr2char(p)))
-		{
-		    // Use a space to draw the composing char on.
-		    msgbuf[1] = ' ';
-		    mch_memmove(msgbuf + 2, p, STRLEN(p));
-		}
-		else
-		    mch_memmove(msgbuf + 1, p, STRLEN(p));
-		if (off_len > 0)
-		    mch_memmove(msgbuf + STRLEN(p) + 1, off_buf, off_len);
-
-		trunc = msg_strtrunc(msgbuf, TRUE);
-		if (trunc != NULL)
+		// do not fill the msgbuf buffer, if cmd_silent is set, leave it
+		// empty for the search_stat feature.
+		if (!cmd_silent)
 		{
-		    vim_free(msgbuf);
-		    msgbuf = trunc;
-		}
+		    msgbuf[0] = dirc;
 
-#ifdef FEAT_RIGHTLEFT
-		// The search pattern could be shown on the right in rightleft
-		// mode, but the 'ruler' and 'showcmd' area use it too, thus
-		// it would be blanked out again very soon.  Show it on the
-		// left, but do reverse the text.
-		if (curwin->w_p_rl && *curwin->w_p_rlc == 's')
-		{
-		    char_u *r;
-		    size_t pat_len;
+		    if (enc_utf8 && utf_iscomposing(utf_ptr2char(p)))
+		    {
+			// Use a space to draw the composing char on.
+			msgbuf[1] = ' ';
+			mch_memmove(msgbuf + 2, p, STRLEN(p));
+		    }
+		    else
+			mch_memmove(msgbuf + 1, p, STRLEN(p));
+		    if (off_len > 0)
+			mch_memmove(msgbuf + STRLEN(p) + 1, off_buf, off_len);
 
-		    r = reverse_text(msgbuf);
-		    if (r != NULL)
+		    trunc = msg_strtrunc(msgbuf, TRUE);
+		    if (trunc != NULL)
 		    {
 			vim_free(msgbuf);
-			msgbuf = r;
-			// move reversed text to beginning of buffer
-			while (*r != NUL && *r == ' ')
-			    r++;
-			pat_len = msgbuf + STRLEN(msgbuf) - r;
-			mch_memmove(msgbuf, r, pat_len);
-			// overwrite old text
-			if ((size_t)(r - msgbuf) >= pat_len)
-			    vim_memset(r, ' ', pat_len);
-			else
-			    vim_memset(msgbuf + pat_len, ' ', r - msgbuf);
+			msgbuf = trunc;
 		    }
-		}
-#endif
-		msg_outtrans(msgbuf);
-		msg_clr_eos();
-		msg_check();
 
-		gotocmdline(FALSE);
-		out_flush();
-		msg_nowait = TRUE;	    // don't wait for this message
+    #ifdef FEAT_RIGHTLEFT
+		    // The search pattern could be shown on the right in rightleft
+		    // mode, but the 'ruler' and 'showcmd' area use it too, thus
+		    // it would be blanked out again very soon.  Show it on the
+		    // left, but do reverse the text.
+		    if (curwin->w_p_rl && *curwin->w_p_rlc == 's')
+		    {
+			char_u *r;
+			size_t pat_len;
+
+			r = reverse_text(msgbuf);
+			if (r != NULL)
+			{
+			    vim_free(msgbuf);
+			    msgbuf = r;
+			    // move reversed text to beginning of buffer
+			    while (*r != NUL && *r == ' ')
+				r++;
+			    pat_len = msgbuf + STRLEN(msgbuf) - r;
+			    mch_memmove(msgbuf, r, pat_len);
+			    // overwrite old text
+			    if ((size_t)(r - msgbuf) >= pat_len)
+				vim_memset(r, ' ', pat_len);
+			    else
+				vim_memset(msgbuf + pat_len, ' ', r - msgbuf);
+			}
+		    }
+    #endif
+		    msg_outtrans(msgbuf);
+		    msg_clr_eos();
+		    msg_check();
+
+		    gotocmdline(FALSE);
+		    out_flush();
+		    msg_nowait = TRUE;	    // don't wait for this message
+		}
 	    }
 	}
 
@@ -1572,7 +1576,7 @@ do_search(
 	// Show [1/15] if 'S' is not in 'shortmess'.
 	if ((options & SEARCH_ECHO)
 		&& messaging()
-		&& !(cmd_silent + msg_silent)
+		&& !msg_silent
 		&& c != FAIL
 		&& !shortmess(SHM_SEARCHCOUNT)
 		&& msgbuf != NULL)
-- 
2.20.1

Reply via email to