From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 6548 invoked from network); 29 Mar 2021 12:31:21 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 29 Mar 2021 12:31:21 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1617021081; b=YmAQvj6lNWKl6hBvpTdZ1UJeIBQ5UuzmViKaIG1OhcB/E+itOtui8P0o7gLvvKdM3X+35XofAH dH7QZaLTII/SH0i2rFRRUdaj5moFfJeF0sCBVk2EH/YI06qdmkEDfpiUJYAo65tYGmQIKGMYWk TR+m9JZjtNmK5ueoIYyQDjUsRmehvaDEsxC7JPzAB9H/7+kSL1782+MxVrgSogdPJ2w8SLOWP8 aNbiB5+Skq9uvI9qeGkGweUVHjVgCeYyKxlSwAeFLHaFp+8BhBuMnJIt2GRwaeLNMHTqbXVVJv zXvuRfauZpr6I6EgZa3eb37QnArmV484J3rYNUqrXyFp1Q==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (out4-smtp.messagingengine.com) smtp.remote-ip=66.111.4.28; dkim=pass header.d=daniel.shahaf.name header.s=fm3 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm2 header.a=rsa-sha256; dmarc=none header.from=daniel.shahaf.name; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1617021081; bh=PwCXwEd19z1fw1IbB9BzA3SgafvsPLW6HnwKOa1EqkI=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:Content-Transfer-Encoding:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:DKIM-Signature: DKIM-Signature:DKIM-Signature; b=th1vXG3UsbfH/UZzbkH5kkAU72swr+MpflZNDQrmond0fR0FKnPWBTT+JEEEmX5UlOZKNIPl5G GZBz89ucca363uDFvcm65LmUGOSfedf6Uu3WvxxNloZHJb1nK7BPvVaaFnyW7R1FbDGFD9jJtE 9ekNH2pxtNCUBO+STh+/oiJctuUyJzBLP+Lh4q2GGII+8KHjv8R0fYc3uGV9UNaiT/Ft7iJtH3 wXurLB6W9Xi8qchABrE35iYi4rbzwlYXmpCb86QaS3pLWll0335MEDp9IhVvjPB7cn9+4nKtA9 Jaxh1tghHL/Qturl4XTgiJwf6TDMMj3S2WFYrowMe+YgcA==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:In-Reply-To:Content-Transfer-Encoding :Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID; bh=NQG7mm8dI3ct1ExDuqlt60Ghff8ZO4JfOdM1tK4oew8=; b=brlK2ZeU8zx6TfPfCIonw1s0Kx TkAAXCUIpDU8rg85khnPKohcMqad/TjTUZQ6GxEI6JOnWZLXfL3n8W7A58CzVD6uEzBBPuCv69Emn aHs/smDXp9cwnvXgYlQ8w2FtxOcQyYiIaYO980WGDXdXIKX0XYhyfslXduvkhzZLe4zGCUckIFwpz VebIMGXtnkdEpeDsi5q/UZ4CuZJMRuf4jD4R4hv3QaqxPf/u88FIK5FkwefEGuZxZ+xBaWxcKuPwd Uc9Az+elvWIeL4S8XP0QZ6jZgh1kKHi+XA7kDqah6vCfYzA8ILRr/pWTMskawE409ZcbUtRtjwY4A NqY6dZIw==; Received: from authenticated user by zero.zsh.org with local id 1lQr3B-0003cw-At; Mon, 29 Mar 2021 12:31:21 +0000 Authentication-Results: zsh.org; iprev=pass (out4-smtp.messagingengine.com) smtp.remote-ip=66.111.4.28; dkim=pass header.d=daniel.shahaf.name header.s=fm3 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm2 header.a=rsa-sha256; dmarc=none header.from=daniel.shahaf.name; arc=none Received: from out4-smtp.messagingengine.com ([66.111.4.28]:33765) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1lQr2r-0003TQ-Np; Mon, 29 Mar 2021 12:31:04 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id BC5FE5C0053; Mon, 29 Mar 2021 08:31:00 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Mon, 29 Mar 2021 08:31:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=date:from:to:cc:subject:message-id :references:mime-version:content-type:content-transfer-encoding :in-reply-to; s=fm3; bh=NQG7mm8dI3ct1ExDuqlt60Ghff8ZO4JfOdM1tK4o ew8=; b=ccUQo6zfPb2dXC9uAZOmj3NVZFh2Pm4bDhCJIolizJEOyBj5kR0oz68L eWfVaNVaddDm0iX0bbqwWxWn2nUTgPmY3jhdwRDyFSWB42UzYvRL0mDznisvVeFM +HlzLma1UmmaXvHcmWYFt8R5euwwZtK0Q4FsZ8685LVCk4f6FWaMC9v9lWYEIfA2 m6oLiEpsc2ee0FgX1cYDO+9w6vkOdejsVPLb4z7KAPlS0SejQbXw09vf/wGBdABR amY1fNfIFu83sBYRA5xJZUjYHZFr2Kd7z+N8A87KwwCRnrnit4SrJh/LMhdx3nPO 6l5oEkpqdqkODI+2Eemm5j+rQMW1zw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=NQG7mm8dI3ct1ExDuqlt60Ghff8ZO4JfOdM1tK4oe w8=; b=atXsCFEqIVY6fKCWLNBk4xSuZ4m63om1al7aBuunIHGbS3EJ/SWwpHnI7 U+/CZFvjETgqa0QkAOCOJjuE+5kcdbPFMf9s6mwYjijNYsZ+H1bzKZvSCe0PVz8v 7CieOGgifAiEJvCxmnGV8qrnv3c9O0lLtlPxwiBw6tF/zilkDdYZBAybB1u0L/Io Ro7IhVoxSRvBwef5vfjnQutqCrWIig6kFMFJGI5QySa9B/IGjCKRzwHd9kyoK3EN 13rNSRBbjOV2E7dRWYrqwODlj5RGIdVGkUJ8Nvy8nwRrRe+3s+9D2RRcaIqWYknm ll/xwuQTH4V4KdxN5j0tzDBPfzQYg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudehkedgheegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfhfgggtugfgjggfsehtkedttddtreejnecuhfhrohhmpeffrghn ihgvlhcuufhhrghhrghfuceougdrshesuggrnhhivghlrdhshhgrhhgrfhdrnhgrmhgvqe enucggtffrrghtthgvrhhnpefgkefgfeejgfdvvdfguddtleelkedvfeetiedtudfhveev veduhfdvveeffedvueenucfkphepjeelrddukedvrdefiedrudekudenucevlhhushhtvg hrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegurdhssegurghnihgvlhdr shhhrghhrghfrdhnrghmvg X-ME-Proxy: Received: from tarpaulin.shahaf.local2 (bzq-79-182-36-181.red.bezeqint.net [79.182.36.181]) by mail.messagingengine.com (Postfix) with ESMTPA id 4F0D0240054; Mon, 29 Mar 2021 08:31:00 -0400 (EDT) Received: by tarpaulin.shahaf.local2 (Postfix, from userid 1005) id 4F8Bkn51qQz3HM; Mon, 29 Mar 2021 12:30:57 +0000 (UTC) Date: Mon, 29 Mar 2021 12:30:57 +0000 From: Daniel Shahaf To: Linus Kardell Cc: zsh-workers@zsh.org Subject: Re: KEYBOARD_HACK breaks with escaped quotes Message-ID: <20210329123057.GQ18178@tarpaulin.shahaf.local2> References: <1fef65c9-6680-b17a-98e8-c67572778f7f@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1fef65c9-6680-b17a-98e8-c67572778f7f@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Seq: 48319 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: Archived-At: Linus Kardell wrote on Sun, Mar 07, 2021 at 11:23:40 +0100: > So, zsh has the KEYBOARD_HACK option as an anti-annoyance feature, which > removes a trailing quote character in case you accidentally hit it along > with enter. However, this naively looks at whether there is an odd number of > quotes at the command line, which causes it to invert when you have (and odd > number of) escaped quotes, removing the trailing quote when it shouldn't and > vice versa. For example, if you write 'test'\''test' or 'test'"'"'test'' > with this enabled, zsh will inapropriately remove the trailing quotes, > whereas if you write echo 'test'\''test'' it will not remove the trailing > quote. Instead, zsh needs to more smartly check whether the quoting is > unbalanced and if removing the trailing quote would make it balanced. In the general case, determining whether the end of the line is outside quotes requires knowing the previous lines (because quoted strings can contain literal newlines). SUN_KEYBOARD_HACK is implemented in inputline(); it is not part of the lexer but a black box the lexer uses. Therefore, I suspect that function can't easily answer the above question. Even answering that question for a single line would essentially require lexing the line — whether using lex.c, using get_comp_string()/addx(), or using bufferwords(). That's not impossible, but it'll be a lot easier to unset SUN_KEYBOARD_HACK and reimplement it as a zle widget, perhaps using ${(z)} and the concept of addx(): accept-line() { BUFFER+=' x' { local buf=$PREBUFFER$BUFFER if [[ -o INTERACTIVE_COMMENTS ]]; then local -a split=( ${(zZ+C+)buf} ) else local -a split=( ${(z)buf} ) fi } always { BUFFER=${BUFFER% x} } if [[ ${split[-1]} == x ]]; then … fi zle .$WIDGET -- "$@" } You might want to use LBUFFER rather than BUFFER. Incidentally, we might want to invent a syntax that applies Z+C+ iff INTERACTIVE_COMMENTS is set — say, ${(zZ+CC+)} could mean that, to avoid using up a fourth option letter in the Z+…+ context ;-) Sorry for the late answer. Daniel