From: Mikael Magnusson <mikachu@gmail.com>
To: zsh-workers@zsh.org
Subject: PATCH: edit-command-line: add editor style
Date: Sat, 8 Aug 2020 12:17:00 +0200 [thread overview]
Message-ID: <20200808101700.26329-1-mikachu@gmail.com> (raw)
In-Reply-To: <20200808095148.21555-1-mikachu@gmail.com>
---
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
next prev parent reply other threads:[~2020-08-08 10:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-08 9:51 PATCH: edit-command-line: when possible, set $BUFFER directly Mikael Magnusson
2020-08-08 10:17 ` Mikael Magnusson [this message]
2020-08-08 10:18 ` PATCH: edit-command-line: restrict editing to region if it is active Mikael Magnusson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200808101700.26329-1-mikachu@gmail.com \
--to=mikachu@gmail.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).