zsh-users
 help / color / mirror / code / Atom feed
* Start an external editor to edit the current zle buffer
@ 2005-11-04 13:24 Vincent Lefevre
  2005-11-04 13:49 ` Peter Stephenson
  0 siblings, 1 reply; 8+ messages in thread
From: Vincent Lefevre @ 2005-11-04 13:24 UTC (permalink / raw)
  To: zsh-users

Is there a way to start an external editor (e.g. given by $FCEDIT)
to edit the current buffer and go back to zle?

This can be useful if some operations are easier with the mouse.

-- 
Vincent Lefèvre <vincent@vinc17.org> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / SPACES project at LORIA


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Start an external editor to edit the current zle buffer
  2005-11-04 13:24 Start an external editor to edit the current zle buffer Vincent Lefevre
@ 2005-11-04 13:49 ` Peter Stephenson
  2005-11-04 14:43   ` Vincent Lefevre
  0 siblings, 1 reply; 8+ messages in thread
From: Peter Stephenson @ 2005-11-04 13:49 UTC (permalink / raw)
  To: zsh-users

Vincent Lefevre wrote:
> Is there a way to start an external editor (e.g. given by $FCEDIT)
> to edit the current buffer and go back to zle?
> 
> This can be useful if some operations are easier with the mouse.

See the ZLE function edit-command-line supplied with the shell.  It's
quite short and you might want to tweak it.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Start an external editor to edit the current zle buffer
  2005-11-04 13:49 ` Peter Stephenson
@ 2005-11-04 14:43   ` Vincent Lefevre
  2005-11-04 14:53     ` Peter Stephenson
  0 siblings, 1 reply; 8+ messages in thread
From: Vincent Lefevre @ 2005-11-04 14:43 UTC (permalink / raw)
  To: zsh-users

On 2005-11-04 13:49:25 +0000, Peter Stephenson wrote:
> Vincent Lefevre wrote:
> > Is there a way to start an external editor (e.g. given by $FCEDIT)
> > to edit the current buffer and go back to zle?
> > 
> > This can be useful if some operations are easier with the mouse.
> 
> See the ZLE function edit-command-line supplied with the shell.  It's
> quite short and you might want to tweak it.

Thanks. Is there any reason why it is not available by default and
not documented in the zshzle man page?

Also why does fc use $FCEDIT and not ${VISUAL:-${EDITOR:-vi}} like
edit-command-line (or the opposite)?

-- 
Vincent Lefèvre <vincent@vinc17.org> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / SPACES project at LORIA


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Start an external editor to edit the current zle buffer
  2005-11-04 14:43   ` Vincent Lefevre
@ 2005-11-04 14:53     ` Peter Stephenson
  2005-11-04 15:48       ` Vincent Lefevre
  0 siblings, 1 reply; 8+ messages in thread
From: Peter Stephenson @ 2005-11-04 14:53 UTC (permalink / raw)
  To: zsh-users

Vincent Lefevre wrote:
> On 2005-11-04 13:49:25 +0000, Peter Stephenson wrote:
> > Vincent Lefevre wrote:
> > > Is there a way to start an external editor (e.g. given by $FCEDIT)
> > > to edit the current buffer and go back to zle?
> > > 
> > > This can be useful if some operations are easier with the mouse.
> > 
> > See the ZLE function edit-command-line supplied with the shell.  It's
> > quite short and you might want to tweak it.
> 
> Thanks. Is there any reason why it is not available by default and
> not documented in the zshzle man page?

Yes: it's not part of zle, it's a contributed function and like all such
is documented in zshcontrib and needs to be loaded.

> Also why does fc use $FCEDIT and not ${VISUAL:-${EDITOR:-vi}} like
> edit-command-line (or the opposite)?

FCEDIT is specific to the fc command.  edit-command-line assumes you
want to use your normal editor.  You can easily change it.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Start an external editor to edit the current zle buffer
  2005-11-04 14:53     ` Peter Stephenson
@ 2005-11-04 15:48       ` Vincent Lefevre
  2005-11-04 16:10         ` Peter Stephenson
  0 siblings, 1 reply; 8+ messages in thread
From: Vincent Lefevre @ 2005-11-04 15:48 UTC (permalink / raw)
  To: zsh-users

On 2005-11-04 14:53:43 +0000, Peter Stephenson wrote:
> Vincent Lefevre wrote:
> > On 2005-11-04 13:49:25 +0000, Peter Stephenson wrote:
> > > See the ZLE function edit-command-line supplied with the shell.  It's
> > > quite short and you might want to tweak it.
> > 
> > Thanks. Is there any reason why it is not available by default and
> > not documented in the zshzle man page?
> 
> Yes: it's not part of zle, it's a contributed function and like all such
> is documented in zshcontrib and needs to be loaded.

Shouldn't it become part of zle?

> > Also why does fc use $FCEDIT and not ${VISUAL:-${EDITOR:-vi}} like
> > edit-command-line (or the opposite)?
> 
> FCEDIT is specific to the fc command.  edit-command-line assumes you
> want to use your normal editor.  You can easily change it.

