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=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 17506 invoked from network); 8 Aug 2020 10:17:28 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 8 Aug 2020 10:17:28 -0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=Sender:List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Cc:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=viAQBEui4uFQQDp0JnDS1D8uobRgBnYHriyDz5PJjAU=; b=mH8GdiToyOSLkAOSVGwOO7B3cg FVbzeay4r9MqTWzuTq0tXG89ytoZzAZzPa5XpEdc5tjAcnM9eQsakBynF5u7ke1usFyZHm8NMcEgX SM2tkVhjJj8LltTLpW4bdMAH4yxDwm5KmFIO5dpnOu4WJsq97MSQvWmLOKZV0uDAaOAQhROjVT57l ny6OkX1zwttZ4GE5GKLbvHR3x5sTrQkiok9HpEjvCL88VAaYFQyEUVIzt3UHGyNFVNtMFviMtKbsG Jbj4TC/UI02t59sn51ppWG2e2vZBtx5ENCMTjs+PVxxbVEAZ3UE3pLCcYDoDeSzWJdBJCoX2MhUf5 oqfri+9w==; Received: from authenticated user by zero.zsh.org with local id 1k4Lun-00015T-1t; Sat, 08 Aug 2020 10:17:25 +0000 Authentication-Results: zsh.org; iprev=pass (mail-lf1-f68.google.com) smtp.remote-ip=209.85.167.68; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256 Received: from mail-lf1-f68.google.com ([209.85.167.68]:37451) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) id 1k4LuV-0000vm-Mt; Sat, 08 Aug 2020 10:17:08 +0000 Received: by mail-lf1-f68.google.com with SMTP id s9so2275677lfs.4 for ; Sat, 08 Aug 2020 03:17:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=viAQBEui4uFQQDp0JnDS1D8uobRgBnYHriyDz5PJjAU=; b=vBcKsYIvLz1tOtxcixlGF1kBBWk0nQ3il9ORFroVMcOWk2/WLWBwAjk8Cj/WJstouS D4nl7U95tBZrm0NJ9v9scpr2f3CVz9O1VZaO7326q5c/DiMUVJsSYRVenH3pl+MqiIn8 3/5GU1F3xW/2MGr87WwHEEpb4yA1jUNgAZRpjPV2XUSnJDoE8riWmF4AjVMtxwhQGcWP jDXeVDGp0wey7TpozrKgyPxGt2Ti4fjku5LZF55A+o6rIeiGC925CpwtNvEBBwUveXYC WdawVCP+zNY7+p4xHnvcuiz/cPtIpHA0QB1lMOyfX45w2yJrvA3pO1mi8mdZ/Du/9XT4 swfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=viAQBEui4uFQQDp0JnDS1D8uobRgBnYHriyDz5PJjAU=; b=IvtV3bYlSJASCNcaIbtj+x6V7ICQEt/twj4aZrIFBRXOtfTiDRlQl9lT/Ry1407syX pEt98X1X9m19+S9t9wyk66nR/6i8i7sDcOoaXlgeA5Uxe+vP7Z7vcSVr8q/54Q9RTCyZ ebbFi5sElIz3KSAkG3oI83HPxLWP/SfbRfXGlgjwXxMNfAwMTAV2R7Rpz5bsu1oi8UjX hdYPVPKkblXhRtxXmIBw0kbl8nZo1cTGfnR87cxeOKUP/bmkTS0lS0eXnWkf1jH/RcrL C/PVWTgQ6dbB86Ny327SC622nevi2V/35szP/lpCgjXHwLUhPVax3ek/gNmgYdXaGeUu 0qeQ== X-Gm-Message-State: AOAM532uFnRJroLRqXMeTESuFhlDtzVFv34OvTLhegNC2qK/frGJ4xgJ UTYyyIHcwB6k2UoQL2YPp8IEW4Y1 X-Google-Smtp-Source: ABdhPJzrAMQioNspiFTAowJdy3knVNN3qrYXWKk+ln9JCu1aYNR9qXbhPe5flo9C4eMuPtSk38TmjA== X-Received: by 2002:a05:6512:10ce:: with SMTP id k14mr8490076lfg.7.1596881826466; Sat, 08 Aug 2020 03:17:06 -0700 (PDT) Received: from localhost.localdomain (h-88-110.A230.priv.bahnhof.se. [212.85.88.110]) by smtp.gmail.com with ESMTPSA id a9sm4843767ljb.57.2020.08.08.03.17.05 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 08 Aug 2020 03:17:05 -0700 (PDT) From: Mikael Magnusson To: zsh-workers@zsh.org Subject: PATCH: edit-command-line: add editor style Date: Sat, 8 Aug 2020 12:17:00 +0200 Message-Id: <20200808101700.26329-1-mikachu@gmail.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20200808095148.21555-1-mikachu@gmail.com> References: <20200808095148.21555-1-mikachu@gmail.com> X-Zsh-Org-Should-ARC-Sign: true X-Seq: 47306 X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: Archived-At: Sender: Sympa Owner --- Completion/Zsh/Command/_zstyle | 1 + Doc/Zsh/contrib.yo | 6 ++++++ Functions/Zle/edit-command-line | 8 ++++++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Completion/Zsh/Command/_zstyle b/Completion/Zsh/Command/_zstyle index e9a5d800cd..bb871762ed 100644 --- a/Completion/Zsh/Command/_zstyle +++ b/Completion/Zsh/Command/_zstyle @@ -143,6 +143,7 @@ styles=( cursor e: edit-buffer e:bool edit-previous e:bool + editor e: insert-kept e: leave-cursor e:bool match e: diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo index 66e6bdc1e4..bab1e30231 100644 --- a/Doc/Zsh/contrib.yo +++ b/Doc/Zsh/contrib.yo @@ -2472,6 +2472,12 @@ item(tt(edit-command-line))( Edit the command line using your visual editor, as in tt(ksh). example(bindkey -M vicmd v edit-command-line) + +The editor to be used can also be specified using the tt(editor) style in +the context of the widget. It is specified as an array of command and +arguments: + +example(zstyle :zle:edit-command-line editor gvim -f) ) tindex(expand-absolute-path) item(tt(expand-absolute-path))( diff --git a/Functions/Zle/edit-command-line b/Functions/Zle/edit-command-line index 1103ca556c..8aaeb738e5 100644 --- a/Functions/Zle/edit-command-line +++ b/Functions/Zle/edit-command-line @@ -22,8 +22,12 @@ fi (( $+zle_bracketed_paste )) && print -r -n - $zle_bracketed_paste[2] # Open the editor, placing the cursor at the right place if we know how. - local editor=( "${(@Q)${(z)${VISUAL:-${EDITOR:-vi}}}}" ) - case $editor in + local -a editor + zstyle -a :zle:$WIDGET editor editor + if (( ! $#editor )); then + editor=( "${(@Q)${(z)${VISUAL:-${EDITOR:-vi}}}}" ) + fi + case $editor in (*vim*) integer byteoffset=$(( $#PREBUFFER + $#LBUFFER + 1 )) "${(@)editor}" -c "normal! ${byteoffset}go" -- $1;; -- 2.15.1