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

Can't bind C-z to a readline function without getting 'readline: maximum macro execution nesting level exceeded' with fzf-cd - Alt-C #3838

Open
5 of 10 tasks
excited-bore opened this issue Jun 4, 2024 · 5 comments

Comments

@excited-bore
Copy link

excited-bore commented Jun 4, 2024

Checklist

  • I have read through the manual page (man fzf)
  • I have searched through the existing issues
  • For bug reports, I have checked if the bug is reproducible in the latest version of fzf

Output of fzf --version

0.52.1 (6432f00)

OS

  • Linux
  • macOS
  • Windows
  • Etc.

Shell

  • bash
  • zsh
  • fish

Problem / Steps to reproduce

bind -m emacs-standard  '"\C-z": vi-undo'
bind -m vi-command      '"\C-z": vi-undo'
bind -m vi-insert       '"\C-z": vi-undo'
$: readline: maximum macro execution nesting level exceeded

This only seems to happen with readline functions for whatever reason.
'bind -x '"\C-z": exit' works without a hitch

@excited-bore
Copy link
Author

excited-bore commented Jun 4, 2024

Upon further inspection it seems like it had something to do with the order that i sourced my ~/.bashrc files more then a fzf bug.

First readline (bind) keybinds, then fzf, then 'complete -F _complete_alias "${!BASH_ALIASES[@]}"'

EDIT: Nevermind, it still seems to be a pure fzf issue and only comes up if I bind Ctrl-Z to something after sourceing ~/.fzf.bash

@junegunn
Copy link
Owner

junegunn commented Jun 5, 2024

Can't reproduce.

bash --noprofile --rcfile <(fzf --bash)

bind -m emacs-standard  '"\C-z": vi-undo'
bind -m vi-command      '"\C-z": vi-undo'
bind -m vi-insert       '"\C-z": vi-undo'

@excited-bore
Copy link
Author

I forgot a relevant line. Also set this in your .bashrc (bash --noprofile --rcfile <(fzf --bash) isn't completely similar):

[ -f ~/.fzf.bash ] && source ~/.fzf.bash

# Unset suspend signal shortcut (Ctrl+z)
stty susp undef

bind -m emacs-standard  '"\C-z": vi-undo'
bind -m vi-command      '"\C-z": vi-undo'
bind -m vi-insert       '"\C-z": vi-undo' 

in your .bashrc gives the 'readline: maximum macro execution nesting level exceeded' when using Alt-C

Sourcing [ -f ~/.fzf.bash ] && source ~/.fzf.bash after these lines will fix this mostly

# Unset suspend signal shortcut (Ctrl+z)
stty susp undef

bind -m emacs-standard  '"\C-z": vi-undo'
bind -m vi-command      '"\C-z": vi-undo'
bind -m vi-insert       '"\C-z": vi-undo' 

[ -f ~/.fzf.bash ] && source ~/.fzf.bash

Now Alt-C works, but Ctrl-z will now be bound to changing editing-modes (vi/emacs).
Removing stty susp undef stops this behaviour but also breaks `vi-undo

@junegunn
Copy link
Owner

junegunn commented Jun 5, 2024

Found out that it can only be reproduced in vi mode (which I don't use).

$ bash --noprofile --rcfile <(fzf --bash)
bash-5.2$ bind -m emacs-standard  '"\C-z": vi-undo'
bind -m vi-command      '"\C-z": vi-undo'
bind -m vi-insert       '"\C-z": vi-undo'
bash-5.2$
bash-5.2$ set -o vi
bash-5.2$ readline: maximum macro execution nesting level exceeded

Related: #1876 (comment)

So the current implementation relies on its internal C-Z binding, and overriding it breaks it. Patches are welcome.

@sebastiancarlos
Copy link

I'm having the exact same issue.

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

3 participants