Why doesn't fc assume I want to use my normal editor?
Is there any reason to have $FCEDIT different from $VISUAL or $EDITOR?

-- 
Vincent Lefèvre <vincent@vinc17.org> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / SPACES project at LORIA


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Start an external editor to edit the current zle buffer
  2005-11-04 15:48       ` Vincent Lefevre
@ 2005-11-04 16:10         ` Peter Stephenson
  2005-11-04 16:32           ` Vincent Lefevre
  0 siblings, 1 reply; 8+ messages in thread
From: Peter Stephenson @ 2005-11-04 16:10 UTC (permalink / raw)
  To: zsh-users

Vincent Lefevre wrote:
> Shouldn't it become part of zle?

I don't think so.  The functions are supplied to be extensible and
flexible.  It's hardly harder to use a function widget than a builtin
one and it's much easier to change it.  For something like this, which
runs external commands and handles the output, it's also much easier to
write the function in the shell command language than in C.

One of the reasons for the new manual roadmap is to indicate things like
the presence of add-on zle functions documented in zshcontrib which users
might otherwise not notice, although it doesn't specifically mention
edit-command-line.

> > > Also why does fc use $FCEDIT and not ${VISUAL:-${EDITOR:-vi}} like
> > > edit-command-line (or the opposite)?
> > 
> > FCEDIT is specific to the fc command.  edit-command-line assumes you
> > want to use your normal editor.  You can easily change it.
> 
> Why doesn't fc assume I want to use my normal editor?

Historical reasons, presumably, since this came from ksh.  It's not much
used.

> Is there any reason to have $FCEDIT different from $VISUAL or $EDITOR?

Not that I'm aware of.  Set it to what you like.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Start an external editor to edit the current zle buffer
  2005-11-04 16:10         ` Peter Stephenson
@ 2005-11-04 16:32           ` Vincent Lefevre
  2005-11-04 17:42             ` Peter Stephenson
  0 siblings, 1 reply; 8+ messages in thread
From: Vincent Lefevre @ 2005-11-04 16:32 UTC (permalink / raw)
  To: zsh-users

On 2005-11-04 16:10:49 +0000, Peter Stephenson wrote:
> Vincent Lefevre wrote:
> > Shouldn't it become part of zle?
> 
> I don't think so.  The functions are supplied to be extensible and
> flexible.  It's hardly harder to use a function widget than a builtin
> one and it's much easier to change it.  For something like this, which
> runs external commands and handles the output, it's also much easier to
> write the function in the shell command language than in C.

I agree, but this wasn't really my question. The main problem is that
this feature isn't documented in zshzle, therefore more difficult to
find.

> One of the reasons for the new manual roadmap is to indicate things like
> the presence of add-on zle functions documented in zshcontrib which users
> might otherwise not notice, although it doesn't specifically mention
> edit-command-line.

I reformulate my question: couldn't edit-command-line become more
official and be documented in the zshzle man page?

Also,

  autoload edit-command-line
  zle -N edit-command-line
  bindkey '\ee' edit-command-line

is more code to type (even if it is done once). Could there be a zsh
option so that

  bindkey '\ee' edit-command-line

automatically calls autoload and zle -N if need be?

> > > FCEDIT is specific to the fc command.  edit-command-line assumes you
> > > want to use your normal editor.  You can easily change it.
> > 
> > Why doesn't fc assume I want to use my normal editor?
> 
> Historical reasons, presumably, since this came from ksh.  It's not much
> used.

OK. BTW, why is FCEDIT defined by default as "vi"? Why not let it
unset, in which case $VISUAL or $EDITOR would be used?

-- 
Vincent Lefèvre <vincent@vinc17.org> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / SPACES project at LORIA


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Start an external editor to edit the current zle buffer
  2005-11-04 16:32           ` Vincent Lefevre
@ 2005-11-04 17:42             ` Peter Stephenson
  0 siblings, 0 replies; 8+ messages in thread
From: Peter Stephenson @ 2005-11-04 17:42 UTC (permalink / raw)
  To: zsh-users

Vincent Lefevre <vincent@vinc17.org> wrote:
> On 2005-11-04 16:10:49 +0000, Peter Stephenson wrote:
> I agree, but this wasn't really my question. The main problem is that
> this feature isn't documented in zshzle, therefore more difficult to
> find.

I repeat: this is exactly what the roadmap is for.  It already points the
reader at zshcontrib for additional functions.  I've added this one
to the list of samples.

> I reformulate my question: couldn't edit-command-line become more
> official and be documented in the zshzle man page?

It's not a question of officalness; zshzle documents built-in features, not
add-ons.

> Also,
> 
>   autoload edit-command-line
>   zle -N edit-command-line
>   bindkey '\ee' edit-command-line
> 
> is more code to type (even if it is done once). Could there be a zsh
> option so that
> 
>   bindkey '\ee' edit-command-line
> 
> automatically calls autoload and zle -N if need be?

