From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21268 invoked from network); 14 Aug 2004 07:41:18 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 14 Aug 2004 07:41:18 -0000 Received: (qmail 61034 invoked from network); 14 Aug 2004 07:41:11 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 14 Aug 2004 07:41:11 -0000 Received: (qmail 14580 invoked by alias); 14 Aug 2004 07:40:27 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7841 Received: (qmail 14570 invoked from network); 14 Aug 2004 07:40:27 -0000 Received: from unknown (HELO a.mx.sunsite.dk) (130.225.247.88) by 130.225.247.90 with SMTP; 14 Aug 2004 07:40:27 -0000 Received: (qmail 59308 invoked from network); 14 Aug 2004 07:39:38 -0000 Received: from unknown (HELO moonbase.zanshin.com) (167.160.213.139) by a.mx.sunsite.dk with SMTP; 14 Aug 2004 07:39:35 -0000 Received: from toltec.zanshin.com (toltec.zanshin.com [64.84.47.166]) by moonbase.zanshin.com (8.12.11/8.12.11) with ESMTP id i7E7dWZ2005123 for ; Sat, 14 Aug 2004 00:39:33 -0700 Date: Sat, 14 Aug 2004 00:39:32 -0700 (PDT) From: Bart Schaefer Reply-To: zsh-users@sunsite.dk To: Zsh-users List Subject: Re: insert-last-word makes space disappear In-Reply-To: <20040813082318.GN1191@localhost> Message-ID: References: <20040813082318.GN1191@localhost> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, hits=0.0 required=6.0 tests=none autolearn=no version=2.63 X-Spam-Hits: 0.0 On Fri, 13 Aug 2004, Jesper Holmberg wrote: > What happens is that the combination of menu-complete and > insert-last-word (bound to alt-.) sometimes makes a vital space > disappear on the command line. I suspect that you don't really have alt-. bound to insert-last-word, or more precisely that you have replaced the builtin insert-last-word widget with a user-defined widget such as smart-insert-last-word from the Functions/Zle directory. Automatic removal of spaces (auto-suffixes in general, really) is a tricky business. The rule (as nearly as it can be stated) is supposed to be that the suffix gets removed if the _next_ widget is any one that either does _not_ perform an insertion, or that inserts the suffix. What this means is that completion puts the suffix into the buffer and stashes away the fact that a suffix was added and what it was, and then it's up to zle (not any particular widget, but the editor engine itself) to adjust the suffix properly _after_ the next keystroke has been read but _before_ the widget for that keystroke is called. This is handled for builtin widgets by flagging in the widget table those widgets that perform insertions -- but there's no provision for flagging a user-defined widget one way or the other. This is dealt with by deferring the suffix decision until either (1) "zle any-builtin-widget-name-here" is called, in which case the flag for that builtin applies, or (2) one of the buffer variables is modified, in which case the suffix is normally kept. Most of the time, this results in the right behavior. In the case of smart-insert-last-word, unfortunately, the first thing that happens is a call to "zle .up-history" so that it can fetch the last word from the previous history entry. Case (1) applies; the suffix removal rule for a motion like up-history is to remove the suffix; and thus you get the behavior you saw. The workaround for this is to make smart-insert-last-word (or whatever the function for your user-defined widget is) forcibly keep the suffix, by e.g. placing LBUFFER+='' or an equivalent assignment before the call to "zle .up-history". An alternate solution would be to rewrite smart-insert-last-word to use (and thus require) the zsh/parameter module and the $history variable, rather than using zle history motion widgets. The best long-term solution would be to extend the user-defined widget creation routines to flag widgets that should keep (or erase) a previous auto-suffix, so that the internal implementation of the widget doesn't matter.