abo-abo/avy

Feature request: a counterpart to 'avy-isearch that works with the "ctrlf" package

mmarshall540 opened this issue · 1 comments

The "avy-isearch" command allows jumping to any visible search candidate during an isearch. But after installing the isearch replacement package, "ctrlf", I wanted the same functionality when searching with it.

But of course, "avy-isearch" was written for isearch, not ctrlf. So I copied the avy-isearch definition to my init.el, renamed it, and modified it to work with ctrlf.

(defun my/avy-ctrlf ()
  "Jump to one of the current ctrlf search candidates.
Like ‘avy-isearch’, but works with ‘ctrlf’ instead."
  (interactive)
  (avy-with avy-isearch
    (let ((avy-background nil)
          (avy-case-fold-search case-fold-search))
      (select-window (minibuffer-selected-window))
      (prog1
          (avy-process
           (avy--regex-candidates (if (eq ctrlf--style 'regexp)
                                      ctrlf--last-input
                                    (regexp-quote ctrlf--last-input))))))
    (ctrlf--delete-all-overlays)
    (abort-recursive-edit)))

Ctrlf seems to be a popular package, so maybe this could be included in Avy?

Thank you for Avy and your many other great works!

Funny, I stopped using the "ctrlf" package the same day that I posted this issue, and I'm back to using "isearch". (The thing that was bothering me about isearch was the way C-g works. But after reviewing the isearch section of the Emacs manual, it all makes sense now.)

So the "my/avy-ctrlf" function has already become obsolete for my own purposes.

I'll leave this issue in case anyone else finds it useful or feels that it should be included in Avy. Otherwise, I'll come back and close it after some time has passed.

SIDENOTE: I considered posting this to the "ctrlf" project. But it's a modification of GPL code from Avy (the original "avy-isearch" function), and "ctrlf" is published under the MIT license. Not sure if it matters, but it seemed wise to err on the side of caution.