Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement readline's yank-last-arg #343

Closed
pkgw opened this issue Jul 14, 2016 · 7 comments
Closed

Implement readline's yank-last-arg #343

pkgw opened this issue Jul 14, 2016 · 7 comments

Comments

@pkgw
Copy link

pkgw commented Jul 14, 2016

The implementation of readline's yank-last-arg command is currently a TODO. It would be good for it to actually get implemented!

@haridsv
Copy link
Contributor

haridsv commented Jul 24, 2016

How about creating a patch based on this gist ? I doesn't currently cycle back to the beginning, but it should be easy to modify it. It is also not identical to the readline's behavior, specifically on how readline recalls arguments from (n-1)th item if you are currently at nth item, but honestly, I prefer always starting from -1 irrespective of where you are in the history.

@jonathanslenders

@haridsv
Copy link
Contributor

haridsv commented Jul 24, 2016

The gist also takes care of yank-nth-arg, though I noticed that the issue #359 makes it less useful.

adamchainz pushed a commit to adamchainz/python-prompt-toolkit that referenced this issue Oct 20, 2016
Fixes prompt-toolkit#343. Alternative implementation to prompt-toolkit#336 that uses a single function and also implements `yank-nth-arg`, in the same style as readline.
@adamchainz
Copy link
Contributor

Thanks for the gist! I adapted it into my implementation in #407 which uses function 'local' variables rather than a separate state and also deduplicates on repeat presses like readline does.

@jonathanslenders
Copy link
Member

Thanks everyone for the pull requests! So far, I did not had any time yet to review/merge this functionality, but I hope to do it soon. It's very useful!

@jonathanslenders
Copy link
Member

Hi everyone, this functionality has been mergen in 0c09bf0

If you have time, could you have a look and see whether it works?

Jonathan

@amitkot
Copy link

amitkot commented Aug 8, 2024

Can this useful feature be used with vi binding as well?

I'm using Xonsh and for the time being I added this binding:

@events.on_ptk_create
def custom_keybindings(bindings, **kw):

    @bindings.add('escape', '.')
    def yank_last(event):
        event.current_buffer.yank_last_arg()

@adamchainz
Copy link
Contributor

Please don’t comment on eight year old issues. Instead, open a new one referencing this one...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants