From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26300 invoked from network); 3 Apr 2008 14:11:38 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.4 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 3 Apr 2008 14:11:38 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 40137 invoked from network); 3 Apr 2008 14:11:33 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 3 Apr 2008 14:11:33 -0000 Received: (qmail 21495 invoked by alias); 3 Apr 2008 14:11:30 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 24785 Received: (qmail 21479 invoked from network); 3 Apr 2008 14:11:29 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 3 Apr 2008 14:11:29 -0000 Received: from esacom89-int.esoc.esa.int (esacom89-ext.esoc.esa.int [131.176.86.4]) by bifrost.dotsrc.org (Postfix) with ESMTP id 1C2B682DC37A for ; Thu, 3 Apr 2008 16:11:21 +0200 (CEST) Received: from esacom53.esoc.esa.int (131-176-86-254.esoc.esa.int [131.176.86.254]) by esacom89-int.esoc.esa.int (8.13.3/8.13.3/ESA-External-v4.0) with ESMTP id m33EBJtU002554 for ; Thu, 3 Apr 2008 14:11:20 GMT Received: from dcle12.dev.esoc.esa.int (dcle12.dev.esoc.esa.int [131.176.58.71]) by esacom53.esoc.esa.int (8.12.10/8.12.10/ESA-Internal-v3.2) with ESMTP id m33EBDdO007068 for ; Thu, 3 Apr 2008 14:11:13 GMT Received: from dcle12.dev.esoc.esa.int (localhost [127.0.0.1]) by dcle12.dev.esoc.esa.int (8.13.8+Sun/8.13.8) with ESMTP id m33EBD8e000557 for ; Thu, 3 Apr 2008 14:11:13 GMT Received: from dcle12 (okiddle@localhost) by dcle12.dev.esoc.esa.int (8.13.8+Sun/8.13.8/Submit) with ESMTP id m33EBDMN000554 for ; Thu, 3 Apr 2008 16:11:13 +0200 (CEST) X-Authentication-Warning: dcle12.dev.esoc.esa.int: okiddle owned process doing -bs In-reply-to: <20080403123301.43f1f1f9@news01> From: Oliver Kiddle References: <8360.1207165155@pws-pc> <10127.1207218614@thecus> <20080403123301.43f1f1f9@news01> To: zsh-workers@sunsite.dk (Zsh hackers list) Subject: Re: PATCH: command line highlighting Date: Thu, 03 Apr 2008 16:11:13 +0200 Message-ID: <553.1207231873@dcle12> X-Virus-Scanned: ClamAV 0.91.2/6567/Thu Apr 3 14:31:07 2008 on bifrost X-Virus-Status: Clean Peter wrote: > zle_highlight is a global setting which can go in your .zshrc, so you can > set zle_highlight=(region:underline special:bold), or whatever. That's why Thanks. Sorry, I see now that that is documented. > > With a zle -M command at the end of this, zsh coredumps. Let me know if > > you can't reproduce it. I observed it on Solaris 10. > I couldn't easily get this to happen (that "/" probably isn't supposed to > be there). However, I have seen at least one crash involving widgets and > region_highlight here which comes from get_region_highlight() being > broken. I think I'll commit what I have: it is to be assumed that the > interface will continue to change. I've updated from cvs, rebuilt with debug enabled, removed the spurious "/" and tried again. This time it works. Thanks. By the way, the documented feature that accepting a line does not save region_highlight doesn't appear to work. For me, the variable and the highlights are persisting. > We need to be able to see if a key is read within the time and if it is > unget it and return (like sit-for in Emacs). Something like > read -kt 1 && zle -U $REPLY > should work, but I haven't played around with it yet. I had to add a call to "zle -R" so that it doesn't wait till the end of the widget to display the highlight but otherwise, that seems to work. An additional key typed in less than a second will remove the highlighting but that's actually fine. I've included the full function below in case anyone else wants to play with it: handle quoting or forward searching perhaps. > > And how can it be sure to remove its highlight > > and not a region from some other widget. > > region_highlight could be an associative array, I suppose. Yes, that would be another solution. Oliver local i nested=1 typeset -A match match=( \) \( \" \" \' \' \] \[ \} \{ ) zle self-insert for ((i=$(( $CURSOR - 1));i;i--)) { [[ $BUFFER[$i] = $match[$KEYS] ]] && (( ! --nested )) && break [[ $BUFFER[$i] == $KEYS ]] && (( nested++ )) } region_highlight=("$((i-1)) $i standout") zle -R read -kt 1 && zle -U "$REPLY" region_highlight=()