Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Start an external editor to edit the current zle buffer



Vincent Lefevre <vincent@xxxxxxxxxx> 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@xxxxxxx>                  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



Messages sorted by: Reverse Date, Date, Thread, Author