zsh-workers
 help / color / mirror / code / Atom feed
* Can't redefine execute-named-cmd ??
@ 2005-03-21  1:50 Bart Schaefer
  2005-03-21 11:13 ` Peter Stephenson
  0 siblings, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2005-03-21  1:50 UTC (permalink / raw)
  To: zsh-workers

If I run these commands:

execute-named-cmd() { zle -R HERE; sleep 2; zle .execute-named-cmd "$@" }
zle -N execute-named-cmd

and I then invoke execute-named-cmd, I go directly to the "execute:"
prompt, with no display of "HERE" and no sleep.

Furthermore, if instead I do this:

execute-widget() { zle -R HERE; sleep 2; zle .execute-named-cmd "$@" }
zle -N execute-widget
bindkey '\ex' execute-widget

and then I invoke execute-widget, the shell displays HERE for two seconds
and then crashes.  This happens whether or not I have the leading dot in
the widget name, is NOT affected by the presence or absence of "$@", and
happens even when "zle -N execute-named-cmd" has NOT been run.

This applies to 4.2.4 as well as to the latest CVS.


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

* Re: Can't redefine execute-named-cmd ??
  2005-03-21  1:50 Can't redefine execute-named-cmd ?? Bart Schaefer
@ 2005-03-21 11:13 ` Peter Stephenson
  2005-03-21 11:24   ` Geoff Wing
  2005-03-21 16:11   ` Bart Schaefer
  0 siblings, 2 replies; 5+ messages in thread
From: Peter Stephenson @ 2005-03-21 11:13 UTC (permalink / raw)
  To: Zsh hackers list

(sorry, should have gone to the list but went to Bart privately by
mistake.)

execute-named-command as well as the isearch commands have horribly
incestuous ways of using key bindings.  They could do with being
rewritten as a suite of functions with special keymaps.  I briefly
looked at this for isearch and it's non-trivial.  This would be a
splendid project for someone with a firm grip on themselves and
adequate supplies of a good malt.  As things stand I will probably be
available to work on this myself in 2012 (but don't hold me to 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 email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

**********************************************************************


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

* Re: Can't redefine execute-named-cmd ??
  2005-03-21 11:13 ` Peter Stephenson
@ 2005-03-21 11:24   ` Geoff Wing
  2005-03-21 16:11   ` Bart Schaefer
  1 sibling, 0 replies; 5+ messages in thread
From: Geoff Wing @ 2005-03-21 11:24 UTC (permalink / raw)
  To: zsh-workers

Peter Stephenson <pws@csr.com> typed:
:                                                   This would be a
: splendid project for someone with a firm grip on themselves and
: adequate supplies of a good malt.

Would an adequate grip on themselves and a firm supply of a good malt do?  :-)

Oops, maybe this is a bad selection of target humour  :-(

Geoff


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

* Re: Can't redefine execute-named-cmd ??
  2005-03-21 11:13 ` Peter Stephenson
  2005-03-21 11:24   ` Geoff Wing
@ 2005-03-21 16:11   ` Bart Schaefer
  2005-03-21 16:57     ` Peter Stephenson
  1 sibling, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2005-03-21 16:11 UTC (permalink / raw)
  To: Zsh hackers list

On Mar 21, 11:13am, Peter Stephenson wrote:
}
} execute-named-command as well as the isearch commands have horribly
} incestuous ways of using key bindings.

Obviously so, but what does that have to do with the inability to
redefine it?  And why does it cause a crash when calling it by name
with "zle execute-named-cmd"?

Something more than keybindings is rotten in Denmark, if you'll pardon
my cliche.

} They could do with being
} rewritten as a suite of functions with special keymaps. [...]
} As things stand I will probably be available to work on this myself in
} 2012 (but don't hold me to it).

Yes, I've looked at that, too, and been similarly discouraged.


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

* Re: Can't redefine execute-named-cmd ??
  2005-03-21 16:11   ` Bart Schaefer
@ 2005-03-21 16:57     ` Peter Stephenson
  0 siblings, 0 replies; 5+ messages in thread
From: Peter Stephenson @ 2005-03-21 16:57 UTC (permalink / raw)
  To: Zsh hackers list

Bart Schaefer wrote:
> On Mar 21, 11:13am, Peter Stephenson wrote:
> }
> } execute-named-command as well as the isearch commands have horribly
> } incestuous ways of using key bindings.
> 
> Obviously so, but what does that have to do with the inability to
> redefine it?

It's kludged into getkeycmd() in a horrible way.  It doesn't have its
own separate widget; it simply gets recognised when we try to read a
command from keystrokes, and the resulting command read by
executenamedcommand() is returned instead.  It's the same for
execute-last-named-command.

> And why does it cause a crash when calling it by name
> with "zle execute-named-cmd"?

Because it doesn't work like a proper widget, the value of the function
is set to NULL.  This isn't handled.

Until someone can de-kludge it, the best we can do is test for the NULL
and document the limitations.

Index: Doc/Zsh/zle.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/zle.yo,v
retrieving revision 1.45
diff -u -r1.45 zle.yo
--- Doc/Zsh/zle.yo	16 Nov 2004 19:06:40 -0000	1.45
+++ Doc/Zsh/zle.yo	21 Mar 2005 16:55:22 -0000
@@ -1670,10 +1670,14 @@
 Any other character that is not bound to tt(self-insert) or
 tt(self-insert-unmeta) will beep and be ignored.
 The bindings of the current insert mode will be used.
+
+Currently this command may not be redefined or called by name.
 )
 tindex(execute-last-named-cmd)
 item(tt(execute-last-named-cmd) (ESC-z) (unbound) (unbound))(
 Redo the last function executed with tt(execute-named-cmd).
+
+Currently this command may not be redefined or called by name.
 )
 tindex(get-line)
 item(tt(get-line) (ESC-G ESC-g) (unbound) (unbound))(
Index: Src/Zle/zle_main.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_main.c,v
retrieving revision 1.65
diff -u -r1.65 zle_main.c
--- Src/Zle/zle_main.c	15 Mar 2005 10:51:04 -0000	1.65
+++ Src/Zle/zle_main.c	21 Mar 2005 16:55:22 -0000
@@ -1053,6 +1053,8 @@
 		ret = completecall(args);
 		if (atcurhist)
 		    histline = curhist;
+	    } else if (!w->u.fn) {
+		handlefeep(zlenoargs);
 	    } else {
 		queue_signals();
 		ret = w->u.fn(args);

-- 
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 email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

**********************************************************************


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

end of thread, other threads:[~2005-03-21 16:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-21  1:50 Can't redefine execute-named-cmd ?? Bart Schaefer
2005-03-21 11:13 ` Peter Stephenson
2005-03-21 11:24   ` Geoff Wing
2005-03-21 16:11   ` Bart Schaefer
2005-03-21 16:57     ` 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).