(defun avy-goto-symbol-at-point (&optional arg)
"Jump to a visible occurance of symbol-at-point.
The window scope is determined by `avy-all-windows' (ARG negates it)."
(interactive "P")
(let ((avy-all-windows (if arg
(not avy-all-windows)
avy-all-windows)))
(avy-with avy-goto-symbol-at-point
(avy-process
(avy--regex-candidates (regexp-quote (thing-at-point 'symbol t)))))))
While it could be used on its own, I'm using it with symbol-overlay which highlights all occurances of a symbol in a buffer and lets you navigate between them with next and previous and first and last functions. This allows jumping to a specific visible occurrence via avy which is very nice. The important point in this case is that it doesn't need user input the way avy-goto-char-timer does.
I suggested such a function to symbol-overlay but they understandably didn't want to add a dependency on avy. If avy offered such a command, another package could simply bind it to a keymap or call it if fboundp and not have a hard dependency.
I'm not sure of the best way to implement such a command. Perhaps it should be an avy-goto-string that takes the string as the argument (which would be useful when called from other packages). The default value when called interactively could be gotten from thing-at-point and enabled when using "future history" via M-n at the prompt. Here's a first approximation that doesn't deal with avy-all-windows.
(defun avy-goto-string (string)
"Jump to a visible occurance of string."
(interactive (list (read-from-minibuffer "String: " nil nil nil nil (thing-at-point 'symbol t))))
(avy-with avy-goto-string
(avy-process
(avy--regex-candidates (regexp-quote string)))))
I could see an avy-goto-regexp being useful too. I haven't put too much thought into it yet and wanted to know if such a thing was previously considered and rejected for some reason that isn't obvious to me.
I'm finding the following useful:
While it could be used on its own, I'm using it with
symbol-overlay
which highlights all occurances of a symbol in a buffer and lets you navigate between them with next and previous and first and last functions. This allows jumping to a specific visible occurrence viaavy
which is very nice. The important point in this case is that it doesn't need user input the wayavy-goto-char-timer
does.I suggested such a function to
symbol-overlay
but they understandably didn't want to add a dependency onavy
. Ifavy
offered such a command, another package could simply bind it to a keymap or call it iffboundp
and not have a hard dependency.I'm not sure of the best way to implement such a command. Perhaps it should be an
avy-goto-string
that takes the string as the argument (which would be useful when called from other packages). The default value when called interactively could be gotten from thing-at-point and enabled when using "future history" via M-n at the prompt. Here's a first approximation that doesn't deal withavy-all-windows
.I could see an
avy-goto-regexp
being useful too. I haven't put too much thought into it yet and wanted to know if such a thing was previously considered and rejected for some reason that isn't obvious to me.