Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Menu-driven version of history-beginning-search-backward

Minor tweak with just interesting enough consequences to bother posting
about.  The menu displayed with "zle -R" doesn't get cleared; I think
that's because the code doesn't remember the list of things it's
displaying as it does in the completion code.  I've hacked it here to
clear the list by brute force.

This is related to another annoyance that the completion listing code is
tied to completion and then hooked into zle_refresh.c.  If it were a
properly separate module (it's already a different library, but the API
is a bit non-existent) we could use it for tasks like menu selection in
a case like this, outside the completion code.

This is a pipe dream.

Index: Functions/Zle/history-beginning-search-menu
RCS file: /cvsroot/zsh/zsh/Functions/Zle/history-beginning-search-menu,v
retrieving revision 1.1
diff -u -r1.1 history-beginning-search-menu
--- Functions/Zle/history-beginning-search-menu	28 Jul 2006 09:52:35 -0000	1.1
+++ Functions/Zle/history-beginning-search-menu	28 Jul 2006 10:01:53 -0000
@@ -41,6 +41,10 @@
 local search=$LBUFFER
 if [[ $WIDGET = *-space* ]]; then
+  # We need to quote metacharacters in the search string
+  # since they are otherwise active in the reverse subscript.
+  # We need to avoid quoting other characters since they aren't
+  # and just stay quoted, rather annoyingly.
   search=${search// /*}
@@ -68,7 +72,14 @@
 local chars
 read -k$width chars
+# Hmmm... this isn't great.  The only way of clearing the display
+# appears to be to overwrite it completely.  I think that's because
+# displaying strings in this way doesn't set the completion list
+# properly.
+display=(${display//?/ })
 if [[ $chars != [[:digit:]]## || $chars -eq 0 || $chars -gt $n ]]; then
+  zle -R '' $display
   return 1
@@ -87,3 +98,5 @@
   (( newcursor )) && CURSOR=$newcursor
+zle -R '' $display

Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070

To access the latest news from CSR copy this link into a web browser:  http://www.csr.com/email_sig.php

Messages sorted by: Reverse Date, Date, Thread, Author