Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm
Precedence: bulk
X-No-Archive: yes
List-Id: Zsh Workers List <zsh-workers.zsh.org>
List-Post: <mailto:zsh-workers@zsh.org>
List-Help: <mailto:zsh-workers-help@zsh.org>
X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID
	autolearn=ham autolearn_force=no version=3.4.0
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=brasslantern-com.20150623.gappssmtp.com; s=20150623;
        h=from:message-id:date:in-reply-to:comments:references:to:subject
         :mime-version:content-type;
        bh=M84WOu1exdytUrREvMfthZ3aJVPQe8AKi/4Mj8Lw+LE=;
        b=MpBm5peIEpRCuY9NZwx4Io3Q/hkgQaEmqf7ZwGaXclY8ife6rB8Vbto2+XZWxkRHed
         DNiSqAH/u7UNR+RGAWYzhSKnN7UdgxwF7ZzC5h8zZUuuI0X9JVTGSwBOgrbeBPpBqDr1
         Nq3hJbQZ2aFs7RlQ/QbsLtsE9K5VieKHXCZs7mEzPq/KQ03KUgjV6qeNB/NsU8ExQGlb
         URXeG3MfgdF6aax6uPxR4uIIKVOpzJQQBw++QhkERb6aCJRDujO8KYuf5dATIAXyZvAS
         zMPhS/yBgqWZiLKF/xRFiAPdkuMMg54yAtMNpN/zMYuD2Ial4UuDjL6BRbS4Eb+MblTM
         QOVw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:from:message-id:date:in-reply-to:comments
         :references:to:subject:mime-version:content-type;
        bh=M84WOu1exdytUrREvMfthZ3aJVPQe8AKi/4Mj8Lw+LE=;
        b=QruO56liueeqV7GXxy7Kp+FVza5CzqwGOrG0AbnX3mVsOYCO1PYCwSBEZ3HUIzfRHS
         GtdlyJqqJ/k5Co0907rrfrBWGNAFAizWv2Y9X5ZvdegQZGUrhSlk3m8jRf7ypqZvJsDK
         oJ7/GXN93GcwySNRspwFvWZ3Q5NOwF//A9bv0kxoJbURMV9sp+27ujRjrftLQ0Fr+W4N
         GorYSSfSRNLWmPHwQsVTYjNvV6lopY4/KwMZZ0comV11rihtdS3YP0NKGfJFlgvDgj9W
         JtCFWUKmcjFrTKcvwiD1E0wm3Cwq0f5gWatu8/7OBKOWuJBGpIPZZb3TLooH4/tnbQPZ
         0fOQ==
X-Gm-Message-State: AG10YOTYnY+u7pRExDsnKcfbHISpPa8JkExV/79H+QQZaEtv+mObf/j+j50Cn+pApo8x1w==
X-Received: by 10.98.15.82 with SMTP id x79mr16795198pfi.52.1453262138303;
        Tue, 19 Jan 2016 19:55:38 -0800 (PST)
From: Bart Schaefer <schaefer@brasslantern.com>
Message-Id: <160119195608.ZM31931@torch.brasslantern.com>
Date: Tue, 19 Jan 2016 19:56:08 -0800
In-Reply-To: <CAKc7PVB-X+DYVEHRqSoOiDAjNeTsVyz=EN72FHQuF=AnRmh65A@mail.gmail.com>
Comments: In reply to Sebastian Gniazdowski <sgniazdowski@gmail.com>
        "Re: "drop-in replacement" and transpose-words-match" (Jan 19,  9:28am)
References: <160111233259.ZM6719@torch.brasslantern.com> 
	<CAKc7PVDhxbVgmV7WcGgyDzMmWSjwQ=7=LExXTwr7YvPzPpn2RA@mail.gmail.com> 
	<160118223126.ZM28565@torch.brasslantern.com> 
	<CAKc7PVB-X+DYVEHRqSoOiDAjNeTsVyz=EN72FHQuF=AnRmh65A@mail.gmail.com>
X-Mailer: OpenZMail Classic (0.9.2 24April2005)
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: "drop-in replacement" and transpose-words-match
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Seq: zsh-workers 37698

On Jan 19,  9:28am, Sebastian Gniazdowski wrote:
} Subject: Re: "drop-in replacement" and transpose-words-match
}
} On 19 January 2016 at 07:31, Bart Schaefer <schaefer@brasslantern.com> wrote:
} > [I would probably save CURSOR and MARK, set CURSOR to zero, then loop
} > on "zle forward-word" until I reached or passed the old CURSOR, rather
} > than try to match up the results of (Z:n:) to $BUFFER.  Then restore
} > CURSOR and MARK, of course.]
} 
} This would miss spaces. zew-pb remembers white space before each word.

Forward-word advances past the whitespace, so you just have to split it
off the end of each region as you advance.

} My point is
} that Zsh could provide more information (besides LBUFFER) to Zle and
} compsys, and also zsh-syntax-highlighting.

Of course the $words array etc. is supplied to compsys for exactly this
reason; you are merely asking for a different scope and definition of
"word".  In fact a huge amount of information is supplied to compsys,
way more than most completion functions need to use.

Beyond that, the information you're looking for doesn't exist.  The
parser is not activated until accept-line or the equivalent occurs.
To get what you seem to want requires an entire separate-but-lesser
implementation of the parser, kept in sync with the real one.

Which I guess is what zsh-syntax-highlighting has attempted to do,
except by writing the second parser in the shell language itself.

} Zsh-syntax-highlighting can be slow, which can be seen by editing ~400
} lines function with zed -f. Maybe it's because it's doing various
} things to compensate not that rich information provided by Zsh.

It's mostly because it's re-analyzing the entire buffer every time any
change is made, if I recall correctly from the few times I've tried it.

