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,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 11669 invoked from network); 2 Sep 2022 08:56:37 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 2 Sep 2022 08:56:37 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1662108997; b=nUgOyiskM2Dy4LrS+0noQVLQjJ5fH/q7fj0RAwQN9lLM/rewDoxj+QoRRBg8VyLEU2emlWl3wv SUIJNrfsF+y0plRVq595GBNxCMkmspTBw3I0wNruZPPBVUSsO9wX2ILSXhK8bOt6ayYhNUqGta OBnCiZdVnTeVLSkxp8xnWFUf8OgPAmxUUTudGaLm3y6bmiFQh+lHPIhUkMm+I/tF6oFq3upmn1 PHEdokCRk+X6uGhzucAzHbrKWU1lAf94pWW3QoO0GpgG6d4lU13Xy0Knsd2EcBsPvSmVm2gHMo jUL2cflLfJlZFrG897nckMDwgaD5hmNwCBIELhI833F6Qg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (wout1-smtp.messagingengine.com) smtp.remote-ip=64.147.123.24; dkim=pass header.d=daniel.shahaf.name header.s=fm3 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm1 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-20210803; t=1662108997; bh=5YviEbcsiz3GwprCDevprB/OBe4P8JilRwabHyelvnw=; 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=h/GYdD6Y/NSana1pGLBQbd8/eKfYKIQM3HrTBTTfKixHzoD05oRzoj7ginRsDpG0nMh89CMs2C 0mFAMhe7EGVWR+3htNQh3ixbMlbcdPsdVVhe3SdTq83pvZrRHRPoUh0N8OBgt3FOw4+cClCIdY zpyKRCTkX2w3p4Zf3PsUXXog9dcu2+VeyXxcVf6pui7AB/JtVETCYY4uvpqO5t1jioCpbSTu5C ZoHvDXJn1FZapahGMOygpxmfn1jNETMeoS5NiZ2StrZXZSaksshdjm033yUR0P3oGHhHk1/1F4 52rqf+EeDs3Hbs01u7r3OuHLZ6xHMCXCh6+7kSlPvi1+Dg==; 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: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=m3d2l+CoEOxVpN2qXXBYv7oXc732nrebNsa+7RVdxyg=; b=YvD+Od02EOVm2cu72f+u6OYfDh atUTafFlwxdjxwwOVZq5Sq55CsCtpSYQQMJ1Z8/wUTdZPuueUe4vfEmSggwWrRpEXowf+1piibAF3 6US93iPiAfu5/f6FZdxcaJlzJDG40gd9Kfwo5kWr4C5AtdWMDIsGRJN1JclOXos54JsBLqEwgaomY axmOYSojlRCTsvDBpyI8TM8vMId2dXBvS0o3H4rYSMr9UoT42PDC6AiJwuSt6pNMzn4ZHT78Vy2kP 6f37YADkb6UsalAdX80zb2iyZ+Ytabh1ms2WFdRP3R4oiGU7ScdaK/7ipVAhG8Lfr48A1F8S5oTXr wszbhaNA==; Received: from authenticated user by zero.zsh.org with local id 1oU2Tc-000JiF-7Q; Fri, 02 Sep 2022 08:56:36 +0000 Authentication-Results: zsh.org; iprev=pass (wout1-smtp.messagingengine.com) smtp.remote-ip=64.147.123.24; dkim=pass header.d=daniel.shahaf.name header.s=fm3 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm1 header.a=rsa-sha256; dmarc=none header.from=daniel.shahaf.name; arc=none Received: from wout1-smtp.messagingengine.com ([64.147.123.24]:43001) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1oU2OS-000JH1-Dy; Fri, 02 Sep 2022 08:51:18 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 4454232008FE; Fri, 2 Sep 2022 04:51:13 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Fri, 02 Sep 2022 04:51:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=cc:cc:content-transfer-encoding :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm3; t=1662108672; x=1662195072; bh=m3d2l+CoEO xVpN2qXXBYv7oXc732nrebNsa+7RVdxyg=; b=TiptNsW2It0BS1jMRGKTSwY5lw FaHNsUdBzNzOy6QWwdDe025x0rHLKleKXL26pstEX/SDZsa2j7iKwpjUMewM0U2q F8/Y9EFrBj/PCMnPoT5tVCw5qD3MG5mJoLHfTaKRn+n03een8tJrckuFea5gn/jR KD2ykdoBkx9qFtFYYycTU7ZVepeqg+oOkhWviviH8uDd0sqxo781wSlsqZNAyYJy jUFTU9TKXQXnrcNQYbj53e14mOoTf4sQ2MaioZoQv/0g/3hoWMgpbkc8GyrhuALX 67I2Ee3LrcLSPEBQP7mPnavvUcWhiCJTi8CGoir8cBq1q4b7m6GGrOGRdGxQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1662108672; x= 1662195072; bh=m3d2l+CoEOxVpN2qXXBYv7oXc732nrebNsa+7RVdxyg=; b=d 14SmeuOzsgUx6FpZmn0YYTEJ/pxMRZKrZLa2p8ncKkl9DEVVg2ao8AL14kzhgsYZ WwA3AuKmF/nsZ+MoZhsdmM1F/S12bwOwkU/aCyw0SZtOtwlzCevnd/u4hLb5R93D jBabZLeR24lM0MbsczYWy2avBYG0owLqGpFEanlGng+3sM53j762B+gdErhO+MB7 fTsXLAY2I3amxKIcm/gVNanWjMgji3RTh691pusqUAZytPLQacbkXyO7hmIzZsvA MAXgMNJwUay4CESdOKQQLR3/N4G0tr0p/qVsaVIhLUJuO91U+1Aomk0NjMpXnjQM vs6REZCHtNYmwSg3R8y7Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvdeltddguddtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggugfgjfgesthektddttderjeenucfhrhhomhepffgr nhhivghlucfuhhgrhhgrfhcuoegurdhssegurghnihgvlhdrshhhrghhrghfrdhnrghmvg eqnecuggftrfgrthhtvghrnhephedtfeduleetjeeufeejleegvdetvddthefhffejgffg ueehteehudeukeeuhfehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrg hilhhfrhhomhepugdrshesuggrnhhivghlrdhshhgrhhgrfhdrnhgrmhgv X-ME-Proxy: Feedback-ID: i425e4195:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 2 Sep 2022 04:51:12 -0400 (EDT) Received: by tarpaulin.shahaf.local2 (Postfix, from userid 1000) id 4MJs8G6KpHz3Kk; Fri, 2 Sep 2022 08:51:10 +0000 (UTC) Date: Fri, 2 Sep 2022 08:51:10 +0000 From: Daniel Shahaf To: Felipe Contreras Cc: Zsh hackers list Subject: Re: [PATCH] initialization of main keymap Message-ID: <20220902085110.GE5920@tarpaulin.shahaf.local2> References: <20220831122842.GC992100@zira.vinc17.org> <20220901002300.GD992100@zira.vinc17.org> <20220901012122.GA1046913@zira.vinc17.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Seq: 50569 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: Felipe Contreras wrote on Thu, Sep 01, 2022 at 16:58:05 -0500: > most vim users use emacs key bindings in the shell. Citation needed. > In my opinion the default should always be emacs bindings, no matter what. +1 If the default were /either/ vi or emacs, a patch making the default depend on the value of $EDITOR would never have been accepted. We'd have pointed out that it was overloading an environment variable that already has a well-defined meaning; that a dependency between that envvar and zle violates the principle of least surprise; that assuming strstr(…, "vi") means "Vi-like editor" is guesswork (cf. PEP20); that the C code shouldn't presume Vi users necessarily prefer «bindkey -v»; and that users can and should set their preferred Zsh Line Editor keymap in zshrc. Attached is a counterpatch for discussion. Felipe: Should revisions to this patch be requested, feel free to beat me to implementing them, if you wish. Cheers, Daniel [[[ diff --git a/README b/README index 21142e17c..f4821e0e1 100644 --- a/README +++ b/README @@ -31,6 +31,28 @@ Zsh is a shell with lots of features. For a list of some of these, see the file FEATURES, and for the latest changes see NEWS. For more details, see the documentation. +Incompatibilities since 5.9 +--------------------------- + +The line editor's default keymap is now the "emacs" keymap regardless of the +value of the environment variables $VISUAL and $EDITOR. This only affects you +if your $VISUAL or $EDITOR environment variable is set to a value that +contains the string "vi". To get the previous behaviour, add +. + bindkey -v +. +or, if your $VISUAL and $EDITOR environment variables vary, +. + if [[ ${VISUAL:-${EDITOR:-emacs}} == *vi* ]]; then + bindkey -v + else + bindkey -e + fi +. +to your .zshrc file. These snippets are compatible with previous +versions of the shell. + Incompatibilities since 5.8.1 ----------------------------- diff --git a/Src/Zle/zle_keymap.c b/Src/Zle/zle_keymap.c index d90838f03..67a5351fd 100644 --- a/Src/Zle/zle_keymap.c +++ b/Src/Zle/zle_keymap.c @@ -1445,20 +1445,14 @@ default_bindings(void) } /* Put the keymaps in the right namespace. The "main" keymap * - * will be linked to the "emacs" keymap, except that if VISUAL * - * or EDITOR contain the string "vi" then it will be linked to * - * the "viins" keymap. */ + * will be linked to the "emacs" keymap. */ linkkeymap(vmap, "viins", 0); linkkeymap(emap, "emacs", 0); linkkeymap(amap, "vicmd", 0); linkkeymap(oppmap, "viopp", 0); linkkeymap(vismap, "visual", 0); linkkeymap(smap, ".safe", 1); - if (((ed = zgetenv("VISUAL")) && strstr(ed, "vi")) || - ((ed = zgetenv("EDITOR")) && strstr(ed, "vi"))) - linkkeymap(vmap, "main", 0); - else - linkkeymap(emap, "main", 0); + linkkeymap(emap, "main", 0); /* the .safe map cannot be modified or deleted */ smap->flags |= KM_IMMUTABLE; ]]]