From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,T_KAM_HTML_FONT_INVALID autolearn=ham autolearn_force=no version=3.4.4 Received: from zero.zsh.org (zero.zsh.org [IPv6:2a02:898:31:0:48:4558:7a:7368]) by inbox.vuxu.org (Postfix) with ESMTP id 1FB0E217C9 for ; Thu, 4 Apr 2024 11:41:13 +0200 (CEST) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1712223673; b=koZTRUIquwXXOC+Ld1c/Q2U9LcSHnr/YoTWpGR/hr+WRhrdB/KEvR8B2p8VITNMMewpX/Rmc0Z KIs/LGdFWF41yaj7jeu42C6vOtkVMpTei+tPpe5ZIpZZyTDkQT5ZHx8TNNin2KpDrvpLOiSLj7 xccHLkNXZy5fAQFa5zdmSGmtaRvMQRAkAaJIcXgKQlKNaB+WHO/M8rJc+2+Rdf83FUErN2y1OA Wldp+pBA0NikUcvN/ur44VuRuV0mka1GEEpya5HXxwio4I9hkf8ka2D7sCr4y3dDm4jAOvDblu jzYqHbFl1GMZhptK9AamwHpybxWVT3bzqVoWqUYoRR7CHQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (a3i336.smtp2go.com) smtp.remote-ip=203.31.37.80; dkim=pass header.d=smtpservice.net header.i=@smtpservice.net header.s=a1-4 header.a=rsa-sha256; dkim=pass header.d=huyz.us header.i=@huyz.us header.s=s254807 header.a=rsa-sha256; dmarc=none header.from=huyz.us; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1712223673; bh=1XanvmSPOmtrkqwyI9xK3R0iysszK6gp9UwT7EY8SCo=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:DKIM-Signature:DKIM-Signature:Content-Type:MIME-Version:Date: Message-ID:To:Subject:From:DKIM-Signature; b=L5xfpxNiUZ3pZYn1H5XF2IhKt9j/Xc+udE+gkd69vZRTsPcX5VD5W2aaPwXAL3GGD75YyY9RCH TuKBQtCph7aPcSmI5bft6tzjqCmZApRY3ihlqXL2MtAJ1yl83QgxAhESPIkFcRCw2JP6TWb0Cf 02MefnPCEddTtM/LAD5lzCVxLxTPxMmwhkamQdA7/N/+vyUwRvthpM5hYte9eX6uTyRgfu6ETM Y5Gnhi8yWHAHw5Bd7ovQIsPSnMNsdR0OQ98gtiw8j/BtfbDjSJ5ei9xr6+JkynE7wNo2S1Dbf5 o6HaxfeM7Qu6+NXPc9iRar8L2f1nlxEvqIFwO2XA6JxNyQ==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:MIME-Version:Date: Message-ID:To:Subject:From:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References; bh=7wN0wfBBHmZ6nVWIYGOTMnWoIwHhbEyzjyTRtW2zS8o=; b=Mf58W9jSW4v1fSgG+14ePeh+32 sCEiX9pDgc7MEaQGxJCUy0a/vfz9vkC1w8LRKRtb4WKNDOPg6xKLvh2r6g62KjgfURXhxVu7RbOuI oMH6uxttwdHs4R39Gw912mJ2F5xNQUr1Ak+5wBQ+tZSzdLfJRuj51zKQ6ZY651SwslhPCoLRAzrF5 w5nbNO4vs7y8OxQz4nns4lYaJ14FmtLSxqo8O1n72HJo9KkCO8d6RkyY6wjyIB0zbFVCHJikcBohz s4lrDJXlxL5aGSPsbwPVI9yXrMnCmzVae2WIALHgeUWuuG0yWenHbSVY5YJ+C3yF5OoAG9Ik3TA0w S3G6kDtw==; Received: by zero.zsh.org with local id 1rsJaq-000MbJ-N2; Thu, 04 Apr 2024 09:41:12 +0000 Authentication-Results: zsh.org; iprev=pass (a3i336.smtp2go.com) smtp.remote-ip=203.31.37.80; dkim=pass header.d=smtpservice.net header.i=@smtpservice.net header.s=a1-4 header.a=rsa-sha256; dkim=pass header.d=huyz.us header.i=@huyz.us header.s=s254807 header.a=rsa-sha256; dmarc=none header.from=huyz.us; arc=none Received: from a3i336.smtp2go.com ([203.31.37.80]:56533) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1rsJZe-000MFH-L2; Thu, 04 Apr 2024 09:40:01 +0000 Received: from [10.21.235.165] (helo=[192.168.1.50]) by smtpcorp.com with esmtpsa (TLS1.2:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_128_GCM:128) (Exim 4.96.1-S2G) (envelope-from ) id 1rsJZa-9EPHBu-0d for zsh-workers@zsh.org; Thu, 04 Apr 2024 09:39:54 +0000 From: Huy Z Subject: Path to fix copy-earlier-word handling of numeric arguments To: zsh-workers@zsh.org Message-ID: <03af2fe1-21d3-65cb-4bfe-d8e84c79c2dd@huyz.us> Date: Thu, 4 Apr 2024 02:39:49 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:52.0) Gecko/20100101 PostboxApp/7.0.60 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="------------EABC2011E77F16F5B2947F79" Content-Language: en-US X-smtpcorp-track: 1rsJZa9EeHUI0d.DrVrDZY9gwy5p DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smtpservice.net; i=@smtpservice.net; q=dns/txt; s=a1-4; t=1712223596; h=feedback-id : x-smtpcorp-track : date : message-id : to : subject : from : reply-to : sender : list-unsubscribe; bh=7wN0wfBBHmZ6nVWIYGOTMnWoIwHhbEyzjyTRtW2zS8o=; b=xSI2VmPPGlYoZBF8j7c5+R9LVUSaAlqx8SHVHc7ZZMf2uvnw/gGjASN4pmgbmhaMVgKE4 iSyg1WYJoK0l8GNqooflKxuGj8osTAo89ZGphwU86Uh+Ehyp6T1gBw0yYVniIFN3X7iTSSG zGFiYCf8LjHt3igm3WNfNsJcQ64n/EUFqGtRqQ8yZs63BEr/auND6HeiuI69HDZrj14skVB krEs43DX0ukMS3PlA5i7M4lbCEa4aiG+hxdf5YiYca/RVYD0oI0dlrJwFgPKNzrv33fbc7i bBiBHTBYldEA1HOoz429W1gMP0sVpOhw53aVIxEfqnrkASCgS58y8jzI40zA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=huyz.us; i=@huyz.us; q=dns/txt; s=s254807; t=1712223596; h=from : subject : to : message-id : date; bh=7wN0wfBBHmZ6nVWIYGOTMnWoIwHhbEyzjyTRtW2zS8o=; b=WGArDx4HhydwYdC/KRR6+Eya3A/OHmp6FDgo1HgbuvvRUcUeQA31Nemkzw8Ian6GUx4PV fBgcRAit7VWO5v/KfxtRM2JBUH9U5yfaa27j0mssFIKJgDyJpoTf12N7FqIrDyoL4s43oKr dcYa0hhV343+NS4AtGdo0zY+KKQZVrniqcxGHZiMiu+LROIBktKcwZM4vd43ezduCwDdC+o ulH3oQR7ytuG1SPdw2d+UFYvd8pzOlB2WMPTaG37jqaf/dmC7WybZQnBfMiCL8zqHd9cHTN ntjc6AvLg2yQRDSy8/H8a7U0XdU7U9wLmuQOUytQ91yalgFwiQ6dN8dBVqbQ== X-Seq: 52873 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: This is a multi-part message in MIME format. --------------EABC2011E77F16F5B2947F79 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit As initially submitted at https://github.com/zsh-users/zsh/pull/116 : ------------------------------------------------------------------------ As mentioned in the code comment: # 1 means last word, 2 second last, etc. the numeric argument is supposed to be interpreted as an offset from the end. The intended behavior is a lot more useful than the current behavior. ------------------------------------------------------------------------ diff --git a/Functions/Zle/copy-earlier-word b/Functions/Zle/copy-earlier-word index 90e862da3..1262c0c82 100644 --- a/Functions/Zle/copy-earlier-word +++ b/Functions/Zle/copy-earlier-word @@ -11,7 +11,7 @@ setopt typesetsilent  typeset -g __copyword  if (( ${NUMERIC:-0} )); then    # 1 means last word, 2 second last, etc. -  (( __copyword = ${NUMERIC:-0} )) +  (( __copyword = -${NUMERIC:-0} ))    zstyle -s :$WIDGET widget __copywidget  elif [[ -n $__copyword && $WIDGET = $LASTWIDGET ]]; then    (( __copyword-- )) ------------------------------------------------------------------------ --------------EABC2011E77F16F5B2947F79 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit As initially submitted at https://github.com/zsh-users/zsh/pull/116 :



As mentioned in the code comment:

  # 1 means last word, 2 second last, etc.

the numeric argument is supposed to be interpreted as an offset from the end.

The intended behavior is a lot more useful than the current behavior.






diff --git a/Functions/Zle/copy-earlier-word b/Functions/Zle/copy-earlier-word
index 90e862da3..1262c0c82 100644
--- a/Functions/Zle/copy-earlier-word
+++ b/Functions/Zle/copy-earlier-word
@@ -11,7 +11,7 @@ setopt typesetsilent
 typeset -g __copyword
 if (( ${NUMERIC:-0} )); then
   # 1 means last word, 2 second last, etc.
-  (( __copyword = ${NUMERIC:-0} ))
+  (( __copyword = -${NUMERIC:-0} ))
   zstyle -s :$WIDGET widget __copywidget
 elif [[ -n $__copyword && $WIDGET = $LASTWIDGET ]]; then
   (( __copyword-- ))



--------------EABC2011E77F16F5B2947F79--