bindkeyl() {
  autoload $argv[-1]
  zle -N $argv[-1]
  bindkey $*
}
bindkeyl '\ee' edit-command-line

> > > > FCEDIT is specific to the fc command.  edit-command-line assumes you
> > > > want to use your normal editor.  You can easily change it.
> > > 
> > > Why doesn't fc assume I want to use my normal editor?
> > 
> > Historical reasons, presumably, since this came from ksh.  It's not much
> > used.
> 
> OK. BTW, why is FCEDIT defined by default as "vi"? Why not let it
> unset, in which case $VISUAL or $EDITOR would be used?

Given that the documentation doesn't even say it has a default, and
actually the shell uses that default value even if the parameter isn't set,
that doesn't seem unreasonable.

Index: Src/builtin.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v
retrieving revision 1.150
diff -u -r1.150 builtin.c
--- Src/builtin.c	19 Oct 2005 21:59:36 -0000	1.150
+++ Src/builtin.c	4 Nov 2005 17:32:11 -0000
@@ -1461,6 +1461,8 @@
 		else
 		    editor = getsparam("FCEDIT");
 		if (!editor)
+		    editor = getsparam("EDITOR");
+		if (!editor)
 		    editor = DEFAULT_FCEDIT;
 
 		unqueue_signals();
Index: Src/params.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/params.c,v
retrieving revision 1.106
diff -u -r1.106 params.c
--- Src/params.c	2 Nov 2005 12:04:47 -0000	1.106
+++ Src/params.c	4 Nov 2005 17:32:11 -0000
@@ -643,7 +643,6 @@
 #ifdef HAVE_SELECT
     setiparam("BAUD", getbaudrate(&shttyinfo));  /* get the output baudrate */
 #endif
-    setsparam("FCEDIT", ztrdup(DEFAULT_FCEDIT));
     setsparam("TMPPREFIX", ztrdup(DEFAULT_TMPPREFIX));
     setsparam("TIMEFMT", ztrdup(DEFAULT_TIMEFMT));
     setsparam("WATCHFMT", ztrdup(default_watchfmt));
Index: Doc/Zsh/builtins.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/builtins.yo,v
retrieving revision 1.80
diff -u -r1.80 builtins.yo
--- Doc/Zsh/builtins.yo	10 Aug 2005 07:47:49 -0000	1.80
+++ Doc/Zsh/builtins.yo	4 Nov 2005 17:32:12 -0000
@@ -410,7 +410,9 @@
 pattern will be shown.
 Otherwise the editor program var(ename) is invoked on a file containing
 these history events.  If var(ename) is not given, the value
-of the parameter tt(FCEDIT) is used.  If var(ename) is `tt(-)',
+of the parameter tt(FCEDIT) is used; if that is not set the value of the
+parameter tt(EDITOR) is used; if that is not set a builtin default, usually
+`tt(vi)' is used.  If var(ename) is `tt(-)',
 no editor is invoked.  When editing is complete, the edited
 command is executed.
 
Index: Doc/Zsh/params.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/params.yo,v
retrieving revision 1.26
diff -u -r1.26 params.yo
--- Doc/Zsh/params.yo	1 Aug 2005 09:55:00 -0000	1.26
+++ Doc/Zsh/params.yo	4 Nov 2005 17:32:12 -0000
@@ -758,7 +758,9 @@
 )
 vindex(FCEDIT)
 item(tt(FCEDIT))(
-The default editor for the tt(fc) builtin.
+The default editor for the tt(fc) builtin.  If tt(FCEDIT) is not set,
+the parameter tt(EDITOR) is used; if that is not set either, a builtin
+default, usually tt(vi), is used.
 )
 vindex(fignore)
 vindex(FIGNORE)
Index: Doc/Zsh/roadmap.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/roadmap.yo,v
retrieving revision 1.3
diff -u -r1.3 roadmap.yo
--- Doc/Zsh/roadmap.yo	30 Oct 2005 20:50:04 -0000	1.3
+++ Doc/Zsh/roadmap.yo	4 Nov 2005 17:32:12 -0000
@@ -58,7 +58,10 @@
 alternative ways of searching the shell history
 )
 item(tt(replace-string), tt(replace-pattern))(
-functions for replacing strings or patterns globally in the command line.
+functions for replacing strings or patterns globally in the command line
+)
+item(tt(edit-command-line))(
+edit the command line with an external editor.
 )
 enditem()
 


-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2005-11-04 17:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-04 13:24 Start an external editor to edit the current zle buffer Vincent Lefevre
2005-11-04 13:49 ` Peter Stephenson
2005-11-04 14:43   ` Vincent Lefevre
2005-11-04 14:53     ` Peter Stephenson
2005-11-04 15:48       ` Vincent Lefevre
2005-11-04 16:10         ` Peter Stephenson
2005-11-04 16:32           ` Vincent Lefevre
2005-11-04 17:42             ` Peter Stephenson

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).