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.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 11925 invoked from network); 23 Aug 2023 17:29:29 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 23 Aug 2023 17:29:29 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1692811769; b=gWenr1vN5zwgNGsVhpl/xwD7E0dft4TTWVYKidKxkZMgeme2Gda3c3sW/YqDe4HI9V5BEo0JaS ecIBS5AXHBnrj6n5jIO95gQhNzKRLO6AY+zHZz+KmCCKr2Bst9+m5TQWXcMGFMfbNj0tbswOrE IInyWp2UPRvEAGFJ3J5j4+yxz1A3VXpM3AsuKPLupeesLA50fvAfU5PKN4TNq9z8h4145w0yiq OKgo926TDhM+R6UDI91sNeShClxsEr2qAmDvUTDp5wNMO0pvMmffqP4aTL8r9Ji/dtwcrHherY Mk3DUplZG44OFHy3QAkFbCkLbK9VdCUL5QdMRnDC032EwQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-lj1-f174.google.com) smtp.remote-ip=209.85.208.174; dkim=pass header.d=brasslantern-com.20221208.gappssmtp.com header.s=20221208 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1692811769; bh=B0sWLf8fE8dLvy34mjDUjjZz4FZKfVAA1o5dNHG5F5k=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:Cc:To:Subject: Message-ID:Date:From:In-Reply-To:References:MIME-Version:DKIM-Signature: DKIM-Signature; b=axjz+8SCvlwU3Sh2IhC2rXtgloMRTtmzwRgRPe55lghN2DOnSAjQ3TphRlNbSS6+6HoVhkvD8G NtonrL5yqfTttU11JSCf/yqCITNAanozCm0civC1pGQH4E157BpdUr334PPuz8LFfExGemsrCe queLY8rdl1ySuOsE+ggEJnexli7yX41TyL9N/UqYgQcUy/XvIhqUKoL1+shwwtF/YwRolMHl3D l2ourEJ1CpreYUHIZOTjs6rSkS0ZX9snY0b/9c6WNyRlv2/AVWzU2NNTuI213BCK5aXe0Dlz// rx0aDqkZT/dCZbyAoEpFYnRGaJhLYhKMLgBTmFY4BCLmQA==; 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:Cc:To:Subject:Message-ID:Date:From:In-Reply-To:References: MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=OVFILE2a0KCH/wrxHFYZCS8ZSmTjEXikk17uFT7ALMQ=; b=NtMDR/H77SEQhhp3hPgolPEfMj mRfEl4H3uEoYkIB06ljtikukV1nfwi7beJvrFT7EW4jwkpvcDFTIspZ1Ym7KhJNJ1ZAg/btxH65Bs Uv3qaLPPyts7pS33O+UZyc3TtPnOb4B4B/ica30Hd68LFRX8Xxi2g9oBu7g2MTNGge+vz+nkwNP0P gExFB6Zx9jvsSHZGEJrYd16Oxhkdz9AYbLvK5i7vTsEjEvYd0Pbm8O9jQK8W9c+7nHQIoNoPXV1Vx rvc/ydz6IgQxaRnPXxjFfHSNkFwRtLy1pJZadY0bsZ3eAU7lSaeu3kstPvHFlG0h1wC1LlLjmSYtj Mma4z1ew==; Received: by zero.zsh.org with local id 1qYrfa-000BSE-13; Wed, 23 Aug 2023 17:29:26 +0000 Authentication-Results: zsh.org; iprev=pass (mail-lj1-f174.google.com) smtp.remote-ip=209.85.208.174; dkim=pass header.d=brasslantern-com.20221208.gappssmtp.com header.s=20221208 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-lj1-f174.google.com ([209.85.208.174]:60535) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1qYrex-000B9g-Qj; Wed, 23 Aug 2023 17:28:49 +0000 Received: by mail-lj1-f174.google.com with SMTP id 38308e7fff4ca-2bbad32bc79so98352571fa.0 for ; Wed, 23 Aug 2023 10:28:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20221208.gappssmtp.com; s=20221208; t=1692811727; x=1693416527; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=OVFILE2a0KCH/wrxHFYZCS8ZSmTjEXikk17uFT7ALMQ=; b=TdgCas/E8AUaJwsrMojer/Bdh6C+cwcGB1t3cat2k2NlK9VA58QOydsJjC0kdj9wUC 9WlA+XoihVHxDX0Kv7PDANPvPlzdzIBcmbd1pK+lAABG0IWVOoSD/cLJMSxJJVinf6u7 sUimYYKz6+tHDSCMyOcewXKclSxv8If2NCbp1bQIbiCLSrB5mFhp8b/99IWIx4sKcvjQ H99YUA1h/QU04HOM/Y658Rv0GDVddL08iIOsaluZTtTWFkRHTe050MxQUJf08Weg1TxX EGvBn+wSYM+VW3R1++Lyr4gb69SpZbbkXW+B+x4Pq567t7KufhTSrGB54I4TSECL1rae TTYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692811727; x=1693416527; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OVFILE2a0KCH/wrxHFYZCS8ZSmTjEXikk17uFT7ALMQ=; b=ULoJ7v2TxGz6hQGFwawx4A/Ts1XL2BN4ySs9YcvucB8Gl0F03r+hGCIELHq+CoCqxF 0pTTN52IjJoilCMnkxfF5FI2YN5JRBgwNgJzpzFoqPVA8iiZygYeB4mjKBJbzU1/r5qA 9goWyAko5LHgSeo6zBYDX8amR3x7lpHhJJNRdWgPkKTEd5acyusd5EWpUupIGbk9b6PY 1e/Qdd8R5/qUL+3aqJrTWfFPm7Ah2aavS1PIkBzvytMJT1ehFzT3eITvwKP4/hbbhJyb WxTaIJopgexxmoYCXbb11t1VmbHhoMsyVgY1qnAmohKCEfReohd4HVoz6H49uIen+CHA FI/w== X-Gm-Message-State: AOJu0YyGaFRihlxQ3bwZPlSC/ZzzULoEPg0em3TeNJk1Pb1la/ZR96vi gyRCFmacvYBMfN1j8mN9Q2VEhzJhrDfTWAcHqj4UiQ== X-Google-Smtp-Source: AGHT+IG1gPAL8HLzV17Gs+cAHNsSTYMPn8KTMi136UJtPtn2I1JbRXgfvZ5N21Z90iMmGSC/6/ENtjNKBAnZySJx4YU= X-Received: by 2002:a2e:86ca:0:b0:2bb:8d70:c9e with SMTP id n10-20020a2e86ca000000b002bb8d700c9emr10803147ljj.47.1692811726687; Wed, 23 Aug 2023 10:28:46 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Bart Schaefer Date: Wed, 23 Aug 2023 10:28:35 -0700 Message-ID: Subject: Re: [PATCH] Enable linewise edit-command when in visual-line To: Christoffer Lundell Cc: "zsh-workers@zsh.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 52084 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: On Wed, Aug 23, 2023 at 2:06=E2=80=AFAM Christoffer Lundell wrote: > > > > + offset_right=3D${(SB)${BUFFER[mark_right+1,-1]}#$'\n'} > > > > This I'm not sure of -- why mark_right+1 ? > > This is because CURSOR and MARK are 0-indexed, according to zshzle(1). They're 0-based because position 0 represents an empty line, the non-character before $LBUFFER. The BUFFER and LBUFFER arrays themselves are still 1-indexed (unless you're crazed enough to be using zle with ksharrays). BUFFER[CURSOR] is always the character to the left of the visible cursor position. To make this work, CURSOR is decremented when entering vicmd mode (unless it's already zero), but that doesn't change MARK. So ... I think this means that in vi-cmd-mode it is necessary to use CURSOR+1 when MARK <=3D CURSOR, but not MARK+1 when CURSOR < MARK? And never add one when in emacs mode? This bothers me a little because starting from CURSOR < MARK, exchange-point-and-mark (or vi-goto-mark?) could extend the range one full line to the right? > which also means we later on no longer need to immediately predecrement $= right, > since the matched index will be 1 lower. I'm not sure whether the foregoing affects that, and can't experiment right= now. > There is also the issue about supporting cursor position in emacs, since = now > $lbuffer is used to split the selected lines and figure out the cursor li= ne and > column. But in both the original code and in your patch improvement, $lbu= ffer > will contain text from the beginning of $BUFFER regardless of where the v= isual > selection actually starts. This works fine in vim since they only use byt= e > offsets, but I would recommend changing it to the following in _both_ cas= es. > > lbuffer=3D$lbuffer[++left,-1] That's equivalent to lbuffer=3D when left=3D$CURSOR because by definition everything after LBUFFER[CURSOR] is empty (and lbuffer=3D$LBUFFER at that point). I believe ((right-left =3D=3D left+1)) when right=3D$CURSOR, so should be a no-op compared to the original ((REGION_HIGHLIGHT =3D=3D 1)) case. Disagree?