zsh-users
 help / color / mirror / code / Atom feed
* most-recent-file completion and accept-line
@ 2004-09-22 22:45 Eric Smith
  2004-09-23  7:59 ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Smith @ 2004-09-22 22:45 UTC (permalink / raw)
  To: Zsh Users

One of the most useful lines in my config file is:
bindkey '^O' most-recent-file

How do I bind a key combination to complete the most recent file
and then automatically run accept-line or <enter> on this
filename?

(my preexec function will do the necessary on the file).

thanks a lot :)

-- 
Eric Smith


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

* Re: most-recent-file completion and accept-line
  2004-09-22 22:45 most-recent-file completion and accept-line Eric Smith
@ 2004-09-23  7:59 ` Bart Schaefer
  2004-11-02 20:06   ` Eric Smith
  0 siblings, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 2004-09-23  7:59 UTC (permalink / raw)
  To: Zsh Users

On Thu, 23 Sep 2004, Eric Smith wrote:

> How do I bind a key combination to complete the most recent file
> and then automatically run accept-line or <enter> on this
> filename?

This seems like an odd question, because any key _combination_ you choose
will be at least as many keystrokes as typing ctrl-o enter.  Normally you
want bindings for things that would otherwise take lots of keystrokes.

However:

accept-most-recent() {
  zle most-recent-file && zle .accept-line
}
zle -N accept-most-recent
bindkey '^X^O' accept-most-recent


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

* Re: most-recent-file completion and accept-line
  2004-09-23  7:59 ` Bart Schaefer
@ 2004-11-02 20:06   ` Eric Smith
  2004-11-04  1:52     ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Smith @ 2004-11-02 20:06 UTC (permalink / raw)
  To: zsh-users

Thanks a lot Bart.

When I tried this previously, I could not get it to work, now it kinda works,
so I finally respond.  Except you need to press the key combo twice, once for
all the possible options to appear and after the second press it accepts one of
the listed files.

Perhpas I have something configured that interferes with it?
Any way FWIW, here is my experience:


[eric@pepper ~] 13 $ ls -rt1 delm*
delme_fruitcom__08_04.pdf
delme_fruitcom__08_04.txt
delme_fruitcom__16_04.pdf
delme_fruitcom__16_04.txt
delme_zz___fruitcom_Monday_June_28_2004.pdf
delme_zz___fruitcom_Monday_June_28_2004.txt
delme_zz___fruitcom_Saturday_July_10_2004.pdf
delme_zz___fruitcom_Saturday_July_10_2004.txt
delme_zz___fruitcom_Wednesday_September_15_2004.pdf
delme_zz___fruitcom_Wednesday_September_15_2004.txt
delme.pdf
delme.txt
delme.xml

[eric@pepper ~] 13 $ ls delme<^X^O>
[eric@pepper ~] 13 $ ls delme.pdf
delme.pdf                                             delme_zz___fruitcom_Monday_June_28_2004.pdf
delme.txt                                             delme_zz___fruitcom_Monday_June_28_2004.txt
delme.xml                                             delme_zz___fruitcom_Saturday_July_10_2004.pdf
delme_fruitcom__08_04.pdf                             delme_zz___fruitcom_Saturday_July_10_2004.txt
delme_fruitcom__08_04.txt                             delme_zz___fruitcom_Wednesday_September_15_2004.pdf
delme_fruitcom__16_04.pdf                             delme_zz___fruitcom_Wednesday_September_15_2004.txt
delme_fruitcom__16_04.txt
[eric@pepper ~] 13 $ ls delme.pdf<^X^O>
[eric@pepper ~] 13 $ ls delme.txt
delme.txt

<Yes, it looks a bit weird>

Bart Schaefer said:
> On Thu, 23 Sep 2004, Eric Smith wrote:
> 
> > How do I bind a key combination to complete the most recent file
> > and then automatically run accept-line or <enter> on this
> > filename?
> 
> This seems like an odd question, because any key _combination_ you choose
> will be at least as many keystrokes as typing ctrl-o enter.  Normally you
> want bindings for things that would otherwise take lots of keystrokes.

So I bind your function to ^O 

> However:
> 
> accept-most-recent() {
>   zle most-recent-file && zle .accept-line
> }
> zle -N accept-most-recent
> bindkey '^X^O' accept-most-recent

-- 
Eric Smith


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

* Re: most-recent-file completion and accept-line
  2004-11-02 20:06   ` Eric Smith
@ 2004-11-04  1:52     ` Bart Schaefer
  0 siblings, 0 replies; 4+ messages in thread
From: Bart Schaefer @ 2004-11-04  1:52 UTC (permalink / raw)
  To: zsh-users

On Tue, 2 Nov 2004, Eric Smith wrote:

> When I tried this previously, I could not get it to work, now it kinda 
> works, so I finally respond.  Except you need to press the key combo 
> twice, once for all the possible options to appear and after the second 
> press it accepts one of the listed files.
> 
> Perhpas I have something configured that interferes with it?

Notice the "&&" in there -- if the most-recent-file widget does not yield 
a zero status, accept-line will not be executed.  However, I don't know 
what if any circumstances would cause a nonzero status.

I hadn't noticed before, but in my zsh installation the name of the widget 
is _most_recent_file, [*] not most-recent-file, so there must be something 
else you're doing to create the hyphenated-name version.  Maybe that would 
provide a clue.


[*] And it's bound to ^Xm as well.


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

end of thread, other threads:[~2004-11-04  1:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-22 22:45 most-recent-file completion and accept-line Eric Smith
2004-09-23  7:59 ` Bart Schaefer
2004-11-02 20:06   ` Eric Smith
2004-11-04  1:52     ` Bart Schaefer

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