Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Menu-driven version of history-beginning-search-backward
- X-seq: zsh-workers 22560
- From: Peter Stephenson <pws@xxxxxxx>
- To: zsh-workers@xxxxxxxxxx (Zsh hackers list)
- Subject: Re: Menu-driven version of history-beginning-search-backward
- Date: Fri, 28 Jul 2006 11:08:31 +0100
- In-reply-to: <200607280910.k6S9AmW2018630@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <200607261638.k6QGcE7E010498@xxxxxxxxxxxxxx> <dc507f4a0607270901r5a4c19f2n20a895b8a831ab3@xxxxxxxxxxxxxx> <060727212432.ZM4920@xxxxxxxxxxxxxxxxxxxxxx> <200607280910.k6S9AmW2018630@xxxxxxxxxxxxxx>
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//(#m)[*?#<>]/\\$MATCH/}
search=${search// /*}
fi
@@ -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
fi
@@ -87,3 +98,5 @@
BUFFER=${matches[$chars]}
(( newcursor )) && CURSOR=$newcursor
fi
+
+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