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

Hydra-repeat not picking up universal-argument #386

Open
HannesHaglund opened this issue Oct 11, 2020 · 0 comments
Open

Hydra-repeat not picking up universal-argument #386

HannesHaglund opened this issue Oct 11, 2020 · 0 comments

Comments

@HannesHaglund
Copy link

HannesHaglund commented Oct 11, 2020

Hello,

Thank you for developing this great package.

hydra-repeat isn't picking up universal-argument for me. To reproduce it I define the following hydra (based on this random blog-post: https://oremacs.com/2015/02/28/hydra-repeat/ ):

(defhydra hydra-vi ()
  "vi"
  ("j" next-line)
  ("." hydra-repeat))

And perform the following chords:

M-x hydra-vi/body 4 j .

I expect the point to move eight lines down, but it only moves a total of five: Four when invoking next-line using j, and one when invoking hydra-repeat.

I have a potential fix: I tried changing the definition of hydra-repeat from

(defun hydra-repeat (&optional arg)
  "Repeat last command with last prefix arg.
When ARG is non-nil, use that instead."
  (interactive "p")
  (if (eq arg 1)
      (unless (string-match "hydra-repeat$" (symbol-name last-command))
        (setq hydra-repeat--command last-command)
        (setq hydra-repeat--prefix-arg last-prefix-arg))
    (setq hydra-repeat--prefix-arg arg))
  (setq current-prefix-arg hydra-repeat--prefix-arg)
  (funcall hydra-repeat--command))

to

(defun hydra-repeat (&optional arg)
  "Repeat last command with last prefix arg.
When ARG is non-nil, use that instead."
  (interactive "p")
  (if (eq arg 1)
      (unless (string-match "hydra-repeat$" (symbol-name last-command))
        (setq hydra-repeat--command last-command)
        (setq hydra-repeat--prefix-arg last-prefix-arg))
    (setq hydra-repeat--prefix-arg arg))
  (setq current-prefix-arg hydra-repeat--prefix-arg)
  (call-interactively hydra-repeat--command))

The difference is that I use call-interactively instead of funcall. This caused hydra-repeat to actually reuse the prefix-arg from the previous function, which I think is the intended behavior. Please note that I'm not intimately familiar with when one should be used over the other. Could this cause issues that I'm not seeing? Note that the repeat command (the non-hydra one) uses call-interactively rather than funcall.

I also tried changing it to funcall-interactively rather than call-interactively, but it has the same behavior as funcall in this case.

I'm using hydra-20200306.913 from elpa with emacs27 on Ubuntu.

Is hydra-repeat doing what it is supposed to, and if not, is my fix appropriate?

Thanks.

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

1 participant