From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23117 invoked by alias); 15 Nov 2017 13:13:38 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: List-Unsubscribe: X-Seq: 22980 Received: (qmail 4230 invoked by uid 1010); 15 Nov 2017 13:13:38 -0000 X-Qmail-Scanner-Diagnostics: from mout02.posteo.de by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(185.67.36.66):SA:0(-7.0/5.0):. Processed in 4.673594 secs); 15 Nov 2017 13:13:38 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_PASS autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: hadrien.lacour@posteo.net X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Date: Wed, 15 Nov 2017 14:13:26 +0100 From: Hadrien Lacour To: zsh-users@zsh.org Subject: Re: zle kill-region without mark consider start of line as mark Message-ID: <20171115131326.cazeuiazwmfy5dmh@gentoo.gentoo> References: <20171115104034.p7evb5raltjlg2ja@gentoo.gentoo> <20171115112437.4b2633c1@pwslap01u.europe.root.pri> <20171115130047.oxs4xbetcb3hzuh3@gentoo.gentoo> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To:<20171115130047.oxs4xbetcb3hzuh3@gentoo.gentoo> User-Agent: NeoMutt/20171027 On Wed, Nov 15, 2017 at 02:00:47PM +0100, Hadrien Lacour wrote: > On Wed, Nov 15, 2017 at 11:24:37AM +0000, Peter Stephenson wrote: > > On Wed, 15 Nov 2017 11:40:34 +0100 > > Hadrien Lacour wrote: > > > I have `bindkey -M emacs '^W' kill-region` in my zshrc and using it without > > > having set any mark will cut from the beginning of the line to the cursor. > > > I've tried to read zle's doc but found no mention of this behaviour. > > > > > > Any idea about what's happening and how to do nothing if the mark isn't set? > > > > Internally, there is actually no notion of the mark not being set --- > > it's simply initialised to zero, and moved when ask it to be set. > > Therefore, if you try and use it, it appears as if it's at the start of > > the line. > > > > The documentation doesn't make this explicit. It could do with > > mentioning the default state. > > > > pws > > Thanks, that's what I supposed too. I almost have it fixed with > > markset= > my-set-mark() > { > zle set-mark-command > markset=true > } > > my-kill-region() > { > [ $markset ] && zle kill-region > } > > zle -N my-kill-region > zle -N my-set-mark > > bindkey -M emacs '^@' my-set-mark > bindkey -M emacs '^W' my-kill-region > > > But I don't know how to reset markset every newline (other than doing an ugly > bindkey for Return). Disregard this, I just forgot to reset markset in the second widget.