From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10053 invoked by alias); 31 Dec 2010 20:22:16 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 28562 Received: (qmail 10707 invoked from network); 31 Dec 2010 20:22:14 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <101231122149.ZM8730@torch.brasslantern.com> Date: Fri, 31 Dec 2010 12:21:47 -0800 In-reply-to: Comments: In reply to Wayne Davison "Re: How to get syntax highlighting working??" (Dec 31, 10:28am) References: <997733.11083.qm@web65612.mail.ac4.yahoo.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: Zsh list Subject: Re: How to get syntax highlighting working?? MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Dec 31, 10:28am, Wayne Davison wrote: } } While playing with this syntax highlighting code, I've come to the } conclusion that it would be much nicer to have a hook where the zle code } asks for a changed line to be highlighted. I've been thinking for a couple of days now about some related ideas. I loaded the zsh-syntax-highlighting script from github but found it to be *agonizingly* slow when running zed (or on any other significant multi-line buffer), because it recomputes the colorization of the whole buffer in shell code on every keystroke -- including movement up or down in the buffer. Several changes could improve this; (1) don't re-highlight if the buffer hasn't changed [your edit to _zsh_highlight-zle-buffer]; (2) highlight incrementally based on $CURSOR rather than starting over with a fresh ${(z)BUFFER} on every change; and (3) get some help from the C code, which presently isn't available. This is exactly the reason that completion has so many helper builtins to figure out the context around the cursor position. Perhaps the code for completion could be repurposed for this; in fact perhaps a way to approach it without hacking new C code directly, is to restructure the colorize-zle-buffer function such that it becomes a completion widget (one which always succeeds without adding any matches), and then invoke that with "zle colorize-zle-buffer" instead of a direct call. } This avoids having to create functions for an ever-changing plethora } of zle functions, and makes things like push-line, yank, yank-pop, } delete-char-or-list, and who-knows-what-else Just Work (all of which } have issues when using override widgets). Aside: It appears the thread beginning users/15493 then workers/28369 never went anywhere (about making the zle hooks into arrays of function or widget names). } Here's a patch for zsh: } } http://opencoder.net/zle-set-highlight-hook.patch } } Thoughts? I really like this single hook point for highlighting. Yes, this makes good sense. --