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,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 4342 invoked from network); 21 Aug 2023 14:14:45 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 21 Aug 2023 14:14:45 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1692627285; b=VdPWSeSzkauW7sa2O+58EtiSk4UzQz8zpxLn0nE+ZO3ZZZdJoTRr1KkUudVeN/AKaHG9GKxdXq HnkWzjTm0Z7OjyKNs+DBK5CVvtCj3NRUIDorIhO0wLVxd5m/DrnyagLxeht+XAofN/ki8Uls5Z nzNgz7Xi9TNCOGw4VrFd0vpfWUVbRdyrlJDcV2dO/27tLFRK4Jh8FOEJ4r4goxZS6zb5qI2CiK bTu0JUj5tjZk2iBCHxmS2/i8Eda1HVsyyhvrxSe7mmBvK9JeJUNvbuG8qn9EUgYLFW7Usy6wS/ VIei6u6+Zkc+N4c3UqRsk+gY8YgRrxyxv/Qb6ONRoMLOCA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-4316.protonmail.ch) smtp.remote-ip=185.70.43.16; dkim=pass header.d=protonmail.com header.s=protonmail3 header.a=rsa-sha256; dmarc=pass header.from=protonmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1692627285; bh=vkgSZUjuXYyJLtdiJqlU542w/4SV3krcwzDqDalq+hA=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:MIME-Version: Message-ID:Subject:From:To:DKIM-Signature:Date:DKIM-Signature; b=WEyGWL48yh5+50tVHh89i162k5r3VBUyKqoP97gXRZlU+6v3K0FPUwAo6NvHoFyjpgBistiTA/ RtvrEKtsV7O1bTgpZfnqF6UgPy+O7DOdoNpVXCBcGBwBfUbAn5iQkQ6oosp95kq0a6FB6A061p rSZBkn2464ghW42pS95/7LjFoeh3v2ao53CkDTTtcnjhyHXA216fvhC89tNiuw1BpP93s1RuRw y8B/NcuuNTIVr3llb+AvLv3S4tZk0Eky7o3gckPb+/0zcXXxeWOhFw3Ebcsh4XoMq0Ccq6c8JF UblHrb20Taih/S2hx7WHHPZl4F8dIRIKBMo7Lj1+mB1G6g==; 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-Transfer-Encoding: Content-Type:MIME-Version:Message-ID:Subject:From:To:Date:Reply-To:Cc: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References; bh=y/sD5Zgc0OT7tDcoSgaCHFq+wImprY++cDqEk8RVjmQ=; b=SGsXGYzMjTiI9JCwvtoRTnGNPF 3T8zrLoF96Q+qB95EYel7TvKRV9N/qlTz1mOr7p2fHapw1u4NalN71VvnzVuFwBMKcoGcoS77Pt/K vVwjfnuzYYRLzhEn51PRJJMg14WR+t3Jb6hYZv7Fu9f3Wf5CRMVaLUaXCW9Z9IzZStQE/ItYR16DB zkqNE4Ri6eR9Ngsh6I0vtL9kKlfYo1DvnXXL8L8PqP1AHXt1BwVXjHuKcyUxtVw9Anb5B8RMjxWFO uqIq6nYWo/XjwnMSgFNgDFoFgsiJlAZx6q/LSCHGCnO4MsGa0dSA2QkyTctlctxdsXSpVdnaLNUZp 6WaNdOcQ==; Received: by zero.zsh.org with local id 1qY5g4-000G7R-AZ; Mon, 21 Aug 2023 14:14:44 +0000 Authentication-Results: zsh.org; iprev=pass (mail-4316.protonmail.ch) smtp.remote-ip=185.70.43.16; dkim=pass header.d=protonmail.com header.s=protonmail3 header.a=rsa-sha256; dmarc=pass header.from=protonmail.com; arc=none Received: from mail-4316.protonmail.ch ([185.70.43.16]:46619) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1qY5fV-000Fmy-T4; Mon, 21 Aug 2023 14:14:10 +0000 Date: Mon, 21 Aug 2023 14:13:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1692627248; x=1692886448; bh=y/sD5Zgc0OT7tDcoSgaCHFq+wImprY++cDqEk8RVjmQ=; h=Date:To:From:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=s89Zf+h6k5DIkH9lPgefIaXeJ0ZopDeKnCHY2GY0VQ1agnW3vUyH8VYmun3OiMxFi IO82i0n/dUaIP35zjS2aVx+lblzqe0T5MgCoPsgdAT8bfAdnTkUg3xHOzeeQPVhEXq mJSe/6RTQWy+yqf5g49qaxBtcZm9/l+9e4i7ExahphQgjO4mLrTbNAvtUzWYRZn/DT pjxqWyIyQ4RDow/8Hu4CeiyUmNc5gtzvz2KXeFQoyfo88GoYDJ8lMIrjKHqEs2LBLP mFkMI7QFdMDwtgQOpEN6/hV1bFsgV2fFZouDHGpJSWiQZtGDI8UWzbEoqGU6OTIxc3 LBeqMl++jFQMw== To: "zsh-workers@zsh.org" From: Christoffer Lundell Subject: [PATCH] Enable linewise edit-command when in visual-line Message-ID: Feedback-ID: 3930316:user:proton MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Seq: 52072 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: Change behavior of edit-command in visual-line mode to edit command linewis= e instead of only allowing editing of the text between MARK and CURSOR. The rationale being that in visual-line mode the entire line(s) appears vis= ually selected, and so I expect edit-command to operate on the entire line(s). With this patch everything visually selected will be brought into the edito= r, while preserving cursor position where applicable. I am not entirely sure I handle this correctly, though it appears to work f= ine when tested locally with both emacs and vim. --- Functions/Zle/edit-command-line | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Functions/Zle/edit-command-line b/Functions/Zle/edit-command-l= ine index 5f7ea321f..52246b88f 100644 --- a/Functions/Zle/edit-command-line +++ b/Functions/Zle/edit-command-line @@ -11,7 +11,7 @@ local left right prebuffer buffer=3D$BUFFER lbuffer=3D$LB= UFFER local TMPSUFFIX=3D.zsh # set up parameters depending on which context we are called from, # see below comment for more details -if (( REGION_ACTIVE )); then +if (( REGION_ACTIVE =3D=3D 1 )); then if (( CURSOR < MARK )); then left=3D$CURSOR right=3D$MARK lbuffer=3D @@ -21,6 +21,23 @@ if (( REGION_ACTIVE )); then fi (( left++ )) buffer=3D$BUFFER[left,right] +elif (( REGION_ACTIVE =3D=3D 2 )); then + local mark_left mark_right offset_right + if (( CURSOR < MARK )); then + mark_left=3D$CURSOR mark_right=3D$MARK + else + mark_left=3D$MARK mark_right=3D$CURSOR + fi + left=3D${(SB)${BUFFER[1,mark_left]}%$'\n'} + (( left !=3D 1 )) && (( left++ )) + offset_right=3D${(SB)${BUFFER[mark_right+1,-1]}#$'\n'} + if (( offset_right =3D=3D 1 )); then + right=3D$#BUFFER + else + (( right =3D mark_right + offset_right - 1 )) + fi + lbuffer=3D${lbuffer[left,CURSOR]} + buffer=3D$BUFFER[left,right] elif (( ! ZLE_RECURSIVE )); then prebuffer=3D$PREBUFFER fi -- 2.41